RosettaCodeData/Task/Variadic-function/Arturo/variadic-function.arturo

29 lines
632 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
;-------------------------------------------
; a quasi-variadic function
;-------------------------------------------
variadic: function [args][
2026-02-01 16:33:20 -08:00
loop args 'argv [
print argv
2023-07-01 11:58:00 -04:00
]
]
; calling function with one block param
; and the arguments inside
variadic ["one" 2 "three"]
;-------------------------------------------
; a function with optional attributes
;-------------------------------------------
variable: function [args][
print ["args:" args]
2026-02-01 16:33:20 -08:00
switch attr? "with" [
2023-07-01 11:58:00 -04:00
print ["with:" attr "with"]
2026-02-01 16:33:20 -08:00
][
2023-07-01 11:58:00 -04:00
print "without attributes"
]
]
variable "yes"
variable.with:"something" "yes!"