17 lines
788 B
Text
17 lines
788 B
Text
^|EMal supports variadic functions in more than one way|^
|
|
fun print ← void by text mode, List args
|
|
writeLine("[" + mode + "]")
|
|
for each var arg in args do writeLine(arg) end
|
|
end
|
|
fun printArgumentsList ← void by List args
|
|
print("accepting a list", args)
|
|
end
|
|
fun printArgumentsUnchecked ← void by some var args
|
|
print("unchecked variadic", args)
|
|
end
|
|
fun printArgumentsChecked ← void by text subject, logic isTrue, int howMany, some text values
|
|
print("checked variadic", var[subject, isTrue, howMany, +values]) # unary plus on lists does list expansion
|
|
end
|
|
printArgumentsList(var["These are the ", true, 7, "seas", "of", "Rhye"])
|
|
printArgumentsUnchecked("These are the ", true, 7, "seas", "of", "Rhye")
|
|
printArgumentsChecked("These are the ", true, 7, "seas", "of", "Rhye")
|