Something like this perhaps: (define (cumulative-sums xs) (rest (reverse (for/fold ([sums '(0)]) ([x xs]) (cons (+ (first sums) x) sums)))))
Or (define (cumulative-sums xs) (define s 0) (for/list ([x xs]) (set! s (+ s x)) s)) 2015-01-22 14:53 GMT+01:00 Alexandr M <rus...@gmail.com>: > 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 > -- -- Jens Axel Søgaard ____________________ Racket Users list: http://lists.racket-lang.org/users