Skip to content

Instantly share code, notes, and snippets.

@line-o
Last active April 30, 2025 17:08
Show Gist options
  • Save line-o/848b970f7043c6f67da55308d0641abb to your computer and use it in GitHub Desktop.
Save line-o/848b970f7043c6f67da55308d0641abb to your computer and use it in GitHub Desktop.
Highlight some hard to handle edge-cases in fn:chain since the arity of functions is set but return sequences can vary in size
let $xml :=
<root>
<child>1</child>
<child>2</child>
<child>3</child>
<!--<child>4</child>-->
</root>
let $children := fn ($n) { $n/child }
return (
chain($xml/root, (
$children,
fn ($a, $b, $c) { concat($a, $b, $c) }
)),
chain($xml/root, (
$children,
tail#1,
fn ($a, $b, $c) { concat($a, $b, $c) }
)),
chain($xml/root, (
$children,
concat#2
)),
chain($xml/root, (
$children,
apply(concat#3, ?)
))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment