It looks very good.

Just a few side-notes:
 - this representation is quite well known, as it is the Church
encoding of list, often used in System F, for example.
   It corresponds to stating the definition of sequences as the
initial algebra of F A = 1 + Any x A.
 - you can play a dual trick for Streams and coLists by representing
them as how to generate them, the same way that you can represent list
as how you reduce them.
This gives a representation of a coList as
   [ seed f ] where f is a function from the seed to either nil(if the
coList is finished) or a pair of an element and as seed.
For example, the integers would be
nat =    [ 0 (fn [n] (vector n (+ n 1))) ]
Then, you can play the same game and define map, filter (which is not
always productive...), and so on, on this
representation, with the same benefits.

You can then also write converters from this representation to
reducible. This would allow to write
(reduce + (take n nat)) without allocating any sequence...

Best,

Nicolas.

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

Reply via email to