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

runsun runsun at gmail.com
Mon Oct 31 01:28:04 EDT 2016


Thx guys for the help. I tried out the examples in the WIP and you guys
provided. These are all very powerful additions. The for-else example in the
WIP was very confusing to me at first, until I tried the example Ronaldo
gave. 

I think an easy way of explanation would be that a "cond?a:b" format handles
AND RETURN every single item, but "if" or "if-else" allows users to discard
some. With this in mind, the example in WIP,

> echo([ for (a = [0 : 3]) if (a < 2) ( if (a < 1) ["+", a] ) else ["-", a]
> ]);
> // ECHO: [["+", 0], ["-", 2], ["-", 3]]

can be read as: 
>>> when a<2: discard those a>=1, and handle the rest as ["+",a]
>>> when a>=2: ["-",a]

Emphasizing the "discard" part helps me understand it better. 

In my opinion, this would be the same as if we allow an "if" existing in the
"cond?a:b" format;


> a<2? 
*
> ( if (a < 1) ["+", a] ) 
*
> : ["-", a]

Or, for Ronado's example:


> a %2==0? a: 
*
> if (a!=1) a*10
*

I'd like this form better, because it sort of focusing the feature of "if"
as a filter that discards something, but not "sometimes it discards,
sometimes it picks it back up when else is added". 

But, at least it's there when we need it. Thx to those who puts them up.
Great additions.




-----

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




More information about the Discuss mailing list