This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-24
Channels
- # adventofcode (33)
- # beginners (15)
- # cider (6)
- # clara (24)
- # cljs-dev (3)
- # clojure (39)
- # clojure-france (1)
- # clojure-greece (1)
- # clojure-norway (1)
- # clojure-spec (9)
- # clojure-uk (1)
- # clojurescript (40)
- # defnpodcast (1)
- # fulcro (9)
- # hoplon (33)
- # jobs-discuss (4)
- # lumo (3)
- # off-topic (4)
- # onyx (2)
- # parinfer (7)
- # precept (45)
- # re-frame (25)
- # ring-swagger (4)
- # shadow-cljs (2)
- # specter (3)
- # sql (10)
- # uncomplicate (3)
- # unrepl (8)
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