Re: [tutorial] Basic Sequence Operations
- Posted by petelomax Jan 23, 2019
- 1513 views
_tom said...
You can assign items of a sequence to a slice of the same length:
or of any length in phix, eg:
string s = "fed" s[2..2] = "easte" -- "e"->"easte", or --s[2..1] = "east" -- ie "f" & x & "ed" --s[3..2] = "aste" -- ie "fe" & x & "d" ?s -- s is now "feasted" -- the two alternatives insert/replace an empty slice s[2..6] = "e" -- "easte" -> "e" --s[2..5] = "" -- or "east" -> "" --s[3..6] = "" -- or "aste" -> "" ?s --s is now "fed"