Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
43
Task/Call-a-function/Luck/call-a-function.luck
Normal file
43
Task/Call-a-function/Luck/call-a-function.luck
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* Calling a function that requires no arguments */
|
||||
f();;
|
||||
|
||||
/* Calling a function with a fixed number of arguments */
|
||||
f(1,2);;
|
||||
|
||||
/* Calling a function with optional arguments
|
||||
Note: defining the function is cumbersome but will get easier in future versions. */
|
||||
f(1,2,new {default with x=3, y=4});;
|
||||
|
||||
/* Calling a function with a variable number of arguments */
|
||||
printf("%d %d %d %d":char*,2,3,4,5);;
|
||||
|
||||
/* Calling a function with named arguments
|
||||
Note: may get syntax sugar in future versions */
|
||||
f(1,2,new {default with x=3, y=4});;
|
||||
|
||||
/* Using a function in statement context (what?) */
|
||||
f();f();f();;
|
||||
|
||||
/* Using a function in first-class context within an expression */
|
||||
[1,2,3].map(string);;
|
||||
|
||||
/* Obtaining the return value of a function */
|
||||
let x:int = f();;
|
||||
|
||||
/* Distinguishing built-in functions and user-defined functions */
|
||||
/* Builtin function i.e. custom calling convention: */
|
||||
(@ binop "==" l r);;
|
||||
/* User defined function i.e. normal function */
|
||||
f(l)(r);;
|
||||
|
||||
/* Distinguishing subroutines and functions: both are supported, but compiler is not aware of difference */
|
||||
sub();;
|
||||
fun();;
|
||||
|
||||
/* Stating whether arguments are passed by value or by reference */
|
||||
f(value);; /* by value */
|
||||
f(&value);; /* by pointer reference */
|
||||
f(ref(value));; /* by managed reference */
|
||||
|
||||
/* Is partial application possible and how */
|
||||
tasty_curry(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z);;
|
||||
Loading…
Add table
Add a link
Reference in a new issue