weird lisp loop type operation

Discussion of Common Lisp
Post Reply
galosi198
Posts: 1
Joined: Thu Sep 15, 2011 5:47 am

weird lisp loop type operation

Post by galosi198 » Thu Sep 15, 2011 5:50 am

Why does the function

(defun counter (list)
(if (null list)
0
(+ 1 ( name (cdr list) )
)
)

loop?

I can't quite see how the self-calling of counter works either.

ramarren
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland
Contact:

Re: weird lisp loop type operation

Post by ramarren » Thu Sep 15, 2011 7:55 am

Please use code tags for formatting code.

(name ...) is not a standard Common Lisp function. As shown, the counter doesn't loop by itself.

Post Reply