-- main.mcl --
import "fmt"

# recursive function (not supported!)
$sum = func($i) {
	if $i < 0 {
		-1 * $sum(-1 * $i)
	} else {
		if $i == 0 {
			0 # terminate recursion
		} else {
			$i + $sum($i - 1)
		}
	}
}

$out1 = $sum(4) # 4 + 3 + 2 + 1 + 0 = 10
$out2 = $sum(-5) # -5 + -4 + -3 + -2 + -1 + -0 = -15

test fmt.printf("sum(4) is %d", $out1) {}
test fmt.printf("sum(-5) is %d", $out2) {}
-- OUTPUT --
# err: errSetScope: recursive reference while setting scope: not a dag
