Problem: I've got a collection of vectors or lists which I would like to find an idiomatic way to sum onto an existing vector possibly with uneven sized vectors. Contrived example showing the setup:
=>(def collated-list [2 3 4 5 6 7 8])
=>(def lists-to-add (partition-all 3 collatedlist))
=>(def base-list [1 1 1])
I'd like the result to sum the broken down collated lists onto the base-list
, for example, the first item would be 1 + 2 + 5 + 8
and so on.
What I've tried: I've tried a map
and a for
loop in couple of different ways but I seem to encounter either problems with Lazy Sequencing or problems of trying to add an Integer
to a Vector
.
These are my first experiments with Clojure so it's almost certainly me mis-understanding functional iteration here.
Thanks