I am looking for a way to check if a current value in a collection is greater than the next value, and if so, add that pair of items to a collection eg:
[9 2 3 7 11 8 3 7 1] => [9 2 11 8 8 3 7 1] ; Checking each item against the next
I initially thought I could do something like:
(filter (fn [[x y]] (> x y)) [9 2 3 7 11 8 3 7 1])
But something like this seemed to work only with associative types. So then I tried something like this:
(defn get-next [col index] ; Returns next item from a collection
(get col (inc (.indexOf col index))))
(filter (fn [[x]] (> x (get-next [9 2 3 7 11 8 3 7 1] x))) [9 2 3 7 11 8 3 7 1])
But still I got the same error. Any help would be appreciated