Documentation

Batteries.Data.String.Legacy

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.

@[irreducible, specialize #[]]
def String.Legacy.mapAux (f : CharChar) (i : Pos.Raw) (s : String) :

Implementation of String.Legacy.map.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[inline]
    def String.Legacy.map (f : CharChar) (s : String) :

    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:

    Equations
    Instances For
      @[inline]

      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
      Instances For
        @[inline]

        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
        Instances For
          @[inline]

          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
          Instances For
            @[inline]

            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
            Instances For
              @[irreducible, specialize #[]]
              def String.Legacy.foldlAux {α : Type u} (f : αCharα) (s : String) (stopPos i : Pos.Raw) (a : α) :
              α

              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
              Instances For
                @[inline]
                def String.Legacy.foldl {α : Type u} (f : αCharα) (init : α) (s : String) :
                α

                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
                Instances For
                  @[inline]

                  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
                    @[inline]

                    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:

                    • "abc".back = 'c'
                    • "".back = (default : Char)
                    Equations
                    Instances For
                      @[irreducible]
                      def String.Legacy.posOfAux (s : String) (c : Char) (stopPos pos : Pos.Raw) :

                      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
                        @[inline]

                        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:

                        • "abcba".posOf 'a' = ⟨0⟩
                        • "abcba".posOf 'z' = ⟨5⟩
                        • "L∃∀N".posOf '∀' = ⟨4⟩
                        Equations
                        Instances For
                          @[irreducible]

                          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
                            @[inline]

                            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
                              @[irreducible]
                              def String.Legacy.findAux (s : String) (p : CharBool) (stopPos pos : Pos.Raw) :

                              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
                                @[inline]

                                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:

                                • "coffee tea water".find (·.isWhitespace) = ⟨6⟩
                                • "tea".find (· == 'X') = ⟨3⟩
                                • "".find (· == 'X') = ⟨0⟩
                                Equations
                                Instances For
                                  @[irreducible]

                                  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
                                    @[inline]

                                    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
                                      @[irreducible, specialize #[]]
                                      def String.Legacy.foldrAux {α : Type u} (f : Charαα) (a : α) (s : String) (i begPos : Pos.Raw) :
                                      α

                                      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
                                        @[inline]
                                        def String.Legacy.foldr {α : Type u} (f : Charαα) (init : α) (s : String) :
                                        α

                                        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
                                        Instances For
                                          @[irreducible, specialize #[]]
                                          def String.Legacy.anyAux (s : String) (stopPos : Pos.Raw) (p : CharBool) (i : Pos.Raw) :

                                          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
                                            @[inline]
                                            def String.Legacy.any (s : String) (p : CharBool) :

                                            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
                                            Instances For
                                              @[inline]
                                              def String.Legacy.all (s : String) (p : CharBool) :

                                              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
                                              Instances For
                                                @[inline]

                                                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
                                                Instances For
                                                  @[inline]
                                                  def Substring.Raw.Legacy.foldl {α : Type u} (f : αCharα) (init : α) (s : Raw) :
                                                  α

                                                  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
                                                  Instances For
                                                    @[inline]
                                                    def Substring.Raw.Legacy.foldr {α : Type u} (f : Charαα) (init : α) (s : Raw) :
                                                    α

                                                    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
                                                    Instances For
                                                      @[inline]

                                                      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
                                                      Instances For
                                                        @[inline]

                                                        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
                                                        Instances For
                                                          @[inline]

                                                          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
                                                          Instances For