import load, post
-from term import Term, Cons, Nil
+from term import Term, Cons, Nil, MapsTo
from chart import Chart
from utils import ip, red, green, blue, magenta, yellow, parse_attrs, \
ddict, dynac, read_anf, strip_comments, _repr, hide_ugly_filename
return Cons(*args)
if fn == 'nil/0':
return Nil
+ if fn == '->/2':
+ return MapsTo(*args)
if fn == '$key/1':
self.new_fn(fn, '=')
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
#for k,v in x.items():
# c = AList(todyna([k,v]), c)
#return c
- return todyna(x.items())
+ return todyna([MapsTo(k,v) for k,v in x.items()])
elif isinstance(x, (list, tuple)):
c = Nil
def __repr__(self):
"Pretty print a term. Will retrieve the complete (ground) term."
- if self.fn == '->/2':
- return '%s -> %s' % self.args
-
fn = '/'.join(self.fn.split('/')[:-1]) # drop arity from name.
if not self.args:
return fn
Nil = _Nil()
+
+
+class MapsTo(Term):
+ def __init__(self, k, v):
+ super(MapsTo, self).__init__('->/2', (k, v))
+ def __repr__(self):
+ return '%s -> %s' % self.args