list issue: report index if value is 1

Apr 20, 2010 at 7:42am

list issue: report index if value is 1

I need to report the index numbers of an incoming list if the value is 1.

f.e. if the list looks like this:

0 1 1 0 1

the result should be like this:

2 3 5

Hope this makes senses!

Thanks.

#49873
Apr 20, 2010 at 8:15am

Hi,

here is one of many ways :

– Pasted Max Patch, click to expand. –
#179115
Apr 20, 2010 at 8:27am

Using [zl sub] is probably the quickest way.

lh

– Pasted Max Patch, click to expand. –
#179116
Apr 20, 2010 at 8:36am

Lsearch from the Lobjects collection does this, other than it treating lists as 0 based, which means that it would return 1 2 4. Slap an Ladd after the Lsearch for your one-based desired result.

– Pasted Max Patch, click to expand. –
#179117

You must be logged in to reply to this topic.