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]
Instances For
Instances For
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]
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".toSlice.revChars.toList = ['c', 'b', 'a']"ab∀c".toSlice.revChars.toList = ['c', '∀', 'b', 'a']
Instances For
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
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"
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"
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]
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]
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']