[OpenSCAD] Can I get some code review up in here?

runsun runsun at gmail.com
Mon Apr 13 17:20:44 EDT 2015


Many thx, Andrew. Embarrassingly, I didn't even know there's a search(). Only
knew about lookup.With search(), the hash() function becomes ridiculously
simple:
function hash(h,k, notfound=undef)= (    let( rtn= search([k],h) )   
len(rtn)>0? h[rtn[0]+1]: notfound    );opt = ["Height", 7, "Thickness", 5,
"PinDiameter", 2];echo( hash(opt,"Height") ); // 7echo(
hash(opt,"Thickness") ); //5echo( hash(opt,"New") ); // undef ==> This also
generates a warning.I notice that there's a little "hiccup" (for me) when
using search()://Search a str in a string: search( "b","abcd" ) //==>
[1]//Search a str in a list: search( "b",["a","b","c"] ) //==> error //
Search a str in a list:  NOTE: argument one has to be a listsearch(
["b"],["a","b","c"] ) //==> [1]   //Search a string in a list of str:
search("b", [ ["a",10], ["b",11],["c",12] ] ) ) //==> [1]
But, it's not a big issue. It seems that search() is a great tool and there
are lots more to dig into.



-----

$  Runsun Pan, PhD 

$ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse  ) 

$ -- hash parameter model: here , here 

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly 




--
View this message in context: http://forum.openscad.org/Can-I-get-some-code-review-up-in-here-tp12341p12358.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20150413/eafd2e67/attachment-0002.html>


More information about the Discuss mailing list