Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
29
Task/Multisplit/M2000-Interpreter/multisplit.m2000
Normal file
29
Task/Multisplit/M2000-Interpreter/multisplit.m2000
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
Module CheckIt {
|
||||
DIM sep$()
|
||||
sep$() = ("==", "!=", "=")
|
||||
PRINT "String splits into:"
|
||||
FNmultisplit("a!===b=!=c", sep$(), FALSE)
|
||||
PRINT "For extra credit:"
|
||||
FNmultisplit("a!===b=!=c", sep$(), TRUE)
|
||||
END
|
||||
|
||||
SUB FNmultisplit(s$, d$(), info%)
|
||||
LOCAL d%, i%, j%, m%, p%, o$
|
||||
p% = 1
|
||||
REPEAT {
|
||||
m% = LEN(s$)
|
||||
FOR i% = 0 TO DIMENSION(d$(),1)-1
|
||||
d% = INSTR(s$, d$(i%), p%)
|
||||
IF d% THEN IF d% < m% THEN m% = d% : j% = i%
|
||||
NEXT I%
|
||||
IF m% < LEN(s$) THEN {
|
||||
o$ += """" + MID$(s$, p%, m%-p%) + """"
|
||||
IF info% THEN {o$ += " (" + d$(j%) + ") "} ELSE o$ += ", "
|
||||
p% = m% + LEN(d$(j%))
|
||||
}
|
||||
|
||||
} UNTIL m% = LEN(s$)
|
||||
PRINT o$ + """" + MID$(s$, p%) + """"
|
||||
END SUB
|
||||
}
|
||||
CheckIt
|
||||
Loading…
Add table
Add a link
Reference in a new issue