Re: ? stateful-map ?

2022-11-27 Thread Sam Ritchie
Pretty sure what you’re looking for is either https://clojuredocs.org/clojure.core/reductions or something close. This idea is called a “scanLeft” in some functional languages, so that should give you another search term to use. Good luck! On Sun, Nov 27, 2022, at 12:00 PM, Jules wrote: >

Re: ? stateful-map ?

2022-11-27 Thread Jules
I thought I should have a look at clojure.core.reducers in case there was an answer there - but this all still looks eager whereas I need something like a lazy reduction which applies a given function to its accumulator and each input to give it's new accumulator, which is output on each

? stateful-map ?

2022-11-27 Thread Jules
Guys, I've found myself needing a function that I am sure cannot be an original but I'm not aware of it existing anywhere... It is a cross between 'map', 'reduce' and 'iterate'... Given a function 'f' and a sequence 's' it would return you a sequence of : ``` [(f s[0]) (f (f s[0]) s[1]) (f (f