Documentation

Init.Data.String.Slice.Basic

@[instance_reducible]
Equations
def String.Slice.beq (s1 s2 : Slice) :

Checks whether s1 and s2 represent the same string, even if they are slices of different base strings or different slices within the same string.

The implementation is an efficient equivalent of s1.copy == s2.copy

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[instance_reducible]
    Equations

    Creates a String from a String.Slice by copying the bytes.

    Equations
    Instances For
      @[extern lean_slice_hash]
      Equations
      Instances For

        Checks whether s is lexicographically smaller than t.

        The implementation is an efficient equivalent of decide (s.copy < t.copy).

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[instance_reducible]
          Equations

          Compares s and t lexicographically.

          The implementation is an efficient equivalent of compare s.copy t.copy.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            @[instance_reducible]
            Equations
            @[instance_reducible]
            Equations
            @[instance_reducible]
            Equations
            @[inline]
            def String.Slice.drop (s : Slice) (n : Nat) :

            Removes the specified number of characters (Unicode code points) from the start of the slice.

            If n is greater than the amount of characters in s, returns an empty slice.

            Examples:

            • "red green blue".toSlice.drop 4 == "green blue".toSlice

            • "red green blue".toSlice.drop 10 == "blue".toSlice

            • "red green blue".toSlice.drop 50 == "".toSlice

            Equations
            Instances For
              @[inline]
              def String.Slice.take (s : Slice) (n : Nat) :

              Creates a new slice that contains the first n characters (Unicode code points) of s.

              If n is greater than the amount of characters in s, returns s.

              Examples:

              • "red green blue".toSlice.take 3 == "red".toSlice

              • "red green blue".toSlice.take 1 == "r".toSlice

              • "red green blue".toSlice.take 0 == "".toSlice

              • "red green blue".toSlice.take 100 == "red green blue".toSlice

              Equations
              Instances For
                @[inline]

                Removes the specified number of characters (Unicode code points) from the end of the slice.

                If n is greater than the amount of characters in s, returns an empty slice.

                Examples:

                • "red green blue".toSlice.dropEnd 5 == "red green".toSlice

                • "red green blue".toSlice.dropEnd 11 == "red".toSlice

                • "red green blue".toSlice.dropEnd 50 == "".toSlice

                Equations
                Instances For
                  @[inline]

                  Creates a new slice that contains the last n characters (Unicode code points) of s.

                  If n is greater than the amount of characters in s, returns s.

                  Examples:

                  • "red green blue".toSlice.takeEnd 4 == "blue".toSlice

                  • "red green blue".toSlice.takeEnd 1 == "e".toSlice

                  • "red green blue".toSlice.takeEnd 0 == "".toSlice

                  • "red green blue".toSlice.takeEnd 100 == "red green blue".toSlice

                  Equations
                  Instances For

                    Checks whether s1 == s2 if ASCII upper/lowercase are ignored.

                    Equations
                    Instances For
                      @[inline]

                      Returns the first character in s. If s is empty, returns none.

                      Examples:

                      Equations
                      Instances For
                        @[inline]

                        Returns the first character in s. If s is empty, returns (default : Char).

                        Examples:

                        • "abc".toSlice.front = 'a'

                        • "".toSlice.front = (default : Char)

                        Equations
                        Instances For
                          @[inline]

                          Returns the last character in s. If s is empty, returns none.

                          Examples:

                          • "abc".toSlice.back? = some 'c'

                          • "".toSlice.back? = none

                          Equations
                          Instances For
                            @[inline]

                            Returns the last character in s. If s is empty, returns (default : Char).

                            Examples:

                            • "abc".toSlice.back = 'c'

                            • "".toSlice.back = (default : Char)

                            Equations
                            Instances For

                              Appends the slices in a list of slices, placing the separator s between each pair.

                              Examples:

                              • ", ".toSlice.intercalate ["red".toSlice, "green".toSlice, "blue".toSlice] = "red, green, blue"

                              • " and ".toSlice.intercalate ["tea".toSlice, "coffee".toSlice] = "tea and coffee"

                              • " | ".toSlice.intercalate ["M".toSlice, "".toSlice, "N".toSlice] = "M | | N"

                              Equations
                              Instances For

                                Appends all the slices in a list of slices, in order.

                                Use String.Slice.intercalate to place a separator string between the strings in a list.

                                Examples:

                                Equations
                                Instances For

                                  Converts a string to the Lean compiler's representation of names. The resulting name is hierarchical, and the string is split at the dots ('.').

                                  "a.b".toSlice.toName is the name a.b, not «a.b». For the latter, use Name.mkSimple.

                                  Equations
                                  Instances For
                                    @[instance_reducible]
                                    Equations