# Building Logic Gates

I’ve been working with Desmos as its own unique programming language for nearly two years now. I’ve been doing small projects, with simple Logic Gates (i.e. {g<7:h->5}). I have also discovered that in these if this, then that statements, you can create if this and that, then that logic gates (i.e. {g<7 {j>0}:h->5}. I haven’t discovered how to create if this, then that & that type statements. For example, how would I create a logic gate that says, if g is greater than 7 then h goes to 5 and j goes to 9. The best solution I have discovered is doing it as two separate gates ({g<7:h->5}, {g<7:j->9}), but I do not want it to be this bulky for the more complex logic gates I am setting up. Any help would be much appreciated. Oh, and also, if there’s any better way to copy the equations from Desmos Graphs into these posts for better formatting than the ugliness above, I’d like to know that as well!

1 Like

Nevermind. I think I figured it out. For those of you questioning the same thing, you can solve this by formatting in the following way, for the example I asked above. By using parenthesis, it allows for both actions to be undertaken if the previous statement is true.

{g>7:(h->5, j->9)}

1 Like

Also, I’d still love to know what’s the easiest way to better format the equations in this is. Any help would still be appreciated!

I don’t think there is a better way to format it. Conditionals in Desmos can be pretty hard to read when they have lots of branches. Here is an example of how I usually deal with AND and OR:

You can separate “or” condtions using commas, and just use restrictions on a condition for an “and”. I don’t have anything much cleaner for xor.

Thank you! I appreciate the help!

Thanks - I always forget that there is that simpler way. Are there any other conditional tips/tricks that make them easier to read/parse?

Nothing in particular aside from throwing extra spaces in there.