def test_letrec_odd_even(self): from util import n, odd, even eq_( eval( letrec([(odd, lamda([n], if_(eq(n, 0), 0, even(sub(n, 1))))), (even, lamda([n], if_(eq(n, 0), 1, odd(sub(n, 1)))))], odd(3))), 1)
def test_letrec_odd_even(self): from util import n odd, even = MacroVar('odd'), MacroVar('even') eq_( eval( letrec([(odd, macro([n], if_(eq(n, 0), 0, even(sub(n, 1))))), (even, macro([n], if_(eq(n, 0), 1, odd(sub(n, 1)))))], odd(3))), 1)
def test_letrec_odd_even(self): from util import n odd, even = MacroVar('odd'), MacroVar('even') eq_(eval(letrec([(odd, macro([n], if_(eq(n,0), 0, even(sub(n,1))))), (even, macro([n], if_(eq(n,0), 1, odd(sub(n, 1)))))], odd(3))), 1)
def test_letrec_odd_even(self): from util import n, odd, even eq_(eval(letrec([(odd, lamda([n], if_(eq(n,0), 0, even(sub(n,1))))), (even, lamda([n], if_(eq(n,0), 1, odd(sub(n, 1)))))], odd(3))), 1)