Hi,

If you know any smart solutions with only currently available

functions, please tell me. I mean, 'smart' solutions have no explicit

'lazy-seq', recursion, and return a lazy sequence as a result.


How about using clojure.contrib.seq-utils/reductions?


> user> (accum-seq [1, 1, 1, 1, 1])
> (1 2 3 4 5)
> user> (accum-seq [1, 2, 3, 4, 5])
> (1 3 6 10 15)
> user> (accum-seq [1, -1, 1, -1, 1])
> (1 0 1 0 1)
>

user> (use '[clojure.contrib.seq-utils :only (reductions)])
nil
user> (reductions + [1,1,1,1,1])
(1 2 3 4 5)
user> (reductions + [1,2,3,4,5])
(1 3 6 10 15)
user> (reductions + [1,-1,1,-1,1])
(1 0 1 0 1)
user>

I learned this function by Stu Halloway's labrepl.

-- 
Satoshi Tajima
e-mail: satu...@gmail.com

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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to