refactor: restore Subarray.foldl and Subarray.forIn signatures (#9762)
This PR does what #9234 regrettably failed to do: actually reintroduce the signatures of some `Subarray` functions that are now implemented via slices (see #9017) in order to ensure backward compatibility and consistency. With this PR, the old interface is restored. As an added benefit, `Subarray.forIn` is no longer opaque.
This commit is contained in:
parent
6d5ce9b87f
commit
ea09ffc8ce
1 changed files with 9 additions and 1 deletions
|
|
@ -108,9 +108,17 @@ Examples:
|
|||
* `#["red", "green", "blue"].toSubarray.popFront.foldl (· + ·.length) 0 = 9`
|
||||
-/
|
||||
@[inline]
|
||||
def foldl {α : Type u} {β : Type v} (f : β → α → β) (init : β) (as : Subarray α) : β :=
|
||||
def Subarray.foldl {α : Type u} {β : Type v} (f : β → α → β) (init : β) (as : Subarray α) : β :=
|
||||
Slice.foldl f (init := init) as
|
||||
|
||||
/--
|
||||
The implementation of `ForIn.forIn` for `Subarray`, which allows it to be used with `for` loops in
|
||||
`do`-notation.
|
||||
-/
|
||||
@[inline]
|
||||
def Subarray.forIn {α : Type u} {β : Type v} {m : Type v → Type w} [Monad m] (s : Subarray α) (b : β) (f : α → β → m (ForInStep β)) : m β :=
|
||||
ForIn.forIn s b f
|
||||
|
||||
namespace Array
|
||||
|
||||
/--
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue