Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog
DelegateParameterVarArgs Delegate
SwiPlCs interface ► SbsSW.SwiPlCs.Callback ► DelegateParameterVarArgs
With this delegate you can build a call-back predicate with a variable amount of parameters.


True for succeeding otherwise false for fail


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; }