indices of a value
Let's say you've got a sequence, [:a 1 :d :f :r 4 :d]
and you want to find all of the indices where :d
is. That would be (2 6)
. Your task is to write that function:
(indices-of :d [:a 1 :d :f :r 4 :d]) ;=> (2 6)
Thanks to this site for the challenge idea where it is considered Medium level in Python.
Email submissions to eric@purelyfunctional.tv before July 19, 2020. You can discuss the submissions in the comments below.
I like Jeroen's idea of adding the transducer version. He asked about the code duplication. My recommendation would be to make the two-arg arity call the transducer.
sequence
maintains the laziness.