Equations
- String.Slice.instInhabitedPosIterator.default = { currPos := default }
Instances For
Equations
Creates an iterator over all valid positions within {name}s.
Examples:
- {lean}
("abc".toSlice.positions.map (fun ⟨p, h⟩ => p.get h) |>.toList) = ['a', 'b', 'c'] - {lean}
("abc".toSlice.positions.map (·.val.offset.byteIdx) |>.toList) = [0, 1, 2] - {lean}
("ab∀c".toSlice.positions.map (fun ⟨p, h⟩ => p.get h) |>.toList) = ['a', 'b', '∀', 'c'] - {lean}
("ab∀c".toSlice.positions.map (·.val.offset.byteIdx) |>.toList) = [0, 1, 2, 5]
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Creates an iterator over all characters (Unicode code points) in s.
Examples:
"abc".toSlice.chars.toList = ['a', 'b', 'c']"ab∀c".toSlice.chars.toList = ['a', 'b', '∀', 'c']
Equations
Instances For
Equations
Equations
- String.Slice.instInhabitedRevPosIterator.default = { currPos := default }
Instances For
Creates an iterator over all valid positions within s that are strictly smaller than
p, starting from the position before p and iterating towards the first one.
Instances For
Creates an iterator over all valid positions within {name}s, starting from the last valid
position and iterating towards the first one.
Examples
- {lean}
("abc".toSlice.revPositions.map (fun ⟨p, h⟩ => p.get h) |>.toList) = ['c', 'b', 'a'] - {lean}
("abc".toSlice.revPositions.map (·.val.offset.byteIdx) |>.toList) = [2, 1, 0] - {lean}
("ab∀c".toSlice.revPositions.map (fun ⟨p, h⟩ => p.get h) |>.toList) = ['c', '∀', 'b', 'a'] - {lean}
("ab∀c".toSlice.revPositions.map (·.val.offset.byteIdx) |>.toList) = [5, 2, 1, 0]
Equations
- s.revPositions = s.revPositionsFrom s.endPos
Instances For
Equations
- One or more equations did not get rendered due to their size.
Creates an iterator over all characters (Unicode code points) in s, starting from the end
of the slice and iterating towards the start.
Example:
"abc".toSlice.revChars.toList = ['c', 'b', 'a']"ab∀c".toSlice.revChars.toList = ['c', '∀', 'b', 'a']
Equations
Instances For
Equations
Instances For
Creates an iterator over all bytes in {name}s.
Examples:
- {lean}
"abc".toSlice.bytes.toList = [97, 98, 99] - {lean}
"ab∀c".toSlice.bytes.toList = [97, 98, 226, 136, 128, 99]
Instances For
Equations
- One or more equations did not get rendered due to their size.
Creates an iterator over all bytes in {name}s, starting from the last one and iterating towards
the first one.
Examples:
- {lean}
"abc".toSlice.revBytes.toList = [99, 98, 97] - {lean}
"ab∀c".toSlice.revBytes.toList = [99, 128, 136, 226, 98, 97]
Instances For
Equations
- String.Slice.instInhabitedRevByteIterator = { default := let s := default; { s := s, offset := s.endPos.offset, hinv := String.Slice.instInhabitedRevByteIterator._proof_1 } }
Equations
- One or more equations did not get rendered due to their size.
Equations
- String.Slice.RevByteIterator.instForInCharOfMonad = { forIn := fun {β : Type ?u.25} (s : String.Slice) (b : β) (f : Char → β → m (ForInStep β)) => forIn s.chars b f }
Folds a function over a slice from the start, accumulating a value starting with init. The
accumulated value is combined with each character in order, using f.
Examples:
"coffee tea water".toSlice.foldl (fun n c => if c.isWhitespace then n + 1 else n) 0 = 2"coffee tea and water".toSlice.foldl (fun n c => if c.isWhitespace then n + 1 else n) 0 = 3"coffee tea water".toSlice.foldl (·.push ·) "" = "coffee tea water"
Equations
- String.Slice.foldl f init s = Std.Iter.fold f init s.chars
Instances For
Folds a function over a slice from the end, accumulating a value starting with init. The
accumulated value is combined with each character in reverse order, using f.
Examples:
"coffee tea water".toSlice.foldr (fun c n => if c.isWhitespace then n + 1 else n) 0 = 2"coffee tea and water".toSlice.foldr (fun c n => if c.isWhitespace then n + 1 else n) 0 = 3"coffee tea water".toSlice.foldr (fun c s => s.push c) "" = "retaw aet eeffoc"
Equations
- String.Slice.foldr f init s = Std.Iter.fold (flip f) init s.revChars
Instances For
Creates an iterator over all valid positions within s.
Examples
("abc".positions.map (fun ⟨p, h⟩ => p.get h) |>.toList) = ['a', 'b', 'c']("abc".positions.map (·.val.offset.byteIdx) |>.toList) = [0, 1, 2]("ab∀c".positions.map (fun ⟨p, h⟩ => p.get h) |>.toList) = ['a', 'b', '∀', 'c']("ab∀c".positions.map (·.val.offset.byteIdx) |>.toList) = [0, 1, 2, 5]
Equations
- s.positions = s.positionsFrom s.startPos
Instances For
Creates an iterator over all valid positions within s that are strictly smaller than
p, starting from the position before p and iterating towards the first one.
Equations
Instances For
Creates an iterator over all valid positions within s, starting from the last valid
position and iterating towards the first one.
Examples
("abc".revPositions.map (fun ⟨p, h⟩ => p.get h) |>.toList) = ['c', 'b', 'a']("abc".revPositions.map (·.val.offset.byteIdx) |>.toList) = [2, 1, 0]("ab∀c".revPositions.map (fun ⟨p, h⟩ => p.get h) |>.toList) = ['c', '∀', 'b', 'a']("ab∀c".toSlice.revPositions.map (·.val.offset.byteIdx) |>.toList) = [5, 2, 1, 0]
Equations
- s.revPositions = s.revPositionsFrom s.endPos
Instances For
Creates an iterator over all characters (Unicode code points) in s, starting from the end
of the slice and iterating towards the start.
Example:
"abc".revChars.toList = ['c', 'b', 'a']"ab∀c".revChars.toList = ['c', '∀', 'b', 'a']
Instances For
Creates an iterator over all bytes in s.
Examples:
"abc".byteIterator.toList = [97, 98, 99]"ab∀c".byteIterator.toList = [97, 98, 226, 136, 128, 99]
Equations
- s.byteIterator = s.toSlice.bytes
Instances For
Creates an iterator over all bytes in s, starting from the last one and iterating towards
the first one.
Examples:
"abc".revBytes.toList = [99, 98, 97]"ab∀c".revBytes.toList = [99, 128, 136, 226, 98, 97]