-> case is of
[x,y] | isFree x && isGround y
-> let
-- call _ vs = "iter_cons" <> (parens $ sepBy comma $ mpv vs) <> colon -- for some reason on colon get put at the end of this line.
++ call _ vs = "iter_cons" <> (parens $ sepBy comma $ mpv vs) <> colon
cdop = [OPIter x [y] "iter" DetNon (Just $ PDBS call)]
cmod = [(x^.mv_var, nuniv)]
in if isFree o
go ("split",_) = Just $ PDBS $ call "split" []
go ("float",_) = Just $ PDBS $ call "float" []
go ("int",_) = Just $ PDBS $ call "int" []
- go ("pycall",_) = Just $ PDBS $ call "pycall" []
-
go ("range",_) = Just $ PDBS $ call "range" []
- go ("in",2) = Just $ PDBS $ call "in_list" []
-
- go ("<=",2) = Just $ PDBS $ infixOp "<="
- go ("<",2) = Just $ PDBS $ infixOp "<"
- go ("=",2) = Just $ PDBS $ call "equals" []
- go ("==",2) = Just $ PDBS $ call "equals" []
- go (">=",2) = Just $ PDBS $ infixOp ">="
- go (">",2) = Just $ PDBS $ infixOp ">"
- go ("!=",2) = Just $ PDBS $ infixOp "!="
+ go ("<=",2) = Just $ PDBS $ call "lte" []
+ go ("<",2) = Just $ PDBS $ call "lt" []
+ go ("=",2) = Just $ PDBS $ call "eq" []
+ go ("==",2) = Just $ PDBS $ call "eq" []
+ go (">=",2) = Just $ PDBS $ call "gte" []
+ go (">",2) = Just $ PDBS $ call "gt" []
+ go ("!=",2) = Just $ PDBS $ call "not_eq" []
- go ("and",2) = Just $ PDBS $ infixOp "and"
- go ("or",2) = Just $ PDBS $ infixOp "or"
+ go ("|",2) = Just $ PDBS $ call "or_" []
+ go ("&",2) = Just $ PDBS $ call "and_" []
+ go ("!",1) = Just $ PDBS $ call "not_" []
- go ("true",0) = Just $ PDBS $ nullary "true"
- go ("false",0) = Just $ PDBS $ nullary "false"
- go ("null",0) = Just $ PDBS $ nullary "None" -- XXX
+ go ("null",0) = Just $ PDBS $ nullary "null"
- go ("!",1) = Just $ PDBS $ call "not" []
- go ("not",1) = Just $ PDBS $ call "not" []
-
- go ("eval",1) = Just $ PDBS $ call "None;exec " []
- go ("tuple",_) = Just $ PDBS $ call "" []
+ --go ("eval",1) = Just $ PDBS $ call "None;exec " []
+ --go ("tuple",_) = Just $ PDBS $ call "" []
+ go ("in",2) = Just $ PDBS $ call "in_list" []
go ("nil",0) = Just $ PDBS $ call "build" ["nil/0"]
go ("cons",2) = Just $ PDBS $ call "build" ["cons/2"]
import re
-from term import Term, Cons, Nil
+from term import Term, Cons, Nil, MapsTo
from collections import Counter
-from utils import pretty, pretty_print
-
-
+from utils import pretty, pretty_print, true, false, null, isbool
from math import log, exp, sqrt
from random import random as _random
-def uniform(a=0, b=1):
- return _random() * (b - a) + a
- def uniform(a=0, b=1):
- return _random() * (b - a) + a
-
-def equals(x,y):
+def or_(x, y):
+ if not (isbool(x) and isbool(y)):
+ raise TypeError('')
+ return todyna(x or y)
+
+def and_(x, y):
+ if not (isbool(x) and isbool(y)):
+ raise TypeError('')
+ return todyna(x and y)
+
+def not_(x):
+ if not isbool(x):
+ raise TypeError('')
+ if x:
+ return false
+ else:
+ return true
+
+def gt(x, y):
+ return todyna(x > y)
+
+def gte(x, y):
+ return todyna(x >= y)
+
+def lt(x, y):
+ return todyna(x < y)
+
+def lte(x, y):
+ return todyna(x <= y)
+
+def eq(x,y):
"""
My work around for discrepency in bool equality True==1 and False==0.
def read_lines(filename):
with file(filename) as f:
return f.readlines()
++
++def uniform(a=0, b=1):
++ return _random() * (b - a) + a