Looking at the implementation of next and rest in RT.java (see the methods next and more), the only difference between them is what they return when the result of calling seq on the argument is null. next returns null and more returns PersistentList.EMPTY. How does that relate to eager versus lazy sequences?
Here's the code for those two methods. static public ISeq next(Object x){ if(x instanceof ISeq) return ((ISeq) x).next(); ISeq seq = seq(x); if(seq == null) return null; return seq.next(); } static public ISeq more(Object x){ if(x instanceof ISeq) return ((ISeq) x).more(); ISeq seq = seq(x); if(seq == null) return PersistentList.EMPTY; return seq.more(); } On Sun, Aug 9, 2009 at 11:01 AM, Adrian Cuthbertson<adrian.cuthbert...@gmail.com> wrote: > > Hi Rob, have a look at http://clojure.org/sequences and then on that > page there's a reference to http://clojure.org/lazy, which explains > the evolution of the lazy/eager sequences. Next is used for eager > cases (e.g loop/recur) and rest for lazy-seq. Should make sense if you > check out those references. > > Hth, Adrian. > > On Sun, Aug 9, 2009 at 5:41 PM, Rob<rob.nikan...@gmail.com> wrote: >> >> Hi all, >> >> I'm trying to understand the next vs rest functions. I don't see why >> you want/need both. -- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---