I have two selects that only differ in the argument to must
: (select [ALL ALL (selected? (must x))] board)
, where x
is :color
and :robot
any way to combine the two into one or should I just do them separately?
if you want to do 1 call that returns both, you could probably do (selected? (multi-path (must :color) (must :robot)))
?
probably could also do (must (multi-path :color :robot))
?
oh sorry, I forgot to mention that I would like to get the results in two different arrays, sort of like this:
user=> (select [(multi-path (filterer odd?) (filterer even?))] (range 10))
[[1 3 5 7 9] [0 2 4 6 8]]
I have a vague recollection that I’ve asked this question before, and that the answer was no 😄
@schmee yea, there's no way to do that
besides doing (multi-path (subselect ...) (subselect ...))
, but that's no more efficient than just doing two select
's
hmm. can anyone think of a way to say "every element after the first element" without knowing the length of the sequence in advance? like a rest
or drop 1
navigator?
hmm, maybe something with not-selected
@idiomancy you can do that with srange-dynamic
or INDEXED-VALS
gotcha, yeah that makes sense
so something like (def REST [(spr/srange-dynamic #(do 1) #(count %)) spr/ALL])
@idiomancy yes
actually (def REST (path (srange-dynamic #(do 1) count) ALL))
is better
more efficient to use when constructing paths dynamically
huh, interesting! Thanks for the tip! So, what do you mean by "dynamically" here? Is there some way to construct them at compile time instead?
nvm, referring to the documentation now
again, thanks!