I want to filter a list based on nested values. Basically this
(filter
#(and (= (get-in % [:a :b]) 1)
(= (get-in % [:a :c]) 2))
data)
Can specter help me here?It can help with performance here as it's faster than get-in
If I were to write this in specter natively it would look like this:
(select [ALL (selected? (must :a :b) (pred= 1)) (selected? (must :a :c) (pred= 2))] data)Thanks! But this not just filters, it has mapped :a over the data too. Can I use selected? before the :a without having to repeat the :a for both conditions somehow?
Ah, right, my mistake. Yes.
I edited the example to be accurate.