Skip to content

Instantly share code, notes, and snippets.

@line-o
Created February 17, 2018 08:32
Show Gist options
  • Select an option

  • Save line-o/1ce8c6ae3e6e6cce30db1b4ee6ec22f0 to your computer and use it in GitHub Desktop.

Select an option

Save line-o/1ce8c6ae3e6e6cce30db1b4ee6ec22f0 to your computer and use it in GitHub Desktop.
An example of fold-left, filter and for-each in combination.
xquery version "3.1";
declare function local:gta50 ($a, $b) { $a > $b};
declare function local:add22 ($a) { $a + 22};
declare function local:sum ($result, $next) {$result + $next};
declare variable $local:sequence := (1,32,34,3,34)
util:log('info', string-join($local:sequence, ',')),
fold-left(
filter(
for-each(
$sequence,
local:add22#1
),
local:gta50(?, 50)
),
0,
local:sum#2
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment