Function as argument

Wednesday, 6 April 2016 · 3 messages
PS
Paul Swennenhuis6 Apr 2016 09:35 #
Hi all, I am now using functions as argument in BaseX for the first time, borrowing the way to do that from some old list archive contribution. Apparently you have to use the name of the function followed by #1 like this:
let $a := local:someFunc($nodeSet, local:someOtherFunc#1)
But it is unclear to me if this is indeed the right way to do it. The #1 suggests that there may also be a #2, #3 etc. (and possibly a #0). I could not find the documentation on using functions as argument on the Wiki pages. (I am happy to see that it works as expected though) Paul
CG
Christian Grün6 Apr 2016 11:31 #
Hi Paul,
Quoted text · Paul Swennenhuis · 6 lines
> Apparently you have to use the name of the function followed by #1 like > this: > > let $a := local:someFunc($nodeSet, local:someOtherFunc#1) > > But it is unclear to me if this is indeed the right way to do it.
This is called a named function reference. The digit represents the number of arguments of your function.
Quoted text · Paul Swennenhuis · 2 lines
> I could not find the documentation on using functions as argument on the > Wiki pages.
This is true. Would anyone out there be interested in extending our Higher Order Functions article [1]? Here are two external references that may be of interest for you, though: * The slides of our XML Technologies course (No 4: "XQuery: More than Just a Query Language", Page 12) [2] * Priscilla Walmsley’s new book on XQuery [3] Hope this helps, Christian [1] http://docs.basex.org/wiki/Higher-Order_Functions [2] http://phobos103.inf.uni-konstanz.de/xml15/ [3] https://books.google.de/books?id=wZ0bCwAAQBAJ&pg=PA360&dq="The+arity+is+required+to+uniquely+identify+the+function"
PS
Paul Swennenhuis6 Apr 2016 11:43 #
Thanks Christian. Now it makes sense. Quite interesting, that "XQuery: More than Just a Query Language" presentation. Paul
Quoted text · Christian Grün · 28 lines
> Hi Paul, > >> Apparently you have to use the name of the function followed by #1 like >> this: >> >> let $a := local:someFunc($nodeSet, local:someOtherFunc#1) >> >> But it is unclear to me if this is indeed the right way to do it. > This is called a named function reference. The digit represents the > number of arguments of your function. > >> I could not find the documentation on using functions as argument on the >> Wiki pages. > This is true. Would anyone out there be interested in extending our > Higher Order Functions article [1]? > > Here are two external references that may be of interest for you, though: > > * The slides of our XML Technologies course (No 4: "XQuery: More than > Just a Query Language", Page 12) [2] > * Priscilla Walmsley’s new book on XQuery [3] > > Hope this helps, > Christian > > [1] http://docs.basex.org/wiki/Higher-Order_Functions > [2] http://phobos103.inf.uni-konstanz.de/xml15/ > [3] https://books.google.de/books?id=wZ0bCwAAQBAJ&pg=PA360&dq="The+arity+is+required+to+uniquely+identify+the+function"

⚡Generated with XQuery