Fork me on GitHub
#specter
<
2015-12-11
>
exupero14:12:26

Is there a way with specter to transform the first element matching a predicate?

sveri14:12:57

@exupero: I had this working for me:

sveri14:12:11

(spec/transform [:new-entity :columns spec/ALL #(= (:id %) id)] #(assoc % key val) @state)``

sveri14:12:35

I guess if you switch ALL by FIRST it will only transform the first met one

exupero14:12:00

Using FIRST pred seems to get the first item in the sequence, then filter it on whether it satisfies the predicate.

exupero14:12:16

Essentially I want ALL pred FIRST.

exupero14:12:44

But that gives the error Vector’s key for assoc must be a number.