Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Call-a-function/Icon/call-a-function.icon
Normal file
30
Task/Call-a-function/Icon/call-a-function.icon
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
procedure main() # demonstrate and describe function calling syntax and semantics
|
||||
|
||||
# normal procedure/function calling
|
||||
|
||||
f() # no arguments, also command context
|
||||
f(x) # fixed number of arguments
|
||||
f(x,h,w) # variable number of arguments (varargs)
|
||||
y := f(x) # Obtaining the returned value of a function
|
||||
|
||||
# procedures as first class values and string invocation
|
||||
|
||||
f!L # Alternate calling syntax using a list as args
|
||||
(if \x then f else g)() # call (f or g)()
|
||||
f := write # assign a procedure
|
||||
f("Write is now called") # ... and call it
|
||||
"f"() # string invocation, procedure
|
||||
"-"(1) # string invocation, operator
|
||||
|
||||
# Co-expressions
|
||||
|
||||
f{e1,e2} # parallel evaluation co-expression call
|
||||
# equivalent to f([create e1, create e2])
|
||||
expr @ coexp # transmission of a single value to a coexpression
|
||||
[e1,e2]@coexp # ... of multiple values (list) to a coexpression
|
||||
coexp(e1,e2) # ... same as above but only in Unicon
|
||||
|
||||
# Other
|
||||
|
||||
f("x:=",1,"y:=",2) # named parameters (user defined)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue