Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
10
Task/Call-a-function/Sidef/call-a-function-1.sidef
Normal file
10
Task/Call-a-function/Sidef/call-a-function-1.sidef
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
foo(); # without arguments
|
||||
foo(1, 2); # with two arguments
|
||||
foo(args...); # with a variable number of arguments
|
||||
foo(name: 'Bar', age: 42); # with named arguments
|
||||
|
||||
var f = foo; # store the function foo inside 'f'
|
||||
var result = f(); # obtain the return value of a function
|
||||
|
||||
var arr = [1,2,3];
|
||||
foo(arr); # the arguments are passed by object-reference
|
||||
12
Task/Call-a-function/Sidef/call-a-function-2.sidef
Normal file
12
Task/Call-a-function/Sidef/call-a-function-2.sidef
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
func curry(f, *args1) {
|
||||
func (*args2) {
|
||||
f(args1..., args2...);
|
||||
}
|
||||
}
|
||||
|
||||
func add(a, b) {
|
||||
a + b
|
||||
}
|
||||
|
||||
var adder = curry(add, 1);
|
||||
say adder(3); #=>4
|
||||
Loading…
Add table
Add a link
Reference in a new issue