for (int i = 0; i < args.Length; i++)
domain.DebugWrite (false, " {0}", args[i].ToString ());
domain.DebugWrite (false, ")");
- domain.depth += 2;
+ domain.depth++;
Term result = func.Call (domain, args);
- domain.depth -= 2;
- domain.DebugWrite (true, " => {0})", result.ToString ());
+ domain.depth--;
+ domain.DebugWrite (true, " ==> {0})", result.ToString ());
return result;
}
public override string ToString ()
{
+ string str;
+
if (objval == null)
- return "<integer>" + intval + "</integer>";
- if (objval is Name)
- return "<symbol>" + objval + "</symbol>";
- if (objval is string)
- return "<string>" + objval + "</string>";
- if (objval is List<Term>)
+ str = "<integer>" + intval + "</integer>";
+ else if (objval is Name)
+ str = "<symbol>" + objval + "</symbol>";
+ else if (objval is string)
+ str = "<string>" + objval + "</string>";
+ else if (objval is List<Term>)
{
- string str = "<list>";
+ str = "<list>";
foreach (Term e in (List<Term>) objval)
str += e;
- return str + "</list>";
+ str += "</list>";
}
- if (objval is Funcall)
- return "<funcall fname=\"" + ((Funcall) objval).func.name + "\"/>";
- if (objval is Variable)
- return "<variable vname=\"" + ((Variable) objval).name + "\"/>";
- if (objval is Term)
- return "<quote>" + objval + "</quote>";
- throw new Exception ("invalid Term object: " + objval);
+ else if (objval is Funcall)
+ str = "<funcall fname=\"" + ((Funcall) objval).func.name + "\"/>";
+ else if (objval is Variable)
+ str = "<variable vname=\"" + ((Variable) objval).name + "\"/>";
+ else if (objval is Term)
+ str = "<quote>" + objval + "</quote>";
+ else
+ throw new Exception ("invalid Term object: " + objval);
+ return str;
}
}
if (n.Name == Ndefun)
domain.Defun (n);
else if (n.Name != Ndefvar)
- terms[i]= new Term (n, domain);
+ {
+ terms[i]= new Term (n, domain);
+ Console.WriteLine ("term="+terms[i]);
+ }
}
}
Term result = Zero;
domain.depth = 0;
+ for (int i = 0; i < terms.Length; i++)
+ Console.WriteLine (terms[i]);
+
foreach (Term term in terms)
{
+ Console.WriteLine (term);
result = term.Eval (domain);
- Console.WriteLine (result);
+ Console.WriteLine ("=>" + result);
}
return result;
}