def get_var_types_(lit): var_types = [] if isinstance(lit,structs.Literal): var_types = ['%s(%s)'%(functs.de_sign(lit.terms_types_map[key]),key) for key in lit.terms_types_map ] elif isinstance(lit,list): _var_types = flatten([['%s(%s)'%(functs.de_sign(_lit.terms_types_map[key]),key) for key in _lit.terms_types_map ] for _lit in lit]) var_types = set(_var_types) else: msg = 'You can ask for the types of variables of a Literal or a list of Literals. You asked for %s'%(lit) raise excps.VariableTypesException(msg,gl.logger) return list(var_types)
def get_var_types_(self): lit = [self.head] lit.extend(self.body) var_types = [] if isinstance(lit,Literal): var_types = ['%s(%s)'%(functs.de_sign(lit.terms_types_map[key]),key) for key in lit.terms_types_map ] elif isinstance(lit,list): _var_types = flatten([['%s(%s)'%(functs.de_sign(_lit.terms_types_map[key]),key) for key in _lit.terms_types_map ] for _lit in lit]) var_types = set(_var_types) else: msg = 'You can ask for the types of variables of a Literal or a list of Literals. You asked for %s'%(lit) raise excps.VariableTypesException(msg,self.globvals.logger) # return list(var_types) l = list(var_types) b = [x.as_string for x in self.body] b.extend(l) bstr = ' '+self.printout.join(b) t = '%s :- \n %s.'%(self.head.as_string,bstr) return t