Fork me on GitHub
#specter
<
2016-09-24
>
caio03:09:45

@puzzler (select (pred (complement seq?)) m)?

puzzler04:09:36

`=> (select (pred (complement seq?)) [:a :b [:c :d] :e [:c :d]]) [[:a :b [:c :d] :e [:c :d]]]`

puzzler04:09:25

I did something like this:

puzzler04:09:30

=> (transform [(continuous-subseqs vector?)] #(first %) [:a :b [:c :d] :e [:c :d]])
[:a :b :c :d :e :c :d]

puzzler04:09:56

It feels a little hacky to me, but I don't see another way to do it.

puzzler05:09:44

Actually, that won't work if they are adjacent.

puzzler05:09:42

Any other ideas?

puzzler05:09:07

=> (transform [(continuous-subseqs vector?)] #(first %) [:a :b [:c :d] [:c :d]])
[:a :b :c :d]

puzzler05:09:36

@caio I don't see how yours would work, but mine doesn't work either.

puzzler05:09:08

This works:

puzzler05:09:18

=> (transform [(continuous-subseqs vector?)] #(apply concat %) [:a :b [:c :d] [:c :d]])
[:a :b :c :d :c :d]

puzzler05:09:27

It's still hacky

nathanmarz12:09:24

@puzzler you could make a new navigator which navigates to each element as a 1 element subsequence

nathanmarz12:09:27

or a new version of ALL which does splicing if the transformed element has metadata indicating to do so

nathanmarz12:09:10

e.g. (transform [MY-ALL vector?] (fn [v] (with-meta v {:all-splice true})) data)

nathanmarz12:09:40

can also do this:

(def SPLICED (comp-paths (continuous-subseqs vector?) (view #(apply concat %))))
(transform SPLICED identity [:a :b [:c :d] :e [:c :d]])
[:a :b :c :d :e :c :d]