Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Binary-strings/Icon/binary-strings-1.icon
Normal file
14
Task/Binary-strings/Icon/binary-strings-1.icon
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
s := "\x00" # strings can contain any value, even nulls
|
||||
s := "abc" # create a string
|
||||
s := &null # destroy a string (garbage collect value of s; set new value to &null)
|
||||
v := s # assignment
|
||||
s == t # expression s equals t
|
||||
s << t # expression s less than t
|
||||
s <<= t # expression s less than or equal to t
|
||||
v := s # strings are immutable, no copying or cloning are needed
|
||||
s == "" # equal empty string
|
||||
*s = 0 # string length is zero
|
||||
s ||:= "a" # append a byte "a" to s via concatenation
|
||||
t := s[2+:3] # t is set to position 2 for 3 characters
|
||||
s := replace(s,s2,s3) # IPL replace function
|
||||
s := s1 || s2 # concatenation (joining) of strings
|
||||
16
Task/Binary-strings/Icon/binary-strings-2.icon
Normal file
16
Task/Binary-strings/Icon/binary-strings-2.icon
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
procedure replace(s1, s2, s3) #: string replacement
|
||||
local result, i
|
||||
|
||||
result := ""
|
||||
i := *s2
|
||||
if i = 0 then fail # would loop on empty string
|
||||
|
||||
s1 ? {
|
||||
while result ||:= tab(find(s2)) do {
|
||||
result ||:= s3
|
||||
move(i)
|
||||
}
|
||||
return result || tab(0)
|
||||
}
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue