Commits

Pierre Carbonnelle committed 0b82402

miscellaneous

Comments (0)

Files changed (3)

 1.0            1.0           c4             c4
 'a'            'a'           c5             c5
 ('a', X)       ('a', X)      (c5v2)         (c5v1)
-lambda X:..    lambda X:..   l1(v2)         l1(v1)
 X+1            (X+1)         (v2+c1)        (v2+c1)
+lambda X:..    (c1l1v2)      (c1l1v2)       (c1l1v2)
+X[0]           (X[0)         (v2[c2)        (v2[c2)
 p              p/2
 p(X,1)         p/2v2c3       p/2v2c3        p/2v1c3
 p[X]==1        p/2v2c3       p/2v2c3        p/2v1

pyDatalog/pyEngine.py

         return False
     is_constant = False
     def get_tag(self, env): #id
-        env.setdefault(self, 'v%i' % len(env)) # TODO return the result of this statement directly ?
-        return env[self] 
+        return env.setdefault(self, 'v%i' % len(env))
 
     def subst(self, env): #unify
         return env.get(self, self)
     def subst(self, env): #unify
         lhs = self.lhs.subst(env)
         rhs = self.rhs.subst(env)
-        if self.operator == 'slice' and isinstance(lhs, VarTuple) and rhs.is_constant:
+        if self.operator == '[' and isinstance(lhs, VarTuple) and rhs.is_constant:
             if isinstance(rhs, VarTuple):
                 return Interned.of(lhs._id.__getitem__(slice(*rhs.id)))
             return Interned.of(lhs._id.__getitem__(rhs.id))
         """ returns a new literal with '==' instead of comparison """
         return self._renamed(self.pred.name.replace(self.pred.comparison, '=='))
     
-    def __str__(self): return "%s(%s)" % (self.pred.name, ','.join([str(term) for term in self.terms])) 
+    def __str__(self): 
+        return "%s(%s)" % (self.pred.name, ','.join([str(term) for term in self.terms])) 
 
 
 def get_id(literal): #id

pyDatalog/pyParser.py

     def __getitem__(self, keys):
         """ called when evaluating expression[keys] """
         if isinstance(keys, slice):
-            return Operation(self, 'slice', [keys.start, keys.stop, keys.step])
-        return Operation(self, 'slice', keys)
+            return Operation(self, '[', [keys.start, keys.stop, keys.step])
+        return Operation(self, '[', keys)
     
     
 class VarSymbol(Expression):