Plaster

text
(defun len (lst) (if (null lst) 0 (+ (len (cdr lst)) 1))) ;<< len returns (cdr lst) where 1 comes from to be added to 1 and where the result of + is being saved between iterations? (len '(a b c)) CL-USER 6 > (trace len) (LEN) ;; It would be good of you if you would explane how to read trace's output ;; or may be there is a more verbose output CL-USER 7 > (len '(a b c)) 0 LEN > ... >> LST : (A B C) 1 LEN > ... >> LST : (B C) 2 LEN > ... >> LST : (C) 3 LEN > ... >> LST : NIL 3 LEN < ... << VALUE-0 : 0 2 LEN < ... << VALUE-0 : 1 1 LEN < ... << VALUE-0 : 2 0 LEN < ... << VALUE-0 : 3 3

Annotations