def get_atom(self): """An `Atom` object representing this term, if it is a prolog atom.""" a = atom_t() self._require_success_expecting_type( PL_get_atom(self._handle, byref(a)), 'atom') return Atom._from_handle(a.value)
def get_info(self): """Returns name, arity, and module of this predicate. Returns: Predicate.Info: """ name = atom_t() arity = c_int() module = module_t() PL_predicate_info(self._handle, byref(name), byref(arity), byref(module)) return self.Info(name=Atom._from_handle(name.value), arity=arity.value, module=Module._from_handle(module.value))
def get_compound_name_arity(self): """The name and arity of this term, if it is a compound term. The same as `get_name_arity` but fails for atoms. Returns: NameArity: Named tuple of name (`string`) and arity (`int`). """ name = atom_t() arity = c_int() self._require_success_expecting_type( PL_get_compound_name_arity(self._handle, byref(name), byref(arity)), 'compound term') return self.NameArity(name=Atom._from_handle(name.value), arity=arity.value)
def get_name_arity(self): """The name and arity of this term, if it is a compound term or an atom. Compound terms with arity 0 give the same result as an atom. To distinguish them use `is_compound` and/or `get_compound_name_arity`. Returns: NameArity: namedtuple (name, arity) """ name = atom_t() arity = c_int() self._require_success_expecting_type( PL_get_name_arity(self._handle, byref(name), byref(arity)), 'compound term', 'atom') return self.NameArity(name=Atom._from_handle(name.value), arity=arity.value)