weird lisp loop type operation

Discussion of Common Lisp

weird lisp loop type operation

Postby 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.
galosi198
 
Posts: 1
Joined: Thu Sep 15, 2011 5:47 am

Re: weird lisp loop type operation

Postby 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.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland


Return to Common Lisp

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests