Miscellaneous definitions concerning weak sequences #
These definitions, as well as those in Mathlib/Data/WSeq/Productive.lean, are not needed for the
development of Mathlib/Data/Seq/Parallel.lean.
Get the length of s (if it is finite and completes in finite time).
Equations
- One or more equations did not get rendered due to their size.
Instances For
A weak sequence is finite if toList s terminates. Equivalently,
it is a finite number of think and cons applied to nil.
- out : s.toList.Terminates
Instances
Select the elements of s that satisfy p.
Equations
- Stream'.WSeq.filter p = Stream'.WSeq.filterMap fun (a : α) => if p a then some a else none
Instances For
Get the first element of s satisfying p.
Equations
- Stream'.WSeq.find p s = (Stream'.WSeq.filter p s).head
Instances For
Zip two weak sequences into a single sequence of pairs
Equations
Instances For
Get the list of indexes of elements of s satisfying p
Equations
- Stream'.WSeq.findIndexes p s = Stream'.WSeq.filterMap (fun (x : α × ℕ) => match x with | (a, n) => if p a then some n else none) (s.zip ↑Stream'.nats)
Instances For
Get the index of the first element of s satisfying p
Equations
- Stream'.WSeq.findIndex p s = (fun (o : Option ℕ) => o.getD 0) <$> (Stream'.WSeq.findIndexes p s).head
Instances For
Get the index of the first occurrence of a in s
Equations
Instances For
Get the indexes of occurrences of a in s
Equations
Instances For
Returns true if s is nil and false if s has an element
Equations
Instances For
Split the sequence at position n into a finite initial segment
and the weak sequence tail
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if any element of s satisfies p
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns true if every element of s satisfies p
Equations
- One or more equations did not get rendered due to their size.
Instances For
Apply a function to the elements of the sequence to produce a sequence
of partial results. (There is no scanr because this would require
working from the end of the sequence, which may not exist.)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Like take, but does not wait for a result. Calculates n steps of
computation and returns the sequence computed so far
Equations
- s.collect n = List.filterMap id (Stream'.Seq.take n s)