This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View 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

View file

@ -0,0 +1,2 @@
verb noun
noun verb noun

View file

@ -0,0 +1 @@
f 1; 2; 3; 4; <5

View file

@ -0,0 +1 @@
f 1; 2; 3; 4; 5

View file

@ -0,0 +1 @@
f 'george';'tom';'howard'

View file

@ -0,0 +1 @@
1 2 3 f 'george';'tom';'howard'

View file

@ -0,0 +1,6 @@
obj=: conew'blank'
george__obj=: 1
tom__obj=: 2
howard__obj=: 3
f obj
coerase obj

View file

@ -0,0 +1 @@
f 'george';1;'tom';2;'howard';3

View file

@ -0,0 +1 @@
f ('george';1),('tom';2),:(howard';3)

View file

@ -0,0 +1 @@
f ('george';1);('tom';2);<howard';3

View file

@ -0,0 +1 @@
1 + f 2

View file

@ -0,0 +1 @@
function argumentList

View file

@ -0,0 +1 @@
sum(1,2,3)

View file

@ -0,0 +1 @@
f''

View file

@ -0,0 +1 @@
f 'one argument'

View file

@ -0,0 +1 @@
'this example has two arguments' f 'the other argument'

View file

@ -0,0 +1 @@
f 1,2,3,4,5

View file

@ -0,0 +1 @@
f (<1),(<2),(<3),(<4),(<5)

View file

@ -0,0 +1 @@
f (<1),(<2),(<3),(<4),<5

View file

@ -0,0 +1 @@
f[]

View file

@ -0,0 +1 @@
f[1,2]

View file

@ -0,0 +1 @@
f[1,Option1->True]

View file

@ -0,0 +1,2 @@
f[1,Option1->True]
f[1,Option1->True,Option2->False]

View file

@ -0,0 +1 @@
f[Option1->True,Option2->False]

View file

@ -0,0 +1 @@
f[1,2];f[2,3]

View file

@ -0,0 +1 @@
(#^2)&[3];