Simple List parsing question

John Daniel's icon

Hello All!
arrgh, stoopid bumfuzzlin roadblock

Am trying to parse a list of integers and query whether X exists anywhere inside of a list
The lists look like ( 1 2 6 9 3 12 14 ) - the order of the numbers in the list change often, as does the total number of items in the list

I want to simply check the list for "does (5) exist anywhere in this list at all?" and get a bang if the test is positive.

what is the trick? Am sure it must be easy...
thanks!
jd

Christopher Dobrian's icon

I think [zl sub] is what you want. Check to see if the result is nonzero with [!= 0] (and use a [change] object after that if you want to filter out repetitions).

Max Patch
Copy patch and select New From Clipboard in Max.

Or... here's an old abstraction I have lying around from before the existence of the [zl] object, updated to look decent in Max 5+. It gathers ints and stores them, then you can test to see if a given int is currently in storage. (Kind of the reverse of [zl sub], in which you provide an item or group of items, then send a list to see if it contains that.)

John Daniel's icon

Thx Christopher, I have been digging thru the zl objects but had not been able to figure that. will try your abstraction tonight.

thanks!!!!
jd

metamax's icon

I thought of [match] but [zl.sub] is better. Not sure you need more than a couple of objects though.

Max Patch
Copy patch and select New From Clipboard in Max.

John Daniel's icon

yay!
got it using zl.sub. Thank you for the direction guys!

match is very interesting too.
Is such good learning to dig thru the different approaches people take to solve a problem.