cons and backtracking

Steve Yegge <[email protected]> Fri, 1 Apr 2005 12:02:07 -0800
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
Is there an equivalent of cons(item, list) in Nice?  I'm trying to
write a function that does backtracking, and in the recursive call, it
needs to push the most recent step onto a copy of the path.

Java's collections APIs are terrible for this sort of thing, since you
have to clone the list explicitly, and the add()/addAll() methods don't
return the list, so you wind up needing to spend several lines setting
it up.

And cloning it isn't easy -- if you're passing an ArrayList around
as a List, you can't call the ArrayList's clone() method, even though
it's public, because it's not exported through the List interface.
And Nice discourages you from trying to cast it, for obvious reasons.

Without cons and append, certain aspects of functional programming
are just as tricky (if not even harder) in Nice as in Java.  They'd be
great additions to nice/functional, I think.

-steve


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click