Functions in Jaf are first-class values that can be stored in variables, passed as arguments, and returned from other functions.
func name(parameter) expression
name - function nameparameter - single parameter nameexpression - function body (can be block)The function itself (can be assigned to variables)
func square(x) x * x print(square(5)) # Output: 25
func factorial(n) {
if (n == 0) {
1
} else {
n * factorial(n - 1)
}
}
print(factorial(5))
# Output: 120
func outer(x) {
func inner(y) x + y
inner(10)
}
print(outer(5))
# Output: 15
func calculate(x) {
y = x * 2
z = y + 10
z / 3
}
print(calculate(5))
# Output: 6.666...
© 2026 elliktronic · Jaf Language