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

runsun runsun at gmail.com
Mon Oct 31 10:32:00 EDT 2016


Ronaldo wrote
> The following list comprehension filter in the new sintax:
>> if ( A ) (  if( B ) x  else if (C) y ) else  z 
> could be expressed in the old one by:
>>  if ( B || C )  !A ? z :  B ? x :  y 
> which is rather cryptic and hard to write. 
> 
> Besides, if we change the first code eliminating the 'else z' part, the
> standard code will change to: 
>> if ( A )  if(B || C)  B ? x: y
> which is far from an obvious change.

I think you made it too complicated. It should be expressed as follows
instead :

> A? (B?x:
*
> if(C)y
*
> ) : z

which, in my opinion, is a lot easier to both read and write than the 3
forms you presented.

Note that I highlight the *if(C)y* part to emphasize that "*an if w/o else
is a filter*", and "*an if with an else is the same as cond?A:B*".


runsun wrote
>> a %2==0? a: 
*
>> if (a!=1) a*10
*
> 
> why not in other expressions too?
>> [ for(a=A) a+(if (a==0) 1) ]

Because it can be easily achieved with current stable release:

> [ for(a=A) a==0? a+1:a ]





-----

$  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-tp18823p18840.html
Sent from the OpenSCAD mailing list archive at Nabble.com.




More information about the Discuss mailing list