本文整理汇总了C#中YieldProlog.Variable类的典型用法代码示例。如果您正苦于以下问题:C# Variable类的具体用法?C# Variable怎么用?C# Variable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Variable类属于YieldProlog命名空间,在下文中一共展示了Variable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: read_term3
public static IEnumerable<bool> read_term3(object Input, object Term, object Options)
{
Variable SaveInput = new Variable();
Variable Answer = new Variable();
Variable Variables = new Variable();
foreach (bool l1 in read_termOptions(Options, Variables))
{
foreach (bool l2 in YP.current_input(SaveInput))
{
try
{
YP.see(Input);
foreach (bool l3 in portable_read3(Answer, Variables, new Variable()))
{
foreach (bool l4 in remove_pos(Answer, Term))
yield return false;
}
}
finally
{
YP.see(SaveInput);
}
}
}
}
示例2: queens
static IEnumerable<bool> queens(object N, object Qs)
{
Variable Ns = new Variable();
foreach (bool l1 in rangeList(1, N, Ns))
{
foreach (bool l2 in queens3(Ns, Atom.NIL, Qs))
yield return false;
}
}
示例3: read_term2
public static IEnumerable<bool> read_term2(object Term, object Options)
{
Variable Answer = new Variable();
Variable Variables = new Variable();
foreach (bool l1 in read_termOptions(Options, Variables))
{
foreach (bool l2 in portable_read3(Answer, Variables, new Variable()))
{
foreach (bool l3 in remove_pos(Answer, Term))
yield return false;
}
}
}
示例4: Main
static void Main(string[] args)
{
long startTicks = DateTime.Now.Ticks;
int nAnswers = 0;
Variable Qs = new Variable();
foreach (bool l1 in queens(11, Qs))
{
++nAnswers;
}
long finishTicks = DateTime.Now.Ticks;
Console.WriteLine("Naive queens: " +
(finishTicks - startTicks) / 10000000.0 + " seconds, " + nAnswers + " answers");
Console.WriteLine("\nPress Enter to finish.");
Console.ReadLine();
}
示例5: rangeList
static IEnumerable<bool> rangeList(int M, int N, Variable List)
{
if (M >= N)
{
foreach (bool l1 in List.unify(new ListPair(N, Atom.NIL)))
yield return false;
}
else
{
Variable Tail = new Variable();
foreach (bool l1 in rangeList(M + 1, N, Tail))
{
foreach (bool l2 in List.unify(new ListPair(M, Tail)))
yield return false;
}
}
}
示例6: queens3
static IEnumerable<bool> queens3(object UnplacedQs, object SafeQs, object Qs)
{
Variable UnplacedQs1 = new Variable();
Variable Q = new Variable();
foreach (bool l1 in selectq(Q, UnplacedQs, UnplacedQs1))
{
foreach (bool l2 in notHasAttack(Q, SafeQs))
{
foreach (bool l3 in queens3(UnplacedQs1, new ListPair(Q, SafeQs), Qs))
yield return false;
}
}
foreach (bool l1 in YP.unify(UnplacedQs, Atom.NIL))
{
foreach (bool l2 in YP.unify(Qs, SafeQs))
yield return false;
}
}
示例7: attack3
static IEnumerable<bool> attack3(object X, object N, object Arg3)
{
Variable Y = new Variable();
foreach (bool l in new ListPair(Y, new Variable()).unify(Arg3))
{
if ((int)YP.getValue(X) == (int)Y.getValue() + (int)YP.getValue(N))
yield return false;
if ((int)YP.getValue(X) == (int)Y.getValue() - (int)YP.getValue(N))
yield return false;
}
Variable Ys = new Variable();
Variable N1 = new Variable();
foreach (bool l1 in new ListPair(new Variable(), Ys).unify(Arg3))
{
foreach (bool l2 in N1.unify((int)YP.getValue(N) + 1))
{
foreach (bool l3 in attack3(X, N1, Ys))
yield return false;
}
}
}
示例8: queens3
static IEnumerable<bool> queens3(object UnplacedQs, object SafeQs, Variable Qs)
{
ListPair UnplacedQsListPair = YP.getValue(UnplacedQs) as ListPair;
if (UnplacedQsListPair != null)
{
Variable UnplacedQs1 = new Variable();
Variable Q = new Variable();
foreach (bool l1 in selectq(Q, UnplacedQsListPair, UnplacedQs1))
{
if (!(SafeQs is ListPair && hasAttack((int)Q.getValue(), (ListPair)SafeQs)))
{
foreach (bool l2 in queens3(UnplacedQs1, new ListPair(Q, SafeQs), Qs))
yield return false;
}
}
}
else
{
foreach (bool l1 in Qs.unify(SafeQs))
yield return false;
}
}
示例9: test_all
public static IEnumerable<bool> test_all(object arg1)
{
{
foreach (bool l2 in YP.unify(arg1, Atom.NIL))
{
yield return false;
}
}
{
Variable F = new Variable();
Variable Fs = new Variable();
foreach (bool l2 in YP.unify(arg1, new ListPair(F, Fs)))
{
foreach (bool l3 in run_tests(F))
{
foreach (bool l4 in test_all(Fs))
{
yield return false;
}
}
}
}
}
示例10: run_all_tests
public static IEnumerable<bool> run_all_tests()
{
{
Variable F = new Variable();
Variable Files = new Variable();
FindallAnswers findallAnswers1 = new FindallAnswers(F);
foreach (bool l2 in file(F))
{
findallAnswers1.add();
}
foreach (bool l2 in findallAnswers1.result(Files))
{
foreach (bool l3 in test_all(Files))
{
foreach (bool l4 in write_results())
{
yield return true;
yield break;
}
}
}
}
}
示例11: write_results
public static IEnumerable<bool> write_results()
{
{
Variable F = new Variable();
Variable ErrorBips = new Variable();
FindallAnswers findallAnswers1 = new FindallAnswers(F);
foreach (bool l2 in inerror(F))
{
findallAnswers1.add();
}
foreach (bool l2 in findallAnswers1.result(ErrorBips))
{
YP.write(Atom.a("--------------------"));
YP.nl();
foreach (bool l3 in YP.unify(ErrorBips, Atom.NIL))
{
YP.write(Atom.a("All bips passed -------------"));
YP.nl();
yield return false;
goto cutIf2;
}
YP.nl();
YP.write(Atom.a("The following BIPs gave unexpected answers:"));
YP.nl();
YP.write(Atom.a("The results should be examined carefully."));
YP.nl();
YP.nl();
foreach (bool l3 in display_list(ErrorBips))
{
yield return false;
}
cutIf2:
{ }
}
}
}
示例12: convertArgListPython
public static void convertArgListPython(object arg1)
{
{
foreach (bool l2 in YP.unify(arg1, Atom.NIL))
{
return;
}
}
{
Variable Head = new Variable();
Variable Tail = new Variable();
foreach (bool l2 in YP.unify(arg1, new ListPair(Head, Tail)))
{
convertExpressionPython(Head);
if (YP.termNotEqual(Tail, Atom.NIL))
{
YP.write(Atom.a(", "));
convertArgListPython(Tail);
return;
goto cutIf1;
}
convertArgListPython(Tail);
return;
cutIf1:
{ }
}
}
}
示例13: convertExpressionPython
public static void convertExpressionPython(object arg1)
{
{
Variable X = new Variable();
foreach (bool l2 in YP.unify(arg1, new Functor1("arg", X)))
{
YP.write(X);
return;
}
}
{
Variable Name = new Variable();
Variable ArgList = new Variable();
foreach (bool l2 in YP.unify(arg1, new Functor2("call", Name, ArgList)))
{
YP.write(Name);
YP.write(Atom.a("("));
convertArgListPython(ArgList);
YP.write(Atom.a(")"));
return;
}
}
{
Variable Name = new Variable();
Variable _FunctorArgs = new Variable();
Variable ArgList = new Variable();
foreach (bool l2 in YP.unify(arg1, new Functor3("functorCall", Name, _FunctorArgs, ArgList)))
{
convertExpressionPython(new Functor2("call", Name, ArgList));
return;
}
}
{
Variable Obj = new Variable();
Variable Name = new Variable();
Variable ArgList = new Variable();
foreach (bool l2 in YP.unify(arg1, new Functor3("callMember", new Functor1("var", Obj), Name, ArgList)))
{
YP.write(Obj);
YP.write(Atom.a("."));
YP.write(Name);
YP.write(Atom.a("("));
convertArgListPython(ArgList);
YP.write(Atom.a(")"));
return;
}
}
{
Variable Name = new Variable();
Variable ArgList = new Variable();
foreach (bool l2 in YP.unify(arg1, new Functor2("new", Name, ArgList)))
{
YP.write(Name);
YP.write(Atom.a("("));
convertArgListPython(ArgList);
YP.write(Atom.a(")"));
return;
}
}
{
Variable Name = new Variable();
foreach (bool l2 in YP.unify(arg1, new Functor1("var", Name)))
{
YP.write(Name);
return;
}
}
{
foreach (bool l2 in YP.unify(arg1, Atom.a("null")))
{
YP.write(Atom.a("None"));
return;
}
}
{
Variable X = new Variable();
foreach (bool l2 in YP.unify(arg1, new Functor1("not", X)))
{
YP.write(Atom.a("not ("));
convertExpressionPython(X);
YP.write(Atom.a(")"));
return;
}
}
{
Variable X = new Variable();
Variable Y = new Variable();
foreach (bool l2 in YP.unify(arg1, new Functor2("and", X, Y)))
{
YP.write(Atom.a("("));
convertExpressionPython(X);
YP.write(Atom.a(") and ("));
convertExpressionPython(Y);
YP.write(Atom.a(")"));
return;
}
}
{
Variable ArgList = new Variable();
foreach (bool l2 in YP.unify(arg1, new Functor1("objectArray", ArgList)))
//.........这里部分代码省略.........
示例14: makeFunctionPseudoCode
public static IEnumerable<bool> makeFunctionPseudoCode(object RuleList, object FunctionCode)
{
{
Variable State = new Variable();
foreach (bool l2 in CompilerState.make(State))
{
assertYPPred(State);
processCompilerDirectives(RuleList, State);
foreach (bool l3 in YP.unify(FunctionCode, Atom.a("getDeclaringClass")))
{
yield return false;
}
foreach (bool l3 in makeFunctionPseudoCode3(RuleList, State, FunctionCode))
{
yield return false;
}
}
}
}
示例15: convertIndentationPython
public static void convertIndentationPython(object Level)
{
{
Variable N = new Variable();
foreach (bool l2 in YP.unify(N, YP.multiply(Level, 2)))
{
repeatWrite(Atom.a(" "), N);
return;
}
}
}