Anonymous user
Binary strings: Difference between revisions
m
→[[Basic_string_manipulation_functions#ALGOL 68]]: add heap creation, and prepending strings
m (→[[Basic_string_manipulation_functions#ALGOL 68]]: add index substring replacement) |
m (→[[Basic_string_manipulation_functions#ALGOL 68]]: add heap creation, and prepending strings) |
||
Line 28:
b := ();
BEGIN
LOC STRING lb := "
HEAP STRING hb := "hello moon"; # allocate out of the HEAP space #
~
END; # local variable "lb" has
# String assignment #
Line 61 ⟶ 62:
# Append a string to a string #
h +:= "BCD";
h PLUSAB "EFG";
# Prepend a string to a string - because STRING addition isn't communitive #
"789" +=: h;
"456" PLUSTO h;
print(("The result of prepends and appends: ", h, new line));
# Extract a substring from a string #
Line 81 ⟶ 88:
INT offset = 7;
# Replace a character at an
j[offset] := "P";
print(("After replace 7th character: ", j, new line));
# Replace a substring at an
j[offset:offset+3] := "PlAN";
print(("After replace 7:10th characters: ", j, new line));
# Insert a string before an
j := j[:offset-1]+"INSERTED "+j[offset:];
print(("Insert string before 7th character: ", j, new line));
Line 118 ⟶ 125:
g is empty
g is empty
The result of prepends and appends: 456789ABCDEFG
Substring 2:3 of
After replace string: hello planet
After replace 7th character: hello Planet
|