Modification operations on strings #
This file contains operations on strings which modify the string, like set or map.
There will usually not be a String.Slice version of these operations.
Replaces the character at a specified position in a string with a new character.
If both the replacement character and the replaced character are 7-bit ASCII characters and the string is not shared, then it is updated in-place and not copied.
Examples:
("abc".pos ⟨1⟩ (by decide)).set 'B' (by decide) = "aBc"("L∃∀N".pos ⟨4⟩ (by decide)).set 'X' (by decide) = "L∃XN"
Equations
Instances For
Given a valid position in a string, obtain the corresponding position after setting a character on that string, provided that the position was before the changed position.
Equations
Instances For
Replaces the character at position p in the string s with the result of applying f to that
character.
If both the replacement character and the replaced character are 7-bit ASCII characters and the string is not shared, then it is updated in-place and not copied.
Examples:
("abc".pos ⟨1⟩ (by decide)).modify Char.toUpper (by decide) = "aBc"
Equations
Instances For
Given a valid position in a string, obtain the corresponding position after modifying a character in that string, provided that the position was before the changed position.
Equations
Instances For
Replaces the character at a specified position in a string with a new character. If the position is invalid, the string is returned unchanged.
If both the replacement character and the replaced character are 7-bit ASCII characters and the string is not shared, then it is updated in-place and not copied.
This is a legacy function. The recommended alternative is String.Pos.set, combined with
String.pos or another means of obtaining a String.Pos.
Examples:
"abc".set ⟨1⟩ 'B' = "aBc""abc".set ⟨3⟩ 'D' = "abc""L∃∀N".set ⟨4⟩ 'X' = "L∃XN""L∃∀N".set ⟨2⟩ 'X' = "L∃∀N"because'∃'is a multi-byte character, so the byte index2is an invalid position.
Equations
Instances For
Replaces the character at position p in the string s with the result of applying f to that
character. If p is an invalid position, the string is returned unchanged.
If both the replacement character and the replaced character are 7-bit ASCII characters and the string is not shared, then it is updated in-place and not copied.
This is a legacy function. The recommended alternative is String.Pos.set, combined with
String.pos or another means of obtaining a String.Pos.
Examples:
"abc".modify ⟨1⟩ Char.toUpper = "aBc""abc".modify ⟨3⟩ Char.toUpper = "abc"
Equations
Instances For
Replaces the character at position p in the string s with the result of applying f to that
character. If p is an invalid position, the string is returned unchanged.
If both the replacement character and the replaced character are 7-bit ASCII characters and the string is not shared, then it is updated in-place and not copied.
This is a legacy function. The recommended alternative is String.Pos.set, combined with
String.pos or another means of obtaining a String.Pos.
Examples:
"abc".modify ⟨1⟩ Char.toUpper = "aBc""abc".modify ⟨3⟩ Char.toUpper = "abc"
Equations
Instances For
Applies the function f to every character in a string, returning a string that contains the
resulting characters.
Examples:
"abc123".map Char.toUpper = "ABC123""".map Char.toUpper = ""
Equations
Instances For
Replaces each character in s with the result of applying Char.toUpper to it.
Char.toUpper has no effect on characters outside of the range 'a'–'z'.
Examples:
Equations
Instances For
Replaces each character in s with the result of applying Char.toLower to it.
Char.toLower has no effect on characters outside of the range 'A'–'Z'.
Examples:
Equations
Instances For
Replaces the first character in s with the result of applying Char.toUpper to it. Returns the
empty string if the string is empty.
Char.toUpper has no effect on characters outside of the range 'a'–'z'.
Examples:
"orange".capitalize = "Orange""ORANGE".capitalize = "ORANGE""".capitalize = ""
Equations
Instances For
Equations
Instances For
Replaces the first character in s with the result of applying Char.toLower to it. Returns the
empty string if the string is empty.
Char.toLower has no effect on characters outside of the range 'A'–'Z'.
Examples:
"Orange".decapitalize = "orange""ORANGE".decapitalize = "oRANGE""".decapitalize = ""