RosettaCodeData/Task/Variadic-function/EMal/variadic-function.emal

18 lines
788 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
^|EMal supports variadic functions in more than one way|^
2026-04-30 12:34:36 -04:00
fun print ← void by text mode, List args
writeLine("[" + mode + "]")
2023-07-01 11:58:00 -04:00
for each var arg in args do writeLine(arg) end
end
2026-04-30 12:34:36 -04:00
fun printArgumentsList ← void by List args
2023-07-01 11:58:00 -04:00
print("accepting a list", args)
end
2026-04-30 12:34:36 -04:00
fun printArgumentsUnchecked ← void by some var args
2023-07-01 11:58:00 -04:00
print("unchecked variadic", args)
end
2026-04-30 12:34:36 -04:00
fun printArgumentsChecked ← void by text subject, logic isTrue, int howMany, some text values
2023-07-01 11:58:00 -04:00
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")