On Sun, Jan 4, 2009 at 5:51 PM, Jason Wolfe <jawo...@berkeley.edu> wrote:
>
> That does satisfy my requirements as a lazy stack data structure.
> However, it does so by adding an inner level of cons objects; this is
> more or less equivalent to just calling (delay) on each level of the
> seq and then having to explicitly (force) each time an element is
> extracted.

Except that I introduce no new object at all.  I don't create any seq
or delay object.  Every object I used was given to me from the user of
'push-seq' function, so I'm not quite sure what you mean.

> With either workaround, the built-in seq functions are no
> longer directly applicable.  I can't call filter directly on an mstk,
> for example.

This would be true of any compound data structure built out of clojure
collections.  'filter', 'map' etc. don't automatically traverse trees,
graphs, or other nested structures.  But a function that returns a
lazy seq over an mstk is pretty easy:

(defn mstk-seq [mstk]
  (lazy-cons (single-peek mstk) (single-pop mstk)))

I think you'll find this has the same laziness profile as the raw
calls to single-peek and single-pop I presented earlier.

--Chouser

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to