Hi all, recursion / iteration
First the definition of (nth i L)
(define nth
(lambda (i L)
( if (= i 0) (car L)
(nth (1- i) (cdr L)))))
which is perfectly symptomatic for this Lisp.
Historically imo Scheme was set up as a minimalistic Lisp , also proving that every situation can be solved with recursion - even today there are people promoting/advocating this (I'm not one of them).
the nth in natural language works like (we're going to count 3rd slice .. of a bread
Mr Basic : 1 2 3
Mr Lisp : I take the first slice (car) and then I have the rest of my bread (cdr)
I then take the first slice of the rest of my bread &
then once again - now I have the 3rd slice ....
why this infantility , are they out of their mind doing this
infact not, because Lisp is variadic and typeless
Mr Basic can perfectly find the 4th house in a street very easily , the houses have the same size , he nows the start position and calculates the distance (offset) and he's there.
For Mr Lisp , things can be houses , streets , villages , cars ... there even may be an Aurel between them , he can not calculate the offset , he goes to the first and then there is a pointer to next -- to reach the fourth he has to travel through these 4 pointers.
(reaching the last will take some time but a clever Mr Lisp does (car (reverse environment)) )
However, there is *no* need to follow such a mechanism when numbers are involved -- from there CL has arrays/vectors and they are easily assigned -- the elements are of a same type.
the solutions tried in Scheme are many, while (range i) still generates a list that is mapped (this happens in parallel , yet another problem ) , it also has (in-range i) .. but this sets up a stream (serial thus !!) , because this happens in serial breaking conditions can be composed , it even can do (in-naturals ) , containing all ! the natural numbers in a stream, the list assignments (naturals ) would take till the end of time to generate.
-Compiler technology (the Austin-Kyoto compiler from the late Mr Schelter converts tail recursion in iteration ) -- and certainly the "Glorious Glasgow Haskell Compiler" does same and more.
This mechanism (even if an iterative operator is provided) is very frustating , it makes me write DLL's for CL , and make me ask question as to Mike about a verdict of sensibility of documentation. In the Bigloo I use C-pointers to overcome these problems.
Only Mr Lütz Mueller from NewLisp boldly and bravely introduced
(address obj) --- the real memory address !!!!!!!! GCL si::address gives a local Lisp address
(dup /char i) --- allocates i bytes with the value of /char p.e. /000 for the null character.
but in this Scheme, there is no single spark of any iterative construction I can use , expand ... if there were one, it would give me the feeling as when the sinking Das Boot hitting the bottom of the sea :
" Eine Schaufel Sand, der liebe Gott hat uns eine Schaufel Sand unter den Kiel geschmissen"
I found back my Lisp Book from Springer Verlag -- quoting it : (about Recursion)
"Just because it is possible to push a pea up a mountain with your nose does not mean it is a sensible way"
The English name of the book is : "the art of Lisp programming" -- maybe it is on-line somewhere.
(in the meantime I found next :
http://www.moz.ac.at/sem/lehre/lib/bib/software/cm/Notes_from_the_Metalevel/index.html ... seems very good !! )
(for the music lovers --- who isn't ??)
best Rob
(addendum , just had a look at the forum linked by Aurel, one of his statements is that Lisp is not capable of even being a hobbyist programming language -- therefor I add something written in Lisp in less than 20 ' )
.