Lutz's Ninth
newLISP release 9.0 has been released, and no doubt there will be much loud rejoicing among newLISP users (which you will hear if you listen closely - the web is very noisy). There are new functions, enhancements in others, speed increases, and bug fixes. The documentation gleams in the sunlight, buffed to perfection by a team of Oregonian wordsmiths. Of course, most of us have probably been downloading the development versions, so will already be using some of the new goodies.
A last minute arrival is the ref-all function. This returns a list of every occurrence of an item in a nested list. Now I don't usually carry around big nested lists with me, so when I require one I usually turn to my iTunes library. It's a big XML file, but that doesn't stop us -
(xml-type-tags nil nil nil nil)
(set 'itunes-data
(xml-parse
(read-file "/Users/me/Music/iTunes/iTunes Music Library.xml")
(+ 1 2 4 8 16)))
turning it into a nested list. Now we'll see if I've got any classical music in there:
(map
(fn (i) (println (last (first (rest (member '(key "Name")
(itunes-data (chop (chop i)))))))))
(ref-all "Classical" itunes-data))
OK, this isn't the most elegant code you've ever seen ('chop chop' ‽ 'last-first-rest-member' ‽), but the key point is that ref-all is giving me the address of every reference to the word "Classical" in my iTunes library. I don't have to hack my way through the XML undergrowth. Output is a list of evocative titles:
...
Toccatina Op. 36
Symphony No. 2: Movement I
Symphony No. 2: Movement II
Symphony No. 2: Movement III
Interlude [Orphee - Act II, Scene 5]
Concerto for Saxophone Quartet and Orchestra: Movement I
Concerto for Saxophone Quartet and Orchestra: Movement II
Concerto for Saxophone Quartet and Orchestra: Movement III
Concerto for Saxophone Quartet and Orchestra: Movement IV
Koyaanisqatsi
Organic
Cloudscape
Resource
Vessels
Pruit Igoe
The Grid
...
But ref-all's economy tempted me into trying to write a one-line RSS headline newsreader, a reprehensible practice that I hope won't encourage the playing of newLISP golf. In fact I could only get it down to three lines:
(xml-type-tags nil nil nil nil)
(set 'sxml-data (xml-parse (get-url {http://www.alh.net/newlisp/phpbb/rss.php}) (+ 1 2 4 8 16)))
(map (fn (i) (println (last (sxml-data (chop i))))) (ref-all 'title sxml-data))
newLISP Fan Club
newLISP newS :: RE: newLISP v.9.0 release
newLISP newS :: RE: newLISP v.9.0 release
newLISP newS :: RE: newLISP v.9.0 release
newLISP newS :: newLISP v.9.0 release
newLISP and/or Whatever Else :: RE: Dynamic list values
newLISP and/or Whatever Else :: RE: Dynamic list values
newLISP and/or Whatever Else :: Dynamic list values
newLISP newS :: RE: pre-release newLISP 9.0.0
newLISP newS :: RE: pre-release newLISP 9.0.0
newLISP newS :: RE: pre-release newLISP 9.0.0
newLISP newS :: RE: pre-release newLISP 9.0.0
newLISP for Win :: RE: newlisp.DLL possible?
newLISP newS :: RE: pre-release newLISP 9.0.0
newLISP for *n?x :: RE: Perhaps a dumb question
newLISP newS :: RE: pre-release newLISP 9.0.0
This is not perhaps the best way to say thank you to Lutz for another cool version of newLISP. Here's a better way: thank you!

2 Comments:
Those chop chop's are great! I love the perl-y sound of the chops. Makes me hungry!
Great job on the "introduction" paper. Someday you can turn it into a book.
A wonderful application for ref-all! this would make a nice example for your 'Introduction ...'
Post a Comment
Links to this post:
Create a Link
<< Home