fix strsplit, fix a few loops

This commit is contained in:
Daniella / Tove 2022-02-05 22:35:14 +01:00
parent d3913cdc0b
commit 1ac0d7f0aa

View file

@ -150,8 +150,8 @@ func acopy {
=arr2
=arr1
0 =i
while (i len lt) (i 1 + =i) {
1 neg =i
while (i 1 + =i) (i len lt) {
arr2 i idx2 + (arr1 i idx1 + aget) aput
}
}
@ -174,27 +174,33 @@ func strsplit {
_string =str
_string =splitter
0 =i
0 =j
1 neg =i
"" 0 anew =sequences
while (i str alen lt) (i 1 + =1) {
while (i 1 + =1) (i str alen lt) {
str i aget =chr
splitter 0 aget =spl
while (chr spl eq) (j 1 + =j) {
"" =sequence
1 neg =j
while (j 1 + =j) (chr spl eq) {
(str i j + aget) (splitter j aget) eq not if {
sequences =oldsq
"" (seq dup =lseq 1 + dup =seq) anew =sequences
"" (sequences alen dup =seq 1 +) anew =sequences
oldsq sequences 0 0 oldsq alen acopy
sequences lseq
sequences seq sequence aput
}
else {
sequence chr strconcat =sequence
}
}
}
sequences
}
func puts {
_string =str
0 =i
while (i str alen lt) (i 1 + =i) {
1 neg =i
while (i 1 + =i) (i str alen lt) {
str i aget putchar
}
}