RosettaCodeData/Task/Variadic-function/M2000-Interpreter/variadic-function.m2000

39 lines
1.1 KiB
Plaintext

Module CheckIt {
\\ Works for numbers and strings (letters in M2000)
Function Variadic {
\\ print a letter for each type in function stack
Print Envelope$()
\\Check types using Match
Print Match("NNSNNS")
=stack.size
While not Empty {
if islet then {print letter$} else print number
}
}
M=Variadic(1,2,"Hello",3,4,"Bye")
Print M
\\ K is a poiner to Array
K=(1,2,"Hello 2",3,4,"Bye 2")
\\ !K pass all items to function's stack
M=Variadic(!K)
}
Checkit
Module CheckIt2 {
Function Variadic {
\\ [] return a pointer to stack, and leave a new stack as function's stack
a=[]
\\ a is a pointer to stack
\\ objects just leave a space, and cursor move to next column (spread on lines)
Print a
}
M=Variadic(1,2,"Hello",3,4,"Bye")
Print M
\\ K is a poiner to Array
K=(1,2,"Hello 2",3,4,"Bye 2")
\\ !K pass all items to function stack
M=Variadic(!K)
}
Checkit2