Ejemplo n.º 1
0
 public override bool Equals(object o)
 {
     if (o == this)
     {
         return(true);
     }
     if (o != null && (o.GetType() == typeof(PredicateIndicator)) &&
         (o.GetHashCode() == this.GetHashCode()))
     {
         PredicateIndicator pi = o as PredicateIndicator;
         return(arity == pi.arity && functor.Equals(pi.functor) && ns.Equals(pi.ns));
     }
     return(false);
 }
Ejemplo n.º 2
0
 public static object TermToObject(ITerm t)
 {
     if (t.IsAtom())
     {
         Atom t2 = (Atom)t;
         if (t2.Equals(Literal.LTrue))
         {
             return(true); //?? Boolean.TRUE
         }
         else if (t2.Equals(Literal.LFalse))
         {
             return(false); //?? Boolean.FALSE
         }
         else
         {
             return(t2.ToString());
         }
     }
     else if (t.IsNumeric())
     {
         INumberTerm nt = (INumberTerm)t;
         double      d  = 0;
         try
         {
             d = nt.Solve();
         }
         catch (NoValueException e)
         {
             //e.printStackTrace();
         }
         if (((byte)d) == d)
         {
             return((byte)d);
         }
         else if (((int)d) == d)
         {
             return((int)d);
         }
         else if (((float)d) == d)
         {
             return((float)d);
         }
         else if (((long)d) == d)
         {
             return((long)d);
         }
         else
         {
             return(d);
         }
     }
     else if (t.IsString())
     {
         return(((IStringTerm)t).GetString());
     }
     else if (t.IsList())
     {
         List <object> list = new List <object>();
         foreach (ITerm t1 in (IListTerm)t)
         {
             list.Add(TermToObject(t1));
         }
         return(list);
     }
     else if (t.GetType() == typeof(IObjectTerm))
     {
         return(((IObjectTerm)t).GetObject());
     }
     else
     {
         return(t.ToString());
     }
 }