Tortelvis.



What the Heck is Tortelvis?

Tortelvis is agile 130 kg strong Elvis impersonator singer of Dread Zeppelin,
the band that plays Led Zeppelin covers in a reggae style. Definitely
fascinating. But, sometimes, you do not want the copy, you want the real thing.
Look here:
> (set 'L (list 1 2 3))
(1 2 3)
> (set 'push-right (lambda(a b)(push a b -1)))
(lambda (a b) (push a b -1))
> (push-right 4 L)
(1 2 3 4)
> L
(1 2 3)

Did you expected (1 2 3 4)? Well, Newlisp is sometimes too functional. This
time it passed copy of L to the push-right. OK, we'll fix it now.

> (set 'push-right (lambda-macro(a b)(eval (expand '(push a b -1) 'a 'b))))
(lambda-macro (a b) (eval (expand '(push a b -1) 'a 'b)))
> (push-right 5 L)
(1 2 3 5)
> L
(1 2 3 5)











---

3 comments:

  1. Is it not easier this way:

    (set 'push-right (lambda-macro (a b) (push (eval a) (eval b) -1 )))

    and safer:

    (define (push-right a b) (push a b -1))
    (set 'L:L '(1 2 3)
    (push 4 L)
    L:L -> '(1 2 3 4)

    ReplyDelete
  2. correction:

    (push-right 4 L)
    L:L -> '(1 2 3 4)

    ReplyDelete
  3. Let me see, yes, you're right - the first is easier and the second is safer.

    ReplyDelete