Legacy implementations of String operations #
This file includes old definitions of String functions that were downstreamed from core to prevent
Batteries.Data.String.Lemmas from breaking.
Implementation of String.Legacy.map.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Applies the function f to every character in a string, returning a string that contains the
resulting characters.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas. Its runtime behavior is equivalent to that of String.map.
Examples:
"abc123".map Char.toUpper = "ABC123""".map Char.toUpper = ""
Equations
- String.Legacy.map f s = String.Legacy.mapAux f 0 s
Instances For
Removes the specified number of characters (Unicode code points) from the start of the string.
If n is greater than s.length, returns "".
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas. Its runtime behavior is equivalent to that of String.drop.
Examples:
"red green blue".drop 4 = "green blue""red green blue".drop 10 = "blue""red green blue".drop 50 = ""
Equations
- String.Legacy.drop s n = (s.toRawSubstring.drop n).toString
Instances For
Creates a new string that contains the first n characters (Unicode code points) of s.
If n is greater than s.length, returns s.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas. Its runtime behavior is equivalent to that of String.take.
Examples:
"red green blue".take 3 = "red""red green blue".take 1 = "r""red green blue".take 0 = """red green blue".take 100 = "red green blue"
Equations
- String.Legacy.take s n = (s.toRawSubstring.take n).toString
Instances For
Creates a new string that contains the longest prefix of s in which p returns true for all
characters.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas. Its runtime behavior is equivalent to that of String.takeWhile.
Examples:
"red green blue".takeWhile (·.isLetter) = "red""red green blue".takeWhile (· == 'r') = "r""red green blue".takeWhile (· != 'n') = "red gree""red green blue".takeWhile (fun _ => true) = "red green blue"
Equations
- String.Legacy.takeWhile s p = (s.toRawSubstring.takeWhile p).toString
Instances For
Creates a new string by removing the longest prefix from s in which p returns true for all
characters.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas. Its runtime behavior is equivalent to that of String.dropWhile.
Examples:
"red green blue".dropWhile (·.isLetter) = " green blue""red green blue".dropWhile (· == 'r') = "ed green blue""red green blue".dropWhile (· != 'n') = "n blue""red green blue".dropWhile (fun _ => true) = ""
Equations
- String.Legacy.dropWhile s p = (s.toRawSubstring.dropWhile p).toString
Instances For
Auxiliary definition for String.Legacy.foldl.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas. Its runtime behavior is equivalent to that of String.foldlAux.
Equations
- String.Legacy.foldlAux f s stopPos i a = if h : i < stopPos then have this := ⋯; String.Legacy.foldlAux f s stopPos (String.Pos.Raw.next s i) (f a (String.Pos.Raw.get s i)) else a
Instances For
Folds a function over a string from the left, accumulating a value starting with init. The
accumulated value is combined with each character in order, using f.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas. Its runtime behavior is equivalent to that of String.foldl.
Examples:
"coffee tea water".foldl (fun n c => if c.isWhitespace then n + 1 else n) 0 = 2"coffee tea and water".foldl (fun n c => if c.isWhitespace then n + 1 else n) 0 = 3"coffee tea water".foldl (·.push ·) "" = "coffee tea water"
Equations
- String.Legacy.foldl f init s = String.Legacy.foldlAux f s s.rawEndPos 0 init
Instances For
Returns the first character in s. If s = "", returns (default : Char).
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas. Its runtime behavior is equivalent to that of String.front.
Examples:
Equations
Instances For
Returns the last character in s. If s = "", returns (default : Char).
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas. Its runtime behavior is equivalent to that of String.back.
Examples:
Equations
Instances For
Auxuliary definition for String.Legacy.posOf.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the position of the first occurrence of a character, c, in a string s. If s does not
contain c, returns s.rawEndPos.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Examples:
Equations
- String.Legacy.posOf s c = String.Legacy.posOfAux s c s.rawEndPos 0
Instances For
Auxuliary definition for String.Legacy.revPosOf.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the position of the last occurrence of a character, c, in a string s. If s does not
contain c, returns none.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Examples:
Equations
Instances For
Auxuliary definition for String.Legacy.find.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Finds the position of the first character in a string for which the Boolean predicate p returns
true. If there is no such character in the string, then the end position of the string is
returned.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Examples:
Equations
- String.Legacy.find s p = String.Legacy.findAux s p s.rawEndPos 0
Instances For
Auxuliary definition for String.Legacy.revFind.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Finds the position of the last character in a string for which the Boolean predicate p returns
true. If there is no such character in the string, then none is returned.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Examples:
"coffee tea water".revFind (·.isWhitespace) = some ⟨10⟩"tea".revFind (· == 'X') = none"".revFind (· == 'X') = none
Equations
Instances For
Auxuliary definition for String.Legacy.foldr.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Folds a function over a string from the right, accumulating a value starting with init. The
accumulated value is combined with each character in reverse order, using f.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Examples:
"coffee tea water".foldr (fun c n => if c.isWhitespace then n + 1 else n) 0 = 2"coffee tea and water".foldr (fun c n => if c.isWhitespace then n + 1 else n) 0 = 3"coffee tea water".foldr (fun c s => c.push s) "" = "retaw dna aet eeffoc"
Equations
- String.Legacy.foldr f init s = String.Legacy.foldrAux f init s s.rawEndPos 0
Instances For
Auxuliary definition for String.Legacy.any.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks whether there is a character in a string for which the Boolean predicate p returns true.
Short-circuits at the first character for which p returns true.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Examples:
"brown".any (·.isLetter) = true"brown".any (·.isWhitespace) = false"brown and orange".any (·.isLetter) = true"".any (fun _ => false) = false
Equations
- String.Legacy.any s p = String.Legacy.anyAux s s.rawEndPos p 0
Instances For
Checks whether the Boolean predicate p returns true for every character in a string.
Short-circuits at the first character for which p returns false.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Examples:
"brown".all (·.isLetter) = true"brown and orange".all (·.isLetter) = false"".all (fun _ => false) = true
Equations
- String.Legacy.all s p = !String.Legacy.any s fun (c : Char) => !p c
Instances For
Checks whether a string contains the specified character.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Examples:
Equations
- String.Legacy.contains s c = String.Legacy.any s fun (a : Char) => a == c
Instances For
Folds a function over a substring from the left, accumulating a value starting with init. The
accumulated value is combined with each character in order, using f.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas. Its runtime behavior is equivalent to that of Substring.Raw.foldl.
Equations
- Substring.Raw.Legacy.foldl f init { str := s_2, startPos := b, stopPos := e } = String.Legacy.foldlAux f s_2 e b init
Instances For
Folds a function over a substring from the right, accumulating a value starting with init. The
accumulated value is combined with each character in reverse order, using f.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Equations
- Substring.Raw.Legacy.foldr f init { str := s_2, startPos := b, stopPos := e } = String.Legacy.foldrAux f init s_2 e b
Instances For
Checks whether the Boolean predicate p returns true for any character in a substring.
Short-circuits at the first character for which p returns true.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Equations
- Substring.Raw.Legacy.any { str := s_2, startPos := b, stopPos := e } p = String.Legacy.anyAux s_2 e p b
Instances For
Checks whether the Boolean predicate p returns true for every character in a substring.
Short-circuits at the first character for which p returns false.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Equations
- Substring.Raw.Legacy.all s p = !Substring.Raw.Legacy.any s fun (c : Char) => !p c
Instances For
Checks whether a substring contains the specified character.
This is an old implementation, preserved here for users of the lemmas in
Batteries.Data.String.Lemmas.
Equations
- Substring.Raw.Legacy.contains s c = Substring.Raw.Legacy.any s fun (a : Char) => a == c