コード例 #1
0
 /// <summary>
 /// Adds a new user-defined binary primitive predicate given
 /// C# delegates to implement its different modes.  Assumes
 /// arguments are always atomic, and that the relation won't
 /// be called with the same unbound variable for both arguments.
 /// </summary>
 /// <param name="name">Name to give to the predicate</param>
 /// <param name="documentation">Description of the operation of the predicate</param>
 /// <param name="arg1Name">Name of the first argument (for documentation and error messages)</param>
 /// <param name="arg2Name">Name of hte second argument (for documentation and error messages)</param>
 /// <param name="filter">Implementation of predicate for case where both arguments are instantiated.</param>
 /// <param name="arg1Enumerator">For non-left-unique predicates: implementation for case where only the second argument is instantiated, so the values of the first argument must be enumerated.</param>
 /// <param name="arg1Function">For left-unique predicates: implementation for the case where only the second argument is instantiated, so need to compute the value of the first (if any).</param>
 /// <param name="arg2Enumerator">For non-right-unique predicates: implementation for case where only the first argument is instantiated, so the values of the second argument must be enumerated.</param>
 /// <param name="arg2Function">For right-unique predicates: implementation for the case where only the first argument is instantiated, so need to compute the value of the second (if any)</param>
 /// <param name="doubleEnumerator">Implementation of the case where neither argument is instantiated.</param>
 public static void Declare(
     string name,
     string documentation,
     string arg1Name,
     string arg2Name,
     Filter filter,
     Arg1Enumerator arg1Enumerator     = null,
     Arg1Function arg1Function         = null,
     Arg2Enumerator arg2Enumerator     = null,
     Arg2Function arg2Function         = null,
     DoubleEnumerator doubleEnumerator = null)
 {
     PrologPrimitives.DefinePrimitive(
         Symbol.Intern(name),
         new BinaryPrimitive <T1, T2>(
             name,
             arg1Name,
             arg2Name,
             filter,
             arg1Enumerator,
             arg1Function,
             arg2Enumerator,
             arg2Function,
             doubleEnumerator).BinaryPrimitiveImplementation,
         null,
         documentation,
         arg1Name,
         arg2Name);
 }
コード例 #2
0
 private BinaryPrimitive(
     string name,
     string arg1Name,
     string arg2Name,
     Filter filterImplementation,
     Arg1Enumerator arg1EnumeratorImplementation,
     Arg1Function arg1FunctionImplementation,
     Arg2Enumerator arg2EnumeratorImplementation,
     Arg2Function arg2FunctionImplementation,
     DoubleEnumerator doubleEnumeratorImplementation)
 {
     this.Name              = name;
     this.arg1Name          = arg1Name;
     this.arg2Name          = arg2Name;
     this.expectedArguments = new object[] { arg1Name, arg2Name };
     filter           = filterImplementation;
     arg1Enumerator   = arg1EnumeratorImplementation;
     arg1Function     = arg1FunctionImplementation;
     arg2Enumerator   = arg2EnumeratorImplementation;
     arg2Function     = arg2FunctionImplementation;
     doubleEnumerator = doubleEnumeratorImplementation;
 }