Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
36
Task/Call-a-function/Arturo/call-a-function.arturo
Normal file
36
Task/Call-a-function/Arturo/call-a-function.arturo
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
printHello: $[][
|
||||
print "Hello World!"
|
||||
]
|
||||
|
||||
sayHello: $[name][
|
||||
print ["Hello" name "!"]
|
||||
]
|
||||
|
||||
printAll: $[args][
|
||||
loop args [arg][
|
||||
print arg
|
||||
]
|
||||
]
|
||||
|
||||
getNumber: $[][3]
|
||||
|
||||
; Calling a function that requires no arguments
|
||||
printHello
|
||||
|
||||
; Calling a function with a fixed number of arguments
|
||||
sayHello "John"
|
||||
|
||||
; Calling a function with a variable number of arguments
|
||||
printAll ["one" "two" "three"]
|
||||
|
||||
; Using a function in statement context
|
||||
if true [printHello]
|
||||
print getNumber
|
||||
|
||||
; Using a function in first-class context within an expression
|
||||
if getNumber=3 [print "yep, it worked"]
|
||||
|
||||
; Obtaining the return value of a function:
|
||||
num: getNumber
|
||||
|
||||
print num
|
||||
Loading…
Add table
Add a link
Reference in a new issue