You can look at this, starting with a sequence of cards, filtering out a sequence of values: a and a separate sequence of a moving sum of values: b, and then matching the function of two arguments to two derived sequences.
create a sequence of only values: a and: b with
(map :a my-vec) (map :b my-vec)
then the function to get the moving amount:
(defn sums [sum seq] "produce a seq of the rolling sum" (if (empty? seq) sum (lazy-seq (cons sum (recur (+ sum (first seq)) (rest seq))))))
then connect them:
(map #(prn %1 %s) (map :a my-vec) (sums 0 (map :b my-vec)))
This separates the problem of generating data from its processing . Hope this makes life easier.
PS: the best way to get a moving amount?
source share