Before you can advance, first take a step back...
Readable
working long form code you can understand is preferable to confusing
non-working short form code you do not understand. While true lispers find my code below abhorrent, true lispers also find the idea of using newLISP itself abhorrent! (Note: The best way to deal with "true lispers" is to ask why they haven't advanced to using Haskell ;o)
Below is the verbose (and mentally easiest) way to think about processing a list of items. Commit this expanded code form to memory. Later, you can then visualize in your mind how the more complex and or shorter forms should be functioning with your list.
I like this as my standard list processing code layout, as I can easily add debugging statements where needed.
Also I substituted length for find-all's regex to simplify the code. (Use on UTF-8 strings might be problematic.)
Code: Select all
#/usr/local/bin/newlisp
(set 'vowels '("a" "ee" "iii" "oooo" "uuuuu"))
(dolist (item vowels)
(if (>= (length item) 4) ; comparison test each item
(begin ; when test is true for item
; put multiple statements here
(println $idx ": " item)
)
(begin ; when test is false for item (actually nil in newLISP)
; put multiple statements here
(println $idx ": ---")
)
)
)
(exit)
And if I haven't totally messed it up in simplifying it, this code should work ;o)
-- xytroxon
Note: I like to use the wscite editor which nicely highlights matching beginning ( and ending ) Ctrl-E then can be used to jump back and forth between the ( ) 's in complex nested ((()()))'s.
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976