September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
10
Task/Call-a-function/Zkl/call-a-function-1.zkl
Normal file
10
Task/Call-a-function/Zkl/call-a-function-1.zkl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
f(); f(1,2,3,4);
|
||||
fcn f(a=1){}() // define and call f, which gets a set to 1
|
||||
fcn{vm.arglist}(1,2,3,4) // arglist is L(1,2,3,4)
|
||||
fcn{a1:=vm.nthArg(1)}(1,2,3) // a1 == 2
|
||||
(f() == True); (f() and 1 or 2)
|
||||
if (f()) println()
|
||||
f(f) // pass f to itself
|
||||
s:=f()
|
||||
fcn{}.isType(self.fcn) //True
|
||||
fcn{}.len.isType(self.fcn) //False, len is a Method
|
||||
10
Task/Call-a-function/Zkl/call-a-function-2.zkl
Normal file
10
Task/Call-a-function/Zkl/call-a-function-2.zkl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
fcn(a,b,c).fp(1)() // call function with a always set to 1
|
||||
fcn(a,b,c).fp1(2,3)() // call function with b & c always set to 2 & 3
|
||||
fcn(a,b,c,d).fpN(3,5)() // call function with d always set to 5
|
||||
fcn{vm.arglist}.fpN(3,66)(1,2,3,4,5) //-->L(1,2,3,66,4,5)
|
||||
fcn{}.fpM("01-",5) // use a mask to select parameters
|
||||
// 1 is supplied, 0 is get upon call, - is chop arglist
|
||||
fcn{vm.arglist}.fpM("01-",66)(1,2,3,4) //-->L(1,66)
|
||||
|
||||
a:=5; f('wrap(b){a+b}) // 'wrap is syntactic sugar for .fpN
|
||||
// to create a lexical closure --> f(fcn(b,a){a+b}.fpN(1,a))
|
||||
Loading…
Add table
Add a link
Reference in a new issue