Hi Guys! I was just starting out with Specter. I had a few questions.
1. Are there error-handling functions implemented inside specter? Can I get errors as to where my navigator failed?
2. Can it work with lazy seqs? Will the laziness be preserved?
3. Can we use reducers in setval
?
@punit-naik there's no particular error handling done by specter
I can usually tell where I messed up a path by looking at the stack trace
specter will never produce a lazy output
though using select-first
can accomplish many of the same things since it terminates navigation as soon as it encounters a matching value
don't know what you mean by #3
@punit-naik the most efficient way to reduce over navigated values is with traverse
https://github.com/nathanmarz/specter/wiki/List-of-Macros#traverse
timing a single invocation tells you absolutely nothing, since neither specter nor the jvm have had a chance to optimize that callsite
use criterium for benchmarking
I think you want (transform [ALL (must :a)] inc [{:a 1 :b 2} {:a 2 :b 1} {:b 3}])
for that code
your path says to navigate to that key
it's doing exactly what you instructed
it's like doing (update {} :a inc)
okay.