If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Monday, March 18, 2013

XQuery3.0: Partial function example

xquery version "3.0";
declare function local:increase($nums as xs:integer*, $by as xs:integer) as xs:integer* {
$nums ! (. + $by)
};
let $numbers := (2,3,6,8,12,14)
let $increaseByThree := local:increase(?, 3)
let $increaseByFour := local:increase(?, 4)
return
<result>
<test1>{$increaseByThree($numbers)}</test1>
<test2>{$increaseByFour($numbers)}</test2>
</result>
(:
**********************************************
XQuery output:
**********************************************
<result>
<test1>5 6 9 11 15 17</test1>
<test2>6 7 10 12 16 18</test2>
</result>
:)
view raw gistfile1.txt hosted with ❤ by GitHub

No comments:

Post a Comment