26 lines
457 B
Common Lisp
26 lines
457 B
Common Lisp
;; vi:ft=lisp:sw=2:ts=2
|
|
|
|
(defun replace-argument (x) (let (x 1) x))
|
|
|
|
(defun replace-let ()
|
|
(let (x 1)
|
|
(setq x 2) ;; mutate local x
|
|
x
|
|
)
|
|
)
|
|
|
|
(defun reassignment-in-a-loop (iterations)
|
|
(let (x 0 y 1)
|
|
(while (< x iterations)
|
|
(setq y (* y 2))
|
|
(setq x (+ x 1))
|
|
)
|
|
y
|
|
)
|
|
)
|
|
|
|
(assert (= (replace-argument 2) 1))
|
|
(assert (= (replace-argument 3) 1))
|
|
(assert (= (replace-let) 2))
|
|
(assert (= (reassignment-in-a-loop 4) 16))
|