Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 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)