On 2013-06-05 19:50, Peter Bex wrote:
> [...]
> There is no C_listp predicate because you can't directly check an
> object for being a list; you must check whether it's
> C_SCHEME_END_OF_LIST (then it is a list).  Otherwise, if it's a pair
> you take its cdr and loop.  If it's something else, it's not a list.
> 
> Because this is a potentially heavy operation (and cyclic lists may
> even cause an endless loop), I guess it's been decided not to provide
> a predicate procedure for this,
> [...]

Hello,

but it's trivial to detect cyclic lists during the traversal using
either a set of seen elements or just two iteration pointers travelling
at different speeds.

The only problematic structures are truly infinite lists without
periodicity, but those are impossible with eager data structures like
the standard Scheme lists.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.


-- 
When C++ is your hammer, every problem looks like your thumb.


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to