A sslicestd/core/sslice/sslice: V represents a sub-slice of string and
has a specific start position and character count. It is used
instead of string indices to make the actual internal representation
of strings abstract (like UTF-8 or UTF-16). String slices are
returned by functions that find sub strings or patterns in
in strings. Use string to
create a fresh substring from a slice.
The start and len fields of a slice are in terms of bytes. Slices should only be interacted with safe methods defined in core that take care to not cut strings in the middle of a utf codepoint.
Apply a function for each character in a string slice.
Apply a function for each character in a string slice.
If action returns Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>, the function returns immediately with that result.
Truncates a slice to length 0.
Inequality based on contents of the slice
O(n+m) where n and m are the lengths of the two strings.
Inequality of slices at the same offset and length on the same string. (The strings do not have to be referentially identical though).
Equality based on contents of the slice
O(n+m) where n and m are the lengths of the two strings.
Equality of slices at the same offset and length on an equal string (The strings do not have to be referentially identical though).
O(count). Advance the start position of a string slice by count characters
up to the end of the string.
A negative count advances the start position backwards upto the first position
in a string.
Maintains the character count of the original slice upto the end of the string.
For example:
"abc".firststd/core/sslice/first: (s : string, n : ? int) -> sslice.advancestd/core/sslice/advance: (slice : sslice, count : int) -> sslice(1).string == "b",
"abc".firststd/core/sslice/first: (s : string, n : ? int) -> sslice.advancestd/core/sslice/advance: (slice : sslice, count : int) -> sslice(3).string == "",
"abc".laststd/core/sslice/last: (s : string, n : ? int) -> sslice.advancestd/core/sslice/advance: (slice : sslice, count : int) -> sslice(-1).string == "b".
O(1). Return the string slice from the end of slicestd/core/sslice/slice: (s : string) -> sslice argument
to the end of the string.
O(1). Return the string slice from the start of a string up to the
start of slicestd/core/sslice/slice: (s : string) -> sslice argument.
Return the common prefix of two strings (upto upto characters (default is minimum length of the two strings)).
O(n). Return the number of characters in a string slice.
Gets a slice that drops the first n characters, shrinking the length of the slice by n accordingly. If the slice does not have n characters, then the slice is shrunk to an empty slice.
If maintaining the length of the slice is important, use advancestd/core/sslice/advance: (slice : sslice, count : int) -> sslice instead.
O(count). Extend a string slice by count characters up to the end of the string.
A negative count shrinks the slice up to the empty slice.
For example:
"abc".firststd/core/sslice/first: (s : string, n : ? int) -> sslice.extendstd/core/sslice/extend: (slice : sslice, count : int) -> sslice(1).string == "ab"
"abc".laststd/core/sslice/last: (s : string, n : ? int) -> sslice.extendstd/core/sslice/extend: (slice : sslice, count : int) -> sslice(-1).string == "".
n). The first n (default = 1) characters in a string.
Is a slice empty?
Is a slice not empty?
Is a slice invalid?
O(n). The last n (default = 1) characters in a string.
If the slice is not empty, return the first character, and a new slice that is advanced by 1.
O(1). The entire string as a slice.
O(n). Copy the slicestd/core/sslice/slice: (s : string) -> sslice argument into a fresh string.
Takes O(1) time if the slice covers the entire string.
Gets up to (end-start) characters from the slice beginning from start.
If either start or end is negative, returns the original slice.
Gets a slice that only includes up to n characters from the start of the slice.
Count the number of times a predicate is true for each character in a string.
Invoke a function for each character in a string.
Invoke a function for each character in a string.
If action returns Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>, the function returns immediately with that result.
Truncate a string to count characters.
Convert the first character of a string to uppercase.
Does string s end with post?
If so, returns a slice of s from the start up to the post string at the end.
O(n). If it occurs, return the position of substring sub in s, tupled with
the position just following the substring sub.
Return the last index of substring sub in s if it occurs.
Return the first character of a string as a string (or the empty string).
Return the first character of a string (or Nothingstd/core/types/Nothing: forall<a> maybe<a> for the empty string).
Is pre a prefix of s? If so, returns a slice
of s following pre up to the end of s.
Return the tail of a string (or the empty string).
Trim off a substring sub while s starts with that string.
Trim off a substring sub while s ends with that string.
Efficient views on strings.
.