Implemented a different way to index clauses

This commit is contained in:
notoria
2020-12-19 14:52:38 +01:00
parent 22ffb1f53f
commit 657e4f12bb
6 changed files with 137 additions and 47 deletions

View File

@@ -339,6 +339,19 @@ impl PredicateClause {
}
}
// TODO: add this to `Term` in `prolog_parser` like `first_arg`.
pub fn args(&self) -> Option<&[Box<Term>]> {
match *self {
PredicateClause::Fact(ref term, ..) => {
match term {
Term::Clause(_, _, args, _) => Some(&args),
_ => None,
}
},
PredicateClause::Rule(ref rule, ..) => Some(&rule.head.1),
}
}
pub fn arity(&self) -> usize {
match self {
&PredicateClause::Fact(ref term, ..) => {