Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -1,13 +1,13 @@
|
|||
fun task = void by text about, fun code
|
||||
writeLine(0U00b7 + " " + about)
|
||||
fun task ← void by text about, fun code
|
||||
writeLine(0U00b7, " ", about)
|
||||
code()
|
||||
end
|
||||
fun answer = void by var message do writeLine(" " + message) end
|
||||
fun answer ← void by var message do writeLine(" ", message) end
|
||||
# few definitions
|
||||
fun noArgumentsFunction = int by block do return 97 end
|
||||
fun fixedArgumentsFunction = void by var a, var b do end
|
||||
fun variadicFunction = void by text a, some var values do end
|
||||
fun funArgumentFunction = var by fun f, var b do return f() + b end
|
||||
fun noArgumentsFunction ← int by block do return 97 end
|
||||
fun fixedArgumentsFunction ← void by var a, var b do end
|
||||
fun variadicFunction ← void by text a, some var values do end
|
||||
fun funArgumentFunction ← var by fun f, var b do return f() + b end
|
||||
task("Calling a function that requires no arguments", void by block
|
||||
answer("Is supported.")
|
||||
noArgumentsFunction()
|
||||
|
|
@ -38,7 +38,7 @@ task("Using a function in first-class context within an expression", void by blo
|
|||
end)
|
||||
task("Obtaining the return value of a function", void by block
|
||||
answer("Is supported.")
|
||||
int value = noArgumentsFunction()
|
||||
int value ← noArgumentsFunction()
|
||||
answer(value)
|
||||
end)
|
||||
task("Distinguishing built-in functions and user-defined functions", void by block
|
||||
|
|
@ -57,23 +57,23 @@ task("Is partial application possible and how", void by block
|
|||
| https://web.archive.org/web/20161023205431/http://www.uncarved.com/articles/not_curryin
|
||||
|^
|
||||
# Partial applying
|
||||
fun add = int by int a, int b do return a + b end
|
||||
fun partial = fun by fun f, int a
|
||||
fun add ← int by int a, int b do return a + b end
|
||||
fun partial ← fun by fun f, int a
|
||||
return int by int b
|
||||
return add(a, b)
|
||||
end
|
||||
end
|
||||
fun add7 = partial(add, 7)
|
||||
fun add7 ← partial(add, 7)
|
||||
answer(add(7, 5))
|
||||
answer(add7(5))
|
||||
# Currying
|
||||
fun addN = fun by int n
|
||||
fun addN ← fun by int n
|
||||
return int by int x
|
||||
return x + n
|
||||
end
|
||||
end
|
||||
fun plus = int by int a, int b
|
||||
fun addA = addN(a)
|
||||
fun plus ← int by int a, int b
|
||||
fun addA ← addN(a)
|
||||
return addA(b)
|
||||
end
|
||||
answer(plus(7, 5))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue