I am working on a function that will split a sequence of dates (or anything else) into a number of sequences contained within a vector based on a given number x.
(date1 date2 date3 date4 date5 date6 date7)
So given the list of dates above and passing in the variable 2 it will produce the vector below.
[(date1 date2) (date3 date4) (date5 date6) (date7)]
The code I have so far is below but all it returns is a vector containing nil.
(defn date-splitter [date-count dates x]
(loop [i date-count, current-split dates, split-dates (vector)]
(if (<= i x)
(conj split-dates (get current-split 1))
(let [s (split-at x current-split)]
(recur (int (- i x)) (get s 1) (conj split-dates (get s 0)))))))
I have also had a look at the split-with function, thinking that I could use it to split the sequence when the modulus of the index divided by x is zero, but I haven't had any luck with this.
Any help would be greatly appreciated.
David.