This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
(define (TREE-label tree) (tree 1))
(define (TREE-left tree) (tree 2))
(define (TREE-right tree) (tree 3))
(define (set-TREE-label tree value)
(nth-set (tree 1) value))
(set 'my-tree (make-depth-3-binary-tree))
(set-TREE-label (find-subtree my-tree 3) 2000)
(println "3: " (find-subtree my-tree 3))
(println "2000: " (find-subtree my-tree 2000))
3: nil
2000: (labeled-binary-tree 2000 () ())
(set-TREE-label (find-subtree tree 5) 2000)
(set 'my-tree (make-depth-3-binary-tree))
(println (find-subtree my-tree 3))
My second contribution is (although still in progress)Quote from: "newdep"
(load "http://www.nodep.nl/downloads/newlisp/nlist.lsp"> ")//http://www.nodep.nl/downloads/newlisp/nlist.lsp
$ newlisp http://www.nodep.nl/downloads/newlisp/worm.lsp
Oops! Wrong! It'sQuote from: "Cyril"O(n)! Very, very evil typo. Sorry, folks. And nobody have corrected me. :-(
However, none of the newLISP users from this forum are into IRC, so the channel has been quiet for most of the year.Quote from: "cormullion"
But if you like talking to yourself, it's kind of fun... :)Quote
For 'last' the optimization was never done, but is trivial to add for 9.2.9.Quote from: "Lutz"
(data-type (tree data children))
(tree 0 ((tree 1 ()) (tree 2 ())))
(set 'points '())
(dotimes (i 5)
(push (point i i) points)
)
(println (point:move '(points 0) 200 200))
(set 'points '())
(dotimes (i 5)
(push (point i i) points)
)
(set 'tmp (points 0))
(println (point:move 'tmp 200 200))
(nth-set (points 0) tmp)
(define-macro (data-type)
(let (ctx (context (args 0 0)))
(set (default ctx) (expand '(fn () (cons ctx (args))) 'ctx))
(dolist (item (rest (args 0)))
(set 'idx (+ $idx 1)
(sym item ctx)
(expand '(lambda (_str _val)
(if (set '_val (eval _val))
(nth-set ((eval _str) idx) _val)
((eval _str) idx)
)
)
'idx
)
)
)
ctx
)
)
(point:x 'pt 5)
(define (point:move _pt _x _y)
(point:x _pt _x)
(point:y _pt _y)
(eval _pt)
)
(point:move 'pt 8 7)
(:x pt)
(:x pt 2)
(define-macro (data-type)
(let (ctx (context (args 0 0)))
(set (default ctx) (expand '(fn () (cons ctx (args))) 'ctx))
(dolist (item (rest (args 0)))
(set 'idx (+ $idx 1)
(sym item ctx)
(expand '(lambda-macro (_str _val)
(if (set '_val (eval _val))
(nth-set ((eval _str) idx) _val)
((eval _str) idx)
)
)
'idx
)
)
)
ctx
)
)
(define-macro (point:move _pt _x _y)
(:x _pt _x)
(:y _pt _y)
)
; this doesn't work either
(define-macro (point:move _pt _x _y)
(point:x _pt _x)
(point:y _pt _y)
)
; if I try this:
(define-macro (point:move _pt _x _y)
(println (point:x _pt))
)
; I get this error:
invalid function : ((eval MAIN:_str) 1)