Is lookup function searches for keys which are strings? say
<b> lookup("foo",myArray)? </b>
I get undef back. Is this a bug?
what's the good Strings functions library for OpenScad?
On 5/29/2019 9:33 AM, Serge wrote:
Is lookup function searches for keys which are strings? say
<b> lookup("foo",myArray)? </b>
I get undef back. Is this a bug?
what's the good Strings functions library for OpenScad?
lookup( ) doesn't explicitly say so, but since it interpolates it can't
work on anything but numbers.
You want search( ).
Notes:
table=[ [ "bar", 0 ], [ "foo", 1 ], [ "foo", 1 ], [ "baz", 2 ] ];
echo(search(["baz"], table));
echo(search(["foo"], table));
echo(search(["junk"], table));
ECHO: [3]
ECHO: [1]
ECHO: [[]]
Lookup is for numerical interpolation. You need search for strings,
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Search
On Wed, 29 May 2019 at 17:34, Serge moneyforidea@gmail.com wrote:
Is lookup function searches for keys which are strings? say
<b> lookup("foo",myArray)? </b>
I get undef back. Is this a bug?
what's the good Strings functions library for OpenScad?
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
wait whaaaat?? I'm using search("top", … searching for "top" why it
returns me "type"? who wrote this rap?
On 5/29/19, nop head nop.head@gmail.com wrote:
Lookup is for numerical interpolation. You need search for strings,
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Search
On Wed, 29 May 2019 at 17:34, Serge moneyforidea@gmail.com wrote:
Is lookup function searches for keys which are strings? say
<b> lookup("foo",myArray)? </b>
I get undef back. Is this a bug?
what's the good Strings functions library for OpenScad?
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 5/29/2019 1:39 PM, Serge wrote:
wait whaaaat?? I'm using search("top", … searching for "top" why it
returns me "type"? who wrote this rap?
See the documentation and my note about how if you're searching for a
string you need to make it be an array containing only that string.
When you just say "top" it's interpreted as "search for t, o, or p".
On 5/29/19, nop head nop.head@gmail.com wrote:
Lookup is for numerical interpolation. You need search for strings,
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Search
On Wed, 29 May 2019 at 17:34, Serge moneyforidea@gmail.com wrote:
Is lookup function searches for keys which are strings? say
<b> lookup("foo",myArray)? </b>
I get undef back. Is this a bug?
what's the good Strings functions library for OpenScad?
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org