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

Yeah, I think it 'smart'. Thanks for a nice solution.

----
Yuto HAYAMIZU

On 4月11ζ—₯, 午後11:48, Steve Purcell <st...@sanityinc.com> wrote:
> On 10 Apr 2010, at 08:46, Yuto Hayamizu wrote:
>
>
>
> > Hi, all
>
> > I want some list functions inHaskelllike mapAccumL in
> > clojure.contrib, because some sequence operations are difficult with
> > only functions in clojure.core and contrib.
>
> > Think about writing a function 'accum-seq', which takes a sequence of
> > numbers, and returns a sequence of numbers. Each element of returned
> > sequence is sum of numbers from the beginning to its position in given
> > sequence.
>
> > Ex)
> > 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)
>
> > 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.
>
> Does this qualify as a 'smart' solution?
>
> user> (use '[clojure.contrib.seq-utils :only (reductions)])
> nil
> user> (reductions + [1 2 3 4 5])
> (1 3 6 10 15)
> user>
>
> -Steve

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