This analogy is not quite right.

> (fn [n] (vector n (+ n 1))

is not a reducing fn. Tt is a cons cell builder, and the Church encoding builds 
lists.

The point of this library is to define map/filter etc *without* using 
lists/streams - not as input, not as output, not producing links/thunks etc, 
nor implicit streams formed by first/rest chained recursion, nor presuming 
input collections defined similarly.

It is only by doing this that you can get the true prize of this library - 
versions of map/filter etc that can be run in parallel, and that are completely 
independent of the data structures on which they are run.

Rich

On May 9, 2012, at 7:09 AM, nicolas.o...@gmail.com wrote:

> 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

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