With this delegate you can build a call-back predicate with a variable amount of parameters.
Declaration Syntax
C# | Visual Basic | Visual C++ | F# |
public delegate bool DelegateParameterVarArgs( PlTermV termVector )
Public Delegate Function DelegateParameterVarArgs ( termVector As PlTermV ) As Boolean
public delegate bool DelegateParameterVarArgs( PlTermV termVector )
type DelegateParameterVarArgs = delegate of termVector : PlTermV -> bool
Return Value
Boolean
True for succeeding otherwise false for fail
True for succeeding otherwise false for fail
Examples
Copy | |
---|---|
public void t_varargs() { Delegate d = new DelegateParameterVarArgs(my_concat_atom); PlEngine.RegisterForeign("my_concat_atom", 4, d); PlEngine.RegisterForeign("my_concat_atom", 7, d); for (int i = 1; i < 10; i++) { PlTerm t = PlQuery.PlCallQuery("my_concat_atom(a,b,c, X)"); Assert.AreEqual("abc", t.ToString(), "my_concat_atom failed!"); t = PlQuery.PlCallQuery("my_concat_atom(a,b,c,d,e,f, X)"); Assert.AreEqual("abcdef", t.ToString(), "my_concat_atom failed!"); } } public static bool my_concat_atom(PlTermV term1) { int arity = term1.Size; string sRet = ""; PlTerm term_out = term1[arity -1]; for (int i = 0; i < arity-1; i++) { string s = term1.ToString(); sRet += term1[i].ToString(); } term_out.Unify(sRet); return true; } |
Assembly: SwiPlCs (Module: SwiPlCs.dll) Version: 1.1.60601.0 (1.1.60601.0)