Пример #1
0
 def test_macro6(self):
     n, act, ntimes = Var('n'), Var('act'), MacroVar('ntimes')
     eq_(
         eval(
             letrec([(ntimes,
                      macro((n, act),
                            if_(eq(n, 0), 1,
                                begin(act, ntimes(sub(n, 1), act)))))],
                    ntimes(3, println(1)))), 1)
Пример #2
0
 def test_macro5(self):
     x, y, f = Const('x'), Const('y'), MacroVar('f')
     eq_(eval(let([(f, macro((x, y), y, x, 1))], f(println(1), prin(2)))),
         1)
Пример #3
0
 def test_macro3(self):
     x, y = Const('x'), Const('y')
     eq_(eval(macro((x, y), y, x, 1)(println(1), prin(2))), 1)
Пример #4
0
 def test_macro6(self):
   n, act, ntimes = Var('n'), Var('act'), MacroVar('ntimes')
   eq_(eval(letrec([(ntimes, macro((n, act), 
                   if_(eq(n, 0), 1, 
                       begin(act, ntimes(sub(n, 1), act)))))], 
                   ntimes(3, println(1)))), 1)
Пример #5
0
 def test_macro5(self):
   x, y, f = Const('x'), Const('y'), MacroVar('f')
   eq_(eval(let([(f, macro((x, y), y, x, 1))], f(println(1), prin(2)))), 1)
Пример #6
0
 def test_macro3(self):
   x, y = Const('x'), Const('y')
   eq_(eval(macro((x, y), y, x, 1)(println(1), prin(2))), 1)