Closed oskarkv closed 5 years ago
filterer
navigates you to a sequence. When the replacement sequence is shorter, it removes elements in the original data structure from the end. Put another way, it's indexes in the filterer
sequence that correspond to locations in the original data structure.
Oh, I see. Is there a better way to do what I wanted, i.e. remove the first element matching some predicate?
There's an idea for "stateful navigators" which would allow something like this to be done very elegantly: https://github.com/nathanmarz/specter/issues/121
For now, I would suggest using zippers. com.rpl.specter.zipper
integrates zippers with Specter.
Ok! Thank you!
If I do
(s/setval [(s/filterer (s/pred= 1)) s/FIRST] s/NONE [1 2 1 3])
I get[1 2 3]
but I expected[2 1 3]
. What's going on?