- node: {α : Type u} → Array (Lean.PersistentArrayNode α) → Lean.PersistentArrayNode α
- leaf: {α : Type u} → Array α → Lean.PersistentArrayNode α
Instances For
instance
Lean.instInhabitedPersistentArrayNode :
{a : Type u_1} → Inhabited (Lean.PersistentArrayNode a)
Equations
- Lean.instInhabitedPersistentArrayNode = { default := Lean.PersistentArrayNode.node default }
Equations
- Lean.PersistentArrayNode.isNode x = match x with | Lean.PersistentArrayNode.node cs => true | Lean.PersistentArrayNode.leaf vs => false
Instances For
@[inline, reducible]
Equations
Instances For
@[inline, reducible]
Equations
Instances For
- root : Lean.PersistentArrayNode α
- tail : Array α
- size : Nat
- shift : USize
- tailOff : Nat
Instances For
Equations
- Lean.instInhabitedPersistentArray = { default := { root := default, tail := default, size := default, shift := default, tailOff := default } }
@[inline, reducible]
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.PersistentArray.isEmpty a = (a.size == 0)
Instances For
Equations
- Lean.PersistentArray.mkEmptyArray = Array.mkEmpty (USize.toNat Lean.PersistentArray.branching)
Instances For
@[inline, reducible]
Equations
- Lean.PersistentArray.mul2Shift i shift = USize.shiftLeft i shift
Instances For
@[inline, reducible]
Equations
- Lean.PersistentArray.div2Shift i shift = USize.shiftRight i shift
Instances For
@[inline, reducible]
Equations
- Lean.PersistentArray.mod2Shift i shift = USize.land i (USize.shiftLeft 1 shift - 1)
Instances For
partial def
Lean.PersistentArray.getAux
{α : Type u}
[Inhabited α]
:
Lean.PersistentArrayNode α → USize → USize → α
Equations
- Lean.PersistentArray.get! t i = if i ≥ t.tailOff then Array.get! t.tail (i - t.tailOff) else Lean.PersistentArray.getAux t.root (USize.ofNat i) t.shift
Instances For
instance
Lean.PersistentArray.instGetElemPersistentArrayNatLtInstLTNatSize
{α : Type u}
[Inhabited α]
:
GetElem (Lean.PersistentArray α) Nat α fun as i => i < as.size
Equations
- Lean.PersistentArray.instGetElemPersistentArrayNatLtInstLTNatSize = { getElem := fun xs i x => Lean.PersistentArray.get! xs i }
partial def
Lean.PersistentArray.setAux
{α : Type u}
:
Lean.PersistentArrayNode α → USize → USize → α → Lean.PersistentArrayNode α
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[specialize #[]]
@[specialize #[]]
def
Lean.PersistentArray.modify
{α : Type u}
[Inhabited α]
(t : Lean.PersistentArray α)
(i : Nat)
(f : α → α)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
partial def
Lean.PersistentArray.insertNewLeaf
{α : Type u}
:
Lean.PersistentArrayNode α → USize → USize → Array α → Lean.PersistentArrayNode α
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
partial def
Lean.PersistentArray.popLeaf
{α : Type u}
:
Lean.PersistentArrayNode α → Option (Array α) × Array (Lean.PersistentArrayNode α)
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[specialize #[]]
def
Lean.PersistentArray.foldlM
{α : Type u}
{m : Type v → Type w}
[Monad m]
{β : Type v}
(t : Lean.PersistentArray α)
(f : β → α → m β)
(init : β)
(start : optParam Nat 0)
:
m β
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[specialize #[]]
def
Lean.PersistentArray.foldrM
{α : Type u}
{m : Type v → Type w}
{β : Type v}
[Monad m]
(t : Lean.PersistentArray α)
(f : α → β → m β)
(init : β)
:
m β
Equations
- Lean.PersistentArray.foldrM t f init = do let __do_lift ← Array.foldrM f init t.tail (Array.size t.tail) Lean.PersistentArray.foldrMAux f t.root __do_lift
Instances For
@[specialize #[]]
def
Lean.PersistentArray.forIn
{α : Type u}
{m : Type v → Type w}
[Monad m]
{β : Type v}
(t : Lean.PersistentArray α)
(init : β)
(f : α → β → m (ForInStep β))
:
m β
Equations
- One or more equations did not get rendered due to their size.
Instances For
instance
Lean.PersistentArray.instForInPersistentArray
{α : Type u}
{m : Type v → Type w}
:
ForIn m (Lean.PersistentArray α) α
@[specialize #[]]
partial def
Lean.PersistentArray.findSomeMAux
{α : Type u}
{m : Type v → Type w}
[Monad m]
{β : Type v}
(f : α → m (Option β))
:
Lean.PersistentArrayNode α → m (Option β)
@[specialize #[]]
def
Lean.PersistentArray.findSomeM?
{α : Type u}
{m : Type v → Type w}
[Monad m]
{β : Type v}
(t : Lean.PersistentArray α)
(f : α → m (Option β))
:
m (Option β)
Equations
- Lean.PersistentArray.findSomeM? t f = do let __do_lift ← Lean.PersistentArray.findSomeMAux f t.root match __do_lift with | none => Array.findSomeM? t.tail f | some b => pure (some b)
Instances For
@[specialize #[]]
partial def
Lean.PersistentArray.findSomeRevMAux
{α : Type u}
{m : Type v → Type w}
[Monad m]
{β : Type v}
(f : α → m (Option β))
:
Lean.PersistentArrayNode α → m (Option β)
@[specialize #[]]
def
Lean.PersistentArray.findSomeRevM?
{α : Type u}
{m : Type v → Type w}
[Monad m]
{β : Type v}
(t : Lean.PersistentArray α)
(f : α → m (Option β))
:
m (Option β)
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[specialize #[]]
def
Lean.PersistentArray.forM
{α : Type u}
{m : Type v → Type w}
[Monad m]
(t : Lean.PersistentArray α)
(f : α → m PUnit)
:
m PUnit
Equations
- Lean.PersistentArray.forM t f = SeqRight.seqRight (Lean.PersistentArray.forMAux f t.root) fun x => Array.forM f t.tail 0 (Array.size t.tail)
Instances For
@[inline]
def
Lean.PersistentArray.foldl
{α : Type u}
{β : Type u_1}
(t : Lean.PersistentArray α)
(f : β → α → β)
(init : β)
(start : optParam Nat 0)
:
β
Equations
- Lean.PersistentArray.foldl t f init start = Id.run (Lean.PersistentArray.foldlM t f init start)
Instances For
@[inline]
def
Lean.PersistentArray.foldr
{α : Type u}
{β : Type u_1}
(t : Lean.PersistentArray α)
(f : α → β → β)
(init : β)
:
β
Equations
- Lean.PersistentArray.foldr t f init = Id.run (Lean.PersistentArray.foldrM t f init)
Instances For
@[inline]
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.PersistentArray.toArray t = Lean.PersistentArray.foldl t Array.push #[]
Instances For
def
Lean.PersistentArray.append
{α : Type u}
(t₁ : Lean.PersistentArray α)
(t₂ : Lean.PersistentArray α)
:
Equations
- Lean.PersistentArray.append t₁ t₂ = if Lean.PersistentArray.isEmpty t₁ = true then t₂ else Lean.PersistentArray.foldl t₂ Lean.PersistentArray.push t₁
Instances For
Equations
- Lean.PersistentArray.instAppendPersistentArray = { append := Lean.PersistentArray.append }
@[inline]
def
Lean.PersistentArray.findSome?
{α : Type u}
{β : Type u_1}
(t : Lean.PersistentArray α)
(f : α → Option β)
:
Option β
Equations
Instances For
@[inline]
def
Lean.PersistentArray.findSomeRev?
{α : Type u}
{β : Type u_1}
(t : Lean.PersistentArray α)
(f : α → Option β)
:
Option β
Equations
Instances For
Equations
- Lean.PersistentArray.toList t = List.reverse (Lean.PersistentArray.foldl t (fun xs x => x :: xs) [])
Instances For
@[specialize #[]]
partial def
Lean.PersistentArray.anyMAux
{α : Type u}
{m : Type → Type w}
[Monad m]
(p : α → m Bool)
:
Lean.PersistentArrayNode α → m Bool
@[specialize #[]]
def
Lean.PersistentArray.anyM
{α : Type u}
{m : Type → Type w}
[Monad m]
(t : Lean.PersistentArray α)
(p : α → m Bool)
:
m Bool
Equations
- Lean.PersistentArray.anyM t p = (Lean.PersistentArray.anyMAux p t.root <||> Array.anyM p t.tail 0 (Array.size t.tail))
Instances For
@[inline]
def
Lean.PersistentArray.allM
{α : Type u}
{m : Type → Type w}
[Monad m]
(a : Lean.PersistentArray α)
(p : α → m Bool)
:
m Bool
Equations
- Lean.PersistentArray.allM a p = do let b ← Lean.PersistentArray.anyM a fun v => do let b ← p v pure !b pure !b
Instances For
@[inline]
Equations
Instances For
@[inline]
Equations
- Lean.PersistentArray.all a p = !Lean.PersistentArray.any a fun v => !p v
Instances For
@[specialize #[]]
def
Lean.PersistentArray.mapM
{α : Type u}
{m : Type u → Type v}
[Monad m]
{β : Type u}
(f : α → m β)
(t : Lean.PersistentArray α)
:
m (Lean.PersistentArray β)
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[inline]
Equations
Instances For
Equations
- Lean.PersistentArray.stats r = Lean.PersistentArray.collectStats r.root { numNodes := 0, depth := 0, tailSize := Array.size r.tail } 0
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- Lean.mkPersistentArray n v = Nat.fold (fun x p => Lean.PersistentArray.push p v) n Lean.PersistentArray.empty
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- List.toPArray'.loop [] x = x
- List.toPArray'.loop (x_2 :: xs) x = List.toPArray'.loop xs (Lean.PersistentArray.push x x_2)
Instances For
Equations
- Array.toPArray' xs = Array.foldl (fun p x => Lean.PersistentArray.push p x) Lean.PersistentArray.empty xs 0 (Array.size xs)