[OpenSCAD] Digging into search( )

MichaelAtOz oz.at.michael at gmail.com
Mon Apr 20 02:48:18 EDT 2015

runsun wrote
> clothbot wrote
>> Example 3:
>> 	table3 =[
>> [“caterpillar”,3],[“cat”,2],[“dog”,2],[“cattle”,5],[“cod”,42]];
>> 	search(“cat”, table3);
>> 		[1]
>> 	search(2,table3,1);
>> 		[1,2]
>> 	search(“bird",table3);
>> 		undef
> Also note that using a flat list like above is error-prone:
>    table4 = [ “abc","def","def",3 ];
>    search( “def”,table4 )= want:[2] got:[1]

Why do you expect [2]?
[1] is the "d" of match_value "def" match to the first "def"
wiki: num_returns_per_match (default: 1)
So it only returns 1 match.

Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”   Fight it! http://www.ourfairdeal.org/
View this message in context: http://forum.openscad.org/Digging-into-search-tp12421p12440.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

More information about the Discuss mailing list