development version newLISP 8.8.6

Notices and updates
Locked
Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

development version newLISP 8.8.6

Post by Lutz »

• optional break condition in 'for, 'dolist' and 'dotimes'
• new 'letex' combines let and macro expansion
• bug fixes and doc additions/changes

files and change notes: http://newlisp.org/downloads/development/

Lutz

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Post by rickyboy »

I was looking at the manual for the 'letex' documentation. It says:

"The last example shows how 'letex' can be combined with 'define-macro' to do variable expansion of macro variables into an expression to be evaluated:

Code: Select all

(define-macro (dolist-while)
   (letex (var ((args) 0 0)
           lst ((args) 0 1) 
           cnd ((args) 0 2) 
           body ((args) -1))
       (catch (dolist (var lst)
           (if (set 'res cnd) body (throw res) )))))

> (dolist-while (x '(a b c d e f) (!= x 'd)) (println x))
a
b
c
nil
'dolist-while' loops through a list while the condition is true."

But, it will not work for a 'body' with more than one form:

Code: Select all

> (dolist-while (x '(a b c d e f) (!= x 'd)) (print "x=") (println x))
a
b
c
nil
This one seems to work for multi-form 'body's.

Code: Select all

(define-macro (dolist-while)
  (letex (var ((args) 0 0)
          lst ((args) 0 1) 
          cnd ((args) 0 2) 
          body (cons 'begin (1 (args))))
    (let (res)
      (catch (dolist (var lst)
               (if (set 'res cnd) body (throw res)))))))

> (dolist-while (x '(a b c d e f) (!= x 'd)) (print "x=") (println x))
x=a
x=b
x=c
nil
Thank you, Lutz, for providing this functionality. --Ricky
(λx. x x) (λx. x x)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Thanks Rick for catching this, it will be corrected in the manual.

Lutz

ps: BTW 'letex' will do expansion on multiple expression bodies

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Yesssssss ..Thanks Lutz!!
you added some very nice extras in the last 2 releases!! great..
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

... and more to come, try newLISP's new syntax highlighting service here:

http://newlisp.org/code/highlight.html

you can try it with Pjot's url: http://www.turtle.dds.nl/newlisp/speaker.lsp

Lutz

ps: read more about it here: http://newlisp.org/index.cgi?page=News

Locked