/** creates a literal from a list with four elements: [namespace, functor, list of terms, list of annots] * (namespace is optional) */ public static Literal NewFromListOfTerms(IListTerm lt) { try { System.Collections.Generic.IEnumerator <ITerm> i = lt.GetEnumerator(); Atom ns = DefaultNS; if (lt.Count == 4) { ns = i.Current as Atom; } ITerm tFunctor = i.Current; bool pos = Literal.LPos; if (tFunctor.IsLiteral() && (tFunctor as Literal).Negated()) { pos = Literal.LNeg; } if (tFunctor.IsString()) { tFunctor = AsSyntax.ParseTerm((tFunctor as IStringTerm).GetString()); } Literal l = new LiteralImpl(ns, pos, (tFunctor as Atom).GetFunctor()); if (i.Current != null) { //l.SetTerms((i.Current as IListTerm).CloneLT()); return(null); } if (i.Current != null) { l.SetAnnots((i.Current as IListTerm).CloneLT()); } return(l); } catch (Exception) { throw new JasonityException("Error creating literal from" + lt); } }
override public object Execute(Reasoner ts, Unifier un, ITerm[] args) { CheckArguments(args); IListTerm list = (IListTerm)args[0]; if (list.Count == 0) { return(false); } IEnumerator <ITerm> i = list.GetEnumerator(); ITerm min = i.Current; while (i.MoveNext()) { ITerm t = i.Current; if (Compare(min, t)) { min = t; } } return(un.Unifies(args[1], (ITerm)min.Clone())); // Como uso el Clone de C# lo que clono son object que luego hay que castear... }