Hello, given a collection like this one [:set1 :set2 :submit :set1 :submit :se2 :set3]
I want a function that returns the items immediately before each :submit
if no :submit
in the coll, I need an empty coll result
user=> (->> [:set1 :set2 :submit :set1 :submit :se2 :set3] (partition-by #(= :submit %)) butlast (remove #(= (list :submit) %)) (map last))
(:set2 :set1)
is my current solution using partition-by
.
Is there a way to do that with specter ? (or a better way in clojure for that matter, but Iām mainly interested in the specter version)@jvuillermet this is similar:
user=> (select [(continuous-subseqs #(not= :submit %)) LAST] data)
[:set2 :set1 :set3]
With https://github.com/nathanmarz/specter/issues/236 you could get exactly the same behavior