Executing the following code, straight from the Quicksort entry into the
manual
unsorted = [for (a = rands(0, 10, 6, 3)) ceil(a)];
echo(unsorted); // ECHO: [6, 1, 8, 9, 3, 2]
echo(quicksort(unsorted)); // ECHO: [1, 2, 3, 6, 8, 9]
results in the following message:
WARNING: Ignoring unknown function 'quicksort'.
Any explanation?
My operating system: Kubuntu 14.4
OpenSCAD version: 2015.03-1
--
View this message in context: http://forum.openscad.org/Quicksort-tp14501.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
You forgot to include the quicksort function. quicksort is not built-in
-Marius
--
View this message in context: http://forum.openscad.org/Quicksort-tp14501p14530.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
kintel wrote
You forgot to include the quicksort function. quicksort is not built-in
Which is why I removed quicksort() and select() from my version of
the manual.
quicksort(), select(), strselect(), multelems(), divelems(), range2vector()
should be put into a stdlib.scad and bundled with MACD
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Libraries#MCAD
And some (if not all) of MCAD should be made "officially supported". That
way,
quicksort() etc can be put back into the manual in a new chapter called
"Standard Libraries". Or better yet, mix the library function and modules
with the built-in ones in the library and simply label clearly which library
need to be use<>'ed.
This is similar to most C books treat fprintf() as part of the language but
it's really a library call.
And btw, MCAD needs a maintenance / purging. Some of the code in there
are seriously out of date.
--
View this message in context: http://forum.openscad.org/Quicksort-tp14501p14532.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
And btw, MCAD needs a maintenance / purging. Some of the code in there
are seriously out of date.
hyperair has been doing some work on updating MCAD, see https://github.com/openscad/MCAD/tree/dev
Creating a cleaner standard library would be nice. It’s significant amounts of work though, and if we want to maintain backwards compatibility it needs some careful design.
-Marius
Von: ctchin c.t.chin@szu.edu.cn
You forgot to include the quicksort function. quicksort is not built-in
Which is why I removed quicksort() and select() from my version of
the manual.
Why's that? The code implementing the quicksort() is the actual
example to show how to use list comprehensions.
And some (if not all) of MCAD should be made "officially supported".
That way, quicksort() etc can be put back into the manual in a new
chapter called "Standard Libraries". Or better yet, mix the library
function and modules with the built-in ones in the library and simply
label clearly which library need to be use<>'ed.
That would be nice. MCAD is basically just a random collection of
very useful scripts. It was unmaintained for quite some time. Lately
hyperair started the huge task to sort all the stuff and produce a
useful general API. Even with just the existing code, that's going
to need some time.
I'm still meaning to help with documenting the existing stuff, but
so far there's no free time to work on that and the list of topic
in OpenSCAD itself is also quite long.
Just to be clear: This is simply to explain why things are slow
sometimes and why some very useful feature requests may need lots
of time to get realized. There's a huge amount of good ideas coming
in, both in the github issue tracker and here, and that's great.
It's just not possible to implement all that anytime soonish with
the existing development ressources.
It's very cool to see the current work on the manual, so thanks
to everybody working on that. I know how much work it is.
And btw, MCAD needs a maintenance / purging. Some of the code in there
are seriously out of date.
The purging part is not so easy. Just removing stuff will break
existing models. It might be an option to deprecate some of the
old modules though.
For my designs I've switched to the dev branch of MCAD which has
the new "mcad_*()" interface and the scripts sorted into various
topic folder. I did not use much yet, but it works nice so far.
ciao,
Torsten.
tp3 wrote
Why's that? The code implementing the quicksort() is the actual
example to show how to use list comprehensions.
And a fantastic example at at, and yes the doc text did mention how to
use the code. But the way it's given it's own Section
title "14.3.3 Quicksort" is misleading fine folks like wolf into making the
mistake he made. As a very experienced programmer myself, I made
the same mistakes (briefly) with both quicksort() and select().
Whereas other examples (e.g. "14.3.1 Generate polygon points" and
"14.3.2 Flatten a nested list") are perfectly clear functions x(a), y(a)
and flatten(l) are not built-in functions.
This can be (should be) fixed easily by simply renaming the section
heading to something like "Sorting a vector with Quicksort" and
eliminating the input and output parameters text.
select() is even worse: in the TOC for
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language
it is listed side-by-side with concat() and len() under "3.5.1 vector
operators"
Or as I said, just move these excellent examples to a supported library
and elevate them in the doc to equivalent of built-in
functions/statements.
tp3 wrote
That would be nice. MCAD is basically just a random collection of
very useful scripts. It was unmaintained for quite some time.
That is perfect fine reason to expunge a lot of it. I firmly believe if no
one (in the user community) care enough to do something about it,
why should the developer maintain it?
tp3 wrote
I'm still meaning to help with documenting the existing stuff, but
so far there's no free time to work on that and the list of topic
in OpenSCAD itself is also quite long.
Being still almost-a-n00b myself, I can tell you are one of the more
important staff members. Your precious time should not be spent
on supporting libraries or writing docs or answering n00b questions.
Leave those easier but time-sinking tasks to lesser folks like myself.
tp3 wrote
The purging part is not so easy. Just removing stuff will break
existing models.
A really lousy excuse to keep bundling unsupported, undocumented
and unmaintained code/library in the installation package.
I'm advocating that bundled code should be supported and
documented or not bundled at all. If purging some old codes break
someone's design, that guy (or lady) should step up and volunteer his
or her time to support that module or function.
It's not like those old code will be lost. The MCAD github can be left in
place, it will simply be unbundled from the installation package and
removed from the doc. A new standard library(ies) will be created,
copying the best stuffs from MCAD, and only keeping those that secure
a pledge of support/maintenance from a community member.
Core developers should not bother with such trifle matters, I volunteer
myself in this effort.
--
View this message in context: http://forum.openscad.org/Quicksort-tp14501p14536.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
ctchin wrote
This can be (should be) fixed easily by simply renaming the section
heading to something like "Sorting a vector with Quicksort" and
eliminating the input and output parameters text.
Which I will carry out, btw... I am not doing it yet simply to allow
time for my argument to get across.
--
View this message in context: http://forum.openscad.org/Quicksort-tp14501p14537.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Ahh, beware the long text... no idea how that happened :-)...
Von: ctchin c.t.chin@szu.edu.cn
And a fantastic example at at, and yes the doc text did mention how to
use the code. But the way it's given it's own Section
title "14.3.3 Quicksort" is misleading fine folks like wolf into making the
mistake he made. As a very experienced programmer myself, I made
the same mistakes (briefly) with both quicksort() and select().
Right, changing the chapter title is a good idea (I'm not
claiming the list comprehension docs are anywhere near perfect,
I basically collected some of the cool examples from the forum
and created that overview page).
This can be (should be) fixed easily by simply renaming the section
heading to something like "Sorting a vector with Quicksort" and
eliminating the input and output parameters text.
I'm not so sure about the second part. Why remove that? The example
is supposed to be pasted into the editor and should give some result
and allow toying with it.
Without the actual calls, it will do nothing when just copy&pasted
which might be confusing. At least that happens to me sometimes when
trying some code send by other people.
(Or am I misunderstanding the changes you suggest?)
Or as I said, just move these excellent examples to a supported
library and elevate them in the doc to equivalent of built-in
functions/statements.
There's still a need for explaining how the list comprehension
works. That the example happens to be a generally useful function
which would be nice to have in some kind of standard library does
not make the example unnecessary. We maybe can just have both?
I'm advocating that bundled code should be supported and
documented or not bundled at all. If purging some old codes break
someone's design, that guy (or lady) should step up and volunteer his
or her time to support that module or function.
Oh, I'd agree to that. I do suspect MCAD was maintained at the
time it was included. Also I'm not against removing stuff, but
there should be a fair amount of time where things are deprecated
and give a warning.
Additionally there's a number of cases where warnings will not
show up, e.g. in the Thingiverse Customizer which does allow
MCAD usage.
It's not like those old code will be lost. The MCAD github can be left in
place, it will simply be unbundled from the installation package and
removed from the doc. A new standard library(ies) will be created,
copying the best stuffs from MCAD, and only keeping those that secure
a pledge of support/maintenance from a community member.
Yes, that would be another option. That would probably also
help defining what's needed to better support libraries in
OpenSCAD. Right now it's a big issue when using multiple
libraries as there's no means to separate those except using
some naming conventions. That a big topic in itself though.
Core developers should not bother with such trifle matters, I
volunteer myself in this effort.
If you can spare some time, that's awesome, I did not read though all
the wiki changes yet, but what I saw so far looks very helpful. I do
value that all people involved care for things like documentation,
making installations work and so on. I think that's one of the major
reasons why OpenSCAD has a sizable community even with all it's
current limitations.
ciao,
Torsten.
tp3 wrote
(Or am I misunderstanding the changes you suggest?)
Rather than explain it, I just did it. If anyone find it unsatisfactory,
undo or refine it.
Note I tweaked a couple of the examples. For further discussion, I think we
have abused this Quicksort thread enough... I'm continuing in my docs
thread.
--
View this message in context: http://forum.openscad.org/Quicksort-tp14501p14592.html
Sent from the OpenSCAD mailing list archive at Nabble.com.