Re: ? stateful-map ?

2022-12-09 Thread Steve Miner
See also https://github.com/cgrand/xforms for a transducer version of reductions. The argument f must have a nullary arity. (You could probably create your own variant if you want an explicit init value.) I think something like this should work: (require '[net.cgrand.xforms :as x]) (defn xs

Re: ? stateful-map ?

2022-11-28 Thread Jules
;s' it would return you a sequence of > : > ``` > [(f s[0]) (f (f s[0]) s[1]) (f (f (f s[0]) s[1]) s[2]) ...] > ``` > > or, more concretely, e.g.: > ``` > util-test> (stateful-map + [0 1 2 3 4 5]) > [0 1 3 6 10 15] > util-test> > ``` > >

Re: ? stateful-map ?

2022-11-27 Thread Sam Ritchie
uence 's' it would return you a sequence of : > ``` > [(f s[0]) (f (f s[0]) s[1]) (f (f (f s[0]) s[1]) s[2]) ...] > ``` > > or, more concretely, e.g.: > ``` > util-test> (stateful-map + [0 1 2 3 4 5]) > [0 1 3 6 10 15] > util-test> > ``` > > I

Re: ? stateful-map ?

2022-11-27 Thread Jules
#x27; 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 (f s[0]) s[1]) s[2]) ...] > ``` > > or, more concretely, e.g.: > ``` > util-test> (stateful-m

? stateful-map ?

2022-11-27 Thread Jules
n you a sequence of : ``` [(f s[0]) (f (f s[0]) s[1]) (f (f (f s[0]) s[1]) s[2]) ...] ``` or, more concretely, e.g.: ``` util-test> (stateful-map + [0 1 2 3 4 5]) [0 1 3 6 10 15] util-test> ``` I have a couple of approaches to it - one using reduce: ``` (defn stateful-map-1 [f [h &