Skip to content

Commit

Permalink
Correct an example of recursive record types
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Oct 24, 2023
1 parent e054a69 commit e339267
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions specifications/xquery-40/src/expressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5478,14 +5478,13 @@ name.</p>

<example id="e-binary-tree">
<head>A Binary Tree</head>
<p>A record used to represent a node in a binary tree might be represented as:</p>
<eg>record(left? as .., value, right? as ..)</eg>
<p>A record used to represent a node in a binary tree might be represented (using XQuery syntax) as:</p>
<eg>declare item-type t:binary-tree
as record(left? as t:binary-tree, value, right? as t:binary-tree)</eg>
<p>A function to walk this tree and enumerate all the values in depth-first order might be written
(using XQuery syntax) as:</p>
<eg><![CDATA[declare item-type t:binary-tree as
record(left? as t:binary-tree, value, right? as t:binary-tree);
declare function t:flatten($tree as t:binary-tree?) as item()* {
$tree ! (t:flatten(?left), ?value, t:flatten(?right))
(again using XQuery syntax) as:</p>
<eg><![CDATA[declare function t:values($tree as t:binary-tree?) as item()* {
$tree ! (t:values(?left), ?value, t:values(?right))
}]]></eg>
</example>

Expand Down

0 comments on commit e339267

Please sign in to comment.