1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#
# Nested curried functions
#
curry.f(x) =
private.x = $x
curry.g(y) =
private.y = $y
curry.h(z) =
add($x, $y, $z)
errors = false
# Partial applications are not allowed
try
i = $(f 0)
eprintln($"Error: partial application f(0) was allowed, result $i")
errors = true
export
default
println($"f(0) failed [SUCCESS]")
# Supposed to fail
# Should take 3 arguments exactly
i = $(f 10, 20, 30)
if $(not $(equal $i, 60))
eprintln($"f(10, 20, 30) evaluates to $i, expected 60 [ERROR]")
errors = true
export
else
println($"f(10, 20, 30) = 60 [SUCCESS]")
if $(errors)
exit 1
|