specter

Latest version: 1.1.3
jvuillermet 2017-12-24T16:34:04.000033Z

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)

nathanmarz 2017-12-24T19:47:03.000049Z

@jvuillermet this is similar:

user=> (select [(continuous-subseqs #(not= :submit %)) LAST] data)
[:set2 :set1 :set3]

šŸ‘ 1
nathanmarz 2017-12-24T19:47:40.000001Z

With https://github.com/nathanmarz/specter/issues/236 you could get exactly the same behavior