Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
20
Task/Extend-your-language/ArkScript/extend-your-language.ark
Normal file
20
Task/Extend-your-language/ArkScript/extend-your-language.ark
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
(macro if2 (conds bothConditionsAreTrue firstConditionIsTrue secondConditionIsTrue noConditionIsTrue) {
|
||||
# Assuming 'conds' is a node with at least 2 subnodes.
|
||||
# Get its content and evaluate it once, to be able to
|
||||
# refer to it without reevaluating the conditions
|
||||
(let result1 (head conds))
|
||||
(let result2 (@ conds 1))
|
||||
|
||||
(if (and result1 result2)
|
||||
bothConditionsAreTrue
|
||||
(if result1
|
||||
firstConditionIsTrue
|
||||
(if result2
|
||||
secondConditionIsTrue
|
||||
noConditionIsTrue)))})
|
||||
|
||||
(if2 (true false)
|
||||
(print "1")
|
||||
(print "2")
|
||||
(print "3")
|
||||
(print "4"))
|
||||
28
Task/Extend-your-language/Koka/extend-your-language.koka
Normal file
28
Task/Extend-your-language/Koka/extend-your-language.koka
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
fun if4(cond1: bool, cond2: bool, both: () -> e a, first: () -> e a, second: () -> e a, none: () -> e a): e a
|
||||
if (cond1 && cond2) then both()
|
||||
elif cond1 then first()
|
||||
elif cond2 then second()
|
||||
else none()
|
||||
|
||||
fun test(first, second)
|
||||
if4(first, second) { // Both
|
||||
println("Both conditions are true")
|
||||
} { // First
|
||||
println("Only the first condition is true")
|
||||
} { // Second
|
||||
println("Only the second condition is true")
|
||||
} { // None
|
||||
println("No conditions are true")
|
||||
}
|
||||
|
||||
match (first, second)
|
||||
(True, True) -> println("Both conditions are true")
|
||||
(True, False) -> println("Only the first condition is true")
|
||||
(False, True) -> println("Only the second condition is true")
|
||||
(False, False) -> println("No conditions are true")
|
||||
|
||||
fun main()
|
||||
test(True, True) // Both
|
||||
test(True, False) // First
|
||||
test(False, True) // Second
|
||||
test(False, False) // None
|
||||
Loading…
Add table
Add a link
Reference in a new issue