[OpenSCAD] Any where to find the doc for lc-each, lc-else and lc-for-c ?

runsun runsun at gmail.com
Mon Oct 31 12:22:00 EDT 2016


Ronaldo wrote
> We are discussing two different matters: the benefits of the if-else
> filter in list comprehension and your alternative sintax of it. 

I'd strongly suggest not to categorize "if-else" construct as a "filter". A
filter means pick something and discard the rest based on a condition. With
the "if-else", nothing can be discarded (just like cond?a:b), so it
shouldn't be considered a filter. Treating it a filter only add more
confusion 'cos it's the role "if" (w/o else) plays.  


> The first point of my last message was about the benefits. So, your
> recoding above mix the two things and did not help. 

Sorry I don't get this part.


> The second issue (your alternative to if-else filter) has it own
> drawbacks. With my trivial example:
>> [ for(a=A) a+(if (a==0) 1) ] 
> I meant: 
>> [ for(a=A) if (a==0) a+1 ] 
> which is a filter

Re-arranging "if(a==0) a+1" to "a+(if (a==0)1)" and suggesting they are the
same doesn't make any sense at all. If "a" is subject to the conditional
pick/drop, why would it be placed BEFORE if ? I couldn't ever imagine an
"if" can simultaneously decide the fate of the code before it (a) and after
it (1). That is a mess-up of scopes and only makes it more confusing.

If you ask "why not 'if' shows up here / there if it is allowed in
cond?if(...):if(...)", then with the same logic, since "if" shows up in 

> [ for (...) if(...) ]

why not it is allowed in in 
> [ for(...) cond?if(...):if(...) ]

 
? 
To me that's simply a choice of language design. 



-----

$  Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 );   $ tips: hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2, 3 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg , tests ( 2 ); $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf ) 
--
View this message in context: http://forum.openscad.org/Any-where-to-find-the-doc-for-lc-each-lc-else-and-lc-for-c-tp18823p18844.html
Sent from the OpenSCAD mailing list archive at Nabble.com.




More information about the Discuss mailing list