Example #1
0
 def test_kleene1(self):
   f, item, kleene = Var('f'), Var('item'), Var('kleene')
   fun = macro(((item,),  
                        letr([(f,macro(((), eval_(item), f()),
                                        ((), nullword)))], 
                             f())))
   eq_(eval(let([(kleene,fun)], set_text('aa'), kleene(char('a')))), True)
Example #2
0
 def test_kleene2(self):
   f, pred, kleene = Var('f'), Var('pred'), Var('kleene')
   fun = macro(((pred,),  
                        letr([(f,macro( ((x,), pred(x), f(x)),
                                         ((x,), nullword)))], 
                             f(x))))
   eq_(eval(let([(kleene,fun)], set_text('ab'), kleene(char))), True)
Example #3
0
 def test_kleene1(self):
     f, item, kleene = Var('f'), Var('item'), Var('kleene')
     fun = macro(((item, ),
                  letr([(f, macro(((), eval_(item), f()), ((), nullword)))],
                       f())))
     eq_(eval(let([(kleene, fun)], set_text('aa'), kleene(char('a')))),
         True)
Example #4
0
 def test_kleene2(self):
     f, pred, kleene = Var('f'), Var('pred'), Var('kleene')
     fun = macro(((pred, ),
                  letr([(f, macro(((x, ), pred(x), f(x)),
                                  ((x, ), nullword)))], f(x))))
     eq_(eval(let([(kleene, fun)], set_text('ab'), kleene(char))), True)
Example #5
0
 def test_closure4(self):
   eq_(eval(let([(f, macro([[x], x])),
                 (x, 1)],
            f(x+x))), 2) 
Example #6
0
 def test4(self):
   eq_(eval(macro([[x], x])(prin(1))), None) 
Example #7
0
 def test_closure2(self):
   eq_(eval(let([(f, macro([[x], prin(x)])),
                 (x, 1)],
            f(x+x))), None) 
Example #8
0
 def test_or_p(self):
   eq_(eval(macro([[x, y], x],
                  [[x, y],y])(prin(1), prin(2))), None) 
Example #9
0
 def test_eval(self):
   eq_(eval(macro([[x, y], eval_(x)],
                  [[x, y],eval_(y)])(prin(1), prin(2))), None) 
Example #10
0
 def test1(self):
   eq_(eval(macro([[], prin(1)])()), None) 
Example #11
0
 def testembedvar2(self):
   e, e2, f, g, h = Var('e'), Var('e2'), Var('f'), Var('g'), Var('h')
   eq_(eval(letr([(f, macro([[cons(1, e2)], g(e2)])),
                    (g, function([[e], h(e)])),
                    (h, function([[1], True]))],
               f(e), e)), cons(1, 1))