Hi Tomaaz,
Well, that is a naughty thing to do, challenging BASIC with a construct which is the very essence of some other programming language
. As you know, Lisp, or LISt Processing, was designed to process lists. No wonder that a list can be processed in such an elegant way in newLisp. List processing is of course not the strongest skill of a BASIC language.
And I understand your reaction, it actually made me laugh
Still, I keep using my converter, but this is with a reason. After I had used ScriptBasic for a while, I discovered newLisp and I started to program it fanatically (see some programs
here). I used to be
very good at it, if you don't mind me saying. If you look into the archives of the newLisp forums, you'll see a lot of my posts. I also posted a lot of issues and bugs in the language (for example
here). I liked the language so much that I actually met the newLisp creator Lutz Mueller in person.
However, I did leave newLisp, for a couple of reasons, even though newLisp can process a list very good as well as it can do some other things very good. Your code snippet looks nice and small, but there are other aspects to newLisp which, at a certain point in time, can be a disadvantage. To name a few:
- newLisp is an interpreter and therefore inevitably slow, even though it relies on precompiled libc functions heavily
- newLisp is an interpreter and therefore always allows a 3rd party to peek into a program's source code, one way or another
- newLisp is an interpreter and therefore always requires an interpreter binary to create a 'standalone' executable
- at the time, newLisp releases kept changing the API, which is very tiring for end users who have to keep changing their programs to stay up to date
- at the time, newLisp releases kept popping up bugs in lots of unexpected ways, and because the internal design structure of the implementation was kind of hard to grasp these bugs could be very confusing
- GPL license not liberal enough for certain purposes
- newLisp is the project of someone else and a newLisp programmer inevitably depends on the willingness of that person when it comes to bug fixes and proposed new functionality (note that mr. Mueller is a very nice and open developer, but it is about the dependency).
You
mentioned some requirements, but here are mine: I left newLisp because I needed to create genuine binaries optimized for speed, independent from interpreters or other persons, without the option of 3rd parties peeking inside my code, and sought for a compatible (meaning multi-platform Unix oriented) way to do this. I ended up implementing a kind of a C preprocessor, using a syntax loosely based on VIC-20 BASIC and ScriptBasic, because I am a nostalgic person. This is the
Basic Converter project.
Surely, it is not The Best Thing For All Purposes, but it fills my needs. And even though I may have to use a FOR/NEXT and a SORT to accomplish your task, at least I can create a program which performs such task very fast, independent from interpreters and libraries and other persons, in a readable manner, producing a binary which cannot be peeked into, executable on all POSIX platforms, even on my Android phone. Which you cannot say about newLisp (nor ScriptBasic)
This would be a solution in BaCon:
SPLIT UNIQ$("120 135 345 345 1890 12 120 12 135 712 78 120") TO list$ SIZE t
MAP list$ BY VAL TO nr SIZE t
SORT nr SIZE t DOWN
PRINT nr[0], " ", nr[1], " ", nr[2]
Not even a FOR/NEXT required
Best regards,
Peter