Assume I want to remove the numbers under 544673. Can anyone suggest what would be elegant? I realize I can do a loop or a reduce but I assume there might be something more elegant?
(->> amounts (take-while #(< % 544673)) vec)
;;or, slightly more efficient using transducer + transient behind the scene
(into [] (take-while #(< % 544673)) amounts)
There are even more efficient ways, depending on performance considerations. You could binary search for the index of the last entry < 5446773, then use subvec to derive a vector slice in o(1) time. So derive a “new” vector in O (log(n)) (original would still be referenced transitively though…).