English
Get the list of indices of elements of s that satisfy a predicate p: findIndexes(p)(s) = (zip s (nats)).filterMap (λ ⟨a,n⟩, if p a then some n else none).
Русский
Получить список индексов элементов последовательности s, удовлетворяющих предикату p: findIndexes(p)(s) = (zip s (nats)).filterMap (λ ⟨a,n⟩, если p a то some n иначе none).
LaTeX
$$$$ \\mathrm{findIndexes}(p)(s) = (\\mathrm{zip}\\, s\\, (\\mathrm{Stream'.nats})).\\mathrm{filterMap}\\ \\lambda\\ \\langle a,n \\rangle,.\\ \\text{if } p(a)\\ \text{then } \\text{some } n\\ else \\text{none} $$$$
Lean4
/-- Get the list of indexes of elements of `s` satisfying `p` -/
def findIndexes (p : α → Prop) [DecidablePred p] (s : WSeq α) : WSeq ℕ :=
(zip s (Stream'.nats : WSeq ℕ)).filterMap fun ⟨a, n⟩ => if p a then some n else none