Example #1:
Code: Select all
(setq l '((a 1) (b 2)))
(let l (+ a b)) ;; ERR: invalid let parameter list in function let : l
Code: Select all
(let ((a 1) (b 2)) (+ a b)) ;; get 3 as expected
Code: Select all
(setq l '((a 1) (b 2)))
(let l (+ a b)) ;; ERR: invalid let parameter list in function let : l
Code: Select all
(let ((a 1) (b 2)) (+ a b)) ;; get 3 as expected
Code: Select all
(setq a 1 b 2)
(let (l (+ a b)) (println l))
;-> 3
(let (a 4 b 5 l (+ a b)) (println a { } b { } l))
;-> 4 5 3
; l = 3 because in the expression (+ a b), a = 1 and b = 2.
Code: Select all
(letn (a 4 b 5 l (+ a b)) (println a { } b { } l))
;-> 4 5 9
; Now l = 9 because inside the letn expression a = 4 and b = 5.
Code: Select all
(letex (l l) (let l (+ a b)))
Code: Select all
(define-macro (lett)
(if (list? (args 0)) (apply let (args))
(apply let (cons (eval (pop (args))) (args))) ))
Code: Select all
(lett l (+ a b))