How deep is a list?
Posted: Wed Nov 17, 2010 4:20 am
Hi everyone 
I have a little task I'm wondering about. Because I'm suppose to figure out, how deep a list is.
Lets say f.ex a function like:
( ( ) , ( ( ) ( ) ) , ( ( ( ( ) ) ) ) )
And I figure out this list should be like "4" or something.
I've set the function like this:
(defun ld (x)
(if (listp x)
(if (null x)
else (if (ld (car x))
(if (ld (cdr x))
)
)
)
But I don't get this function: ( ( ) , ( ( ) ( ) ) , ( ( ( ( ) ) ) ) ) to work. Yes, I'm a newb in CL.
But hopefully some of you could explain something for me.
Thanks Ceenth

I have a little task I'm wondering about. Because I'm suppose to figure out, how deep a list is.
Lets say f.ex a function like:
( ( ) , ( ( ) ( ) ) , ( ( ( ( ) ) ) ) )
And I figure out this list should be like "4" or something.
I've set the function like this:
(defun ld (x)
(if (listp x)
(if (null x)
else (if (ld (car x))
(if (ld (cdr x))
)
)
)
But I don't get this function: ( ( ) , ( ( ) ( ) ) , ( ( ( ( ) ) ) ) ) to work. Yes, I'm a newb in CL.
But hopefully some of you could explain something for me.
Thanks Ceenth