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

runsun runsun at gmail.com
Mon Oct 31 16:03:34 EDT 2016

```Ronaldo wrote
>
> runsun wrote
>> So a legitimate question is: why not just allow the filter
*
>> (if(B) yyy)
*
>>  in a "cond?~:~" ?

My message was to explain that your trivial example is illogical. How could
anyone invent an illogical usage of an idea in order to argue against that
idea ?

> That is exactly what is happening when you write something like:
>> [for (a=A) a % 2 == 0 ? a: if (a!=1) a*10 ]
> the filter
/
> if
/
>
*
> is deciding "the fate of the conditional before it"
*
> .

No! it is to decide the fate of the variable AFTER it ... when the condition
"a%2==0" is met, the previous variable of if's, a, is then decided without
invoking the if-filter. So it's not decided by the "if-filter". The 'if'
filter comes into play only when "a%2==0" is not met. Under that condition,
the 'if' filter is to decide the variable/code AFTER it, just like anywhere
'if' is used in this and other languages.

> In fact, the conditional expression above would not act as an expression
> but as a filter. And that is confusing!

No, the condition expression (the ?:) is not a filter. The "if (a!=1) a*10"
is, working only when condition "a % 2 == 0" is not met.

Re-write it to the currently accepted form:

[ for (a=A) if(a % 2 == 0 ) a else if (a!=1) a*10 ]

Now you have two if's, the 2nd one is a filter but the 1st is not. That's
where the confusion comes.

> I agree that is inappropriate to call the construct if-else a filter and
> that it is just a conditional that accepts filtering. But it is not
> equivalent to ?: because it is not an expression either.

Yes, *"if-else" is a conditional that accepts filtering* is the best way to
describe it. Better if added: *"if" w/o "else" serves as a filter*.

But, other than the filtering, show me an example that can only be expressed
by "if-else" but not "?:".

I don't think you could, because they serve the exact same role (other than
the filtering).

-----

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

```