I am learning how to use list comprehension in OpenScad. The Oskar demos in
github has been an invaluable source to my studies. But there is some cases
I feel myself constrained. One of that cases is the absence of an else in
the filter if. I imagine that this has been discussed before but I were not
able to find it.
At a first glance, it seems that the conditional expression could be used
instead but the conditional expression is not a filter, it always produces a
value. I already faced cases were an if-else would give a cleaner and more
readable code. Here is an example. Suppose I want to express the following
filter in the context of list comprehension:
if ( A )
if( B )
x
else
if (C) y
else
z
It is possible to express that with only the standard resources of list
comprehension. But with very cryptic code:
if ( B || C )
!A? z :
B? x :
y
It is not easy to understand the last code and it is not easy to arrive to
it. I had to make a table of A, B and C possible values and the outcome to
arrive there.
Besides, if I 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.
The question is: there is a strong reason for the absence of an else clause
of the filter 'if' ?
I am sorry if this had been answered before. A reference would be welcome.
--
View this message in context: http://forum.openscad.org/List-comprehension-filters-tp16069.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
On 02/05/2016 09:37 PM, Ronaldo wrote:
The question is: there is a strong reason for the absence of an else clause
of the filter 'if' ?
It's available as experimental feature in the development snapshots.
(Which means it needs to be enabled in the preferences and there might
be changes to the currently implemented syntax/behavior)
Note that precedence can be specified using ( ), e.g.
echo([ for (a = [0 : 3]) if (a < 2) ( if (a < 1) ["+", a] ) else ["-", a] ]);
ciao,
Torsten.
Thank you, Torsten, for your kind information. It was nice to see that the
constraint is being removed.
However, I was not able to run OpenSCAD-2016.02.01-x86-64-Installer.exe. It
appears 3 times in the process list but nothing happens. And I have no
success trying to kill those process except rebooting.
Ronaldo
2016-02-05 18:47 GMT-02:00 Torsten Paul Torsten.Paul@gmx.de:
On 02/05/2016 09:37 PM, Ronaldo wrote:
The question is: there is a strong reason for the absence of an else
clause
of the filter 'if' ?
It's available as experimental feature in the development snapshots.
(Which means it needs to be enabled in the preferences and there might
be changes to the currently implemented syntax/behavior)
Note that precedence can be specified using ( ), e.g.
echo([ for (a = [0 : 3]) if (a < 2) ( if (a < 1) ["+", a] ) else ["-", a]
]);
ciao,
Torsten.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 02/06/2016 01:44 PM, Ronaldo Persiano wrote:
However, I was not able to run OpenSCAD-2016.02.01-x86-64-Installer.exe.
It appears 3 times in the process list but nothing happens. And I have
no success trying to kill those process except rebooting.
Are you running Avast antivirus 2015 by any chance? This sounds a bit like
the report in:
http://forum.openscad.org/Can-t-install-the-2016-1-26-Windows-snapshot-in-my-64-bit-Windows-7-OS-td15902.html#a15973
FWIW I ran both files though https://www.virustotal.com/
https://www.virustotal.com/en/url/b263dc45a702031cab5351b24b1ae5ef6a384905cd50d9ec6d6a2755693c5a31/analysis/
https://www.virustotal.com/en/url/c1f8afb2ba55d483e3d268ce815ed76782acd93c9ffb60feba660636ffd9b367/analysis/
and https://www.metascan-online.com/
https://www.metascan-online.com/#!/results/file/57114db7b7a0409e8dd4874e18a7ea59/regular
(complains about ZIP file having more than 100 files and refuses to scan that)
You can try the ZIP file meanwhile, in case it's the installer that's
freaking out. Nothing special required, just unzip and run the openscad.exe.
ciao,
Torsten.
On 02/06/2016 01:44 PM, Ronaldo Persiano wrote:
Thank you, Torsten, for your kind information. It was nice to see that the constraint is being removed.
I've created a wiki page to list the experimental features that are not yet ready for the release and therefor also not yet documented in
the main manual.
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/WIP
Disclaimer: I'm not going to promise that will always be up to date or complete ;-).
ciao,
Torsten.
Hello,
The zip doesn't work either. The sole solution is to block Avast from
checking the Openscad dir.
With Avast active the installer hangs itself. If we suspend Avast for some
time and install from the installer it installs OpenSCAD successsfully.
After restarting Avast, openscad.exe hangs. OpenSCAD is not the only
app to hang, ImageMagic for instance has the same behaviour in Windows 7 OS
with the latest updates.
jpmendes
--
View this message in context: http://forum.openscad.org/List-comprehension-filters-tp16069p16077.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
On Feb 6, 2016, at 16:06 PM, jpmendes jpmendes54@gmail.com wrote:
The zip doesn't work either. The sole solution is to block Avast from
checking the Openscad dir.
Could you file a bug report with Avast for this?
Perhaps they will do an analysis and explain why it doesn’t work.
-Marius
I had the same issues JPMendes described. But anyway I couldn't test the
extra features because I couldn't find how to set the preferences of the
snapshot. There is no related option in Edit/Preferences/Advanced.
2016-02-06 13:07 GMT-02:00 Torsten Paul Torsten.Paul@gmx.de:
On 02/06/2016 01:44 PM, Ronaldo Persiano wrote:
However, I was not able to run OpenSCAD-2016.02.01-x86-64-Installer.exe.
It appears 3 times in the process list but nothing happens. And I have
no success trying to kill those process except rebooting.
Are you running Avast antivirus 2015 by any chance? This sounds a bit like
the report in:
FWIW I ran both files though https://www.virustotal.com/
and https://www.metascan-online.com/
https://www.metascan-online.com/#!/results/file/57114db7b7a0409e8dd4874e18a7ea59/regular
(complains about ZIP file having more than 100 files and refuses to scan
that)
You can try the ZIP file meanwhile, in case it's the installer that's
freaking out. Nothing special required, just unzip and run the
openscad.exe.
ciao,
Torsten.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Von: "Ronaldo Persiano" rcmpersiano@gmail.com
I had the same issues JPMendes described. But anyway I couldn't
test the extra features because I couldn't find how to set the
preferences of the snapshot. There is no related option in
Edit/Preferences/Advanced.
Hmm, there should be Features tab in the preferences dialog.
If that's not there, it's an issue with the snapshot build,
I'll have a look...
ciao,
Torsten.
The build script had the snapshot flag missing, new snapshots are
up on the download page (http://www.openscad.org/downloads.html).
ciao,
Torsten.