How to check if value is identical to at least one value in a list?

Hello! I am trying to make a program, and one thing which I need to do is to compare if a value is identical to a set of predefined values. Below was my first instinct:

Obviously, the input isn’t being compared to x, y, or z (as I would like it to), but rather, the list itself and its contents. I suppose I could just use a lot of ()or() blocks:

But that seems very messy and the same thing being written over and over bugs me. Is there a better way to implement this? Thanks!

You can make use of the for each (item) in (list) to do this:


(You can drag the script directly into the Snap! editor)

btw, you don’t have to say if <>{ report <<true>> }else{ report <<False>> , just say report<condition.

the problem is, this solution is way slower than the tedious way.


The ANY block is what you get if you drop the MAP over the arrowheads of the OR block.

P.S. You never need to say


because that’s exactly equivalent to
untitled script pic (10)

I would do it like this

This makes sure that it doesn’t do unnecessary, as it returns as soon as it finds an identical item.

<(list [x][y][z]@delInput@addInput)contains (input)>

That doesn’t meet what the OP was asking. They want to do identical checks, meaning lowercase a does not equal uppercase A. The contains block doesn’t care about cases, so it will say that a = A. There’s more to the identical check though, as it’s not just doing case sensitive checks, so you can’t just turn on case sensitivity.

oh, i guess i misunderstood the post.

Thanks for the help. I think that @bh’s solution makes the most sense, but, funnily enough, @theaysnap’s solution with the ()contains() block is the most logical for me as I actually do want it to be case-insensitive (though I did not mention that in the post). If anyone was wondering, I was trying to make a script that detects whether the first letter of a word is a vowel and making the word before it a ‘a’ or an ‘an’, depending on the output (I am aware it will be occasionally incorrect, like for the word “user”, which should be ‘a’ but will be ‘an’ in my program).

why use the is identical block rather than =?

Oh… Thought ()=() only worked for numbers… -_-

because the input to < []=[] @<:> is a square, it accepts all data types.

I thought you meant is a square like 1, 4, 9, 16, … :~) That input shape is a rectangle.

oh… yeah…

Interestingly, it is also the same with <[] < [] @<:> > and <[] > [] @<:> >. This feature is derived from Scratch.

Most programming languages allow you to compare strings and other data types, so it wasn’t derived from scratch, it was derived from every other programming language.