chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Question about the implementation of list?


From: Daniel Carrera
Subject: [Chicken-users] Question about the implementation of list?
Date: Fri, 7 Mar 2014 19:25:56 +0100

Hello,

I recently learned that a list is defined as either the empty list or a pair where the second element is a list. For example:

#;2> (list? (cons 1 (cons 2 (cons 3 (cons 4 (cons 5 '()))))))
#t
#;3> (list? (cons 1 (cons 2 (cons 3 (cons 4 (cons 5 6))))))
#f


Does this mean that "list?" is O(n) on the list length? In other words, you cannot know whether a pair is a list until you have visited every node all the way to the end, till you hit '().

Cheers,
Daniel.
--
When an engineer says that something can't be done, it's a code phrase that means it's not fun to do.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]