Here's a straightforward way: (define (cumulative-sum list) (let loop ([list list] [acc 0]) (if (null? list) list (let ([s (+ (first list) acc)]) (cons s (loop (rest list) s))))))
On Thu, Jan 22, 2015 at 2:53 PM, Alexandr M <rus...@gmail.com> wrote: > Hello, > > I am trying to replicate functionality of this code in Python: > > https://gist.github.com/m-blog/22b7c5d31b3839ffba50#file-cumsum-py > > in Racket without usage of any libraries. > > What would the most optimal / concise way to do it in Racket? > > Thank you. > > -- > Best regards, > Alex > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > ____________________ Racket Users list: http://lists.racket-lang.org/users