-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1651 ordered maps #1703
base: master
Are you sure you want to change the base?
1651 ordered maps #1703
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the proposal, including the definition of “entry order”, and I appreciate the effort made to incorporate all the changes.
and returns the sequence concenation of the results.</p> | ||
<p>The <code>dm:iterate-map</code> accessor calls the supplied <code>$action</code> | ||
function once for each key/value pair in <code>$map</code>, | ||
and returns the sequence concenation of the results. The order in which entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and returns the sequence concenation of the results. The order in which entries | |
and returns the sequence concatenation of the results. The order in which entries |
<!--<fos:option key="retain-order"> | ||
<fos:meaning>Determines the | ||
<xtermref spec="DM40" ref="dt-entry-order">entry order</xtermref> of the | ||
entries in the returned map, as well as the value of the map's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entries in the returned map, as well as the value of the map's | |
entries in the returned map, as well as the value of the map’s |
@@ -23105,7 +23129,7 @@ let $combine := fn($A as map(*), $B as map(*), $deduplicator as fn(*)) { | |||
else map:put($z, $k, $B($k)) | |||
}) | |||
} | |||
return fold-left($maps, {}, | |||
return fold-left($maps, dm:empty-map($options?ordering otherwise "undefined"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fold-left($maps, dm:empty-map($options?ordering otherwise "undefined"), | |
return fold-left($maps, {}, |
@@ -23217,6 +23243,12 @@ return fold-left($maps, {}, | |||
entry that appears in the result is the <xtermref spec="XP40" ref="dt-sequence-concatenation">sequence concatenation</xtermref> of the entries | |||
in the input maps, retaining order.</fos:postamble> | |||
</fos:test> | |||
|
|||
<fos:test> | |||
<fos:expression><eg>map:merge(({ "red": 0 }, { "green": 1}, { "blue": 2 }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<fos:expression><eg>map:merge(({ "red": 0 }, { "green": 1}, { "blue": 2 }), | |
<fos:expression><eg>map:merge(({ "red": 0 }, { "green": 1}, { "blue": 2 })) |
|
||
<fos:test> | ||
<fos:expression><eg>map:merge(({ "red": 0 }, { "green": 1}, { "blue": 2 }), | ||
{ "retain-order": true() } => map:keys()</eg></fos:expression> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ "retain-order": true() } => map:keys()</eg></fos:expression> | |
=> map:keys()</eg></fos:expression> |
}; | ||
</eg> | ||
|
||
<p>So the call <code>cx:complex(3, 2)</code> produces the value <code>{ "r": 3e0, "i": 2e0 }</code>, | ||
while the call <code>cx:complex(3)</code> produces the value <code>{ "r": 3e0, "i": 0e0 }</code></p> | ||
|
||
<p>The resulting map has its <xtermref spec="DM40" ref="dt-map-ordered"/> property set to | ||
<code>true</code>, so the order of entries corresponds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<code>true</code>, so the order of entries corresponds | |
<p>The order of entries corresponds |
@@ -2157,7 +2163,7 @@ local:depth(doc("partlist.xml")) | |||
map:merge(( | |||
{ "r": $r }, | |||
if (exists($i)) { { "i": $i } } | |||
)) | |||
), { "retain-order" : true() }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
), { "retain-order" : true() }) | |
)) |
@@ -2186,13 +2192,16 @@ local:depth(doc("partlist.xml")) | |||
{ "last": $last }, | |||
$options | |||
), | |||
{ "duplicates": "use-first" } | |||
{ "duplicates": "use-first", "retain-order" : true() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ "duplicates": "use-first", "retain-order" : true() } | |
{ "duplicates": "use-first" } |
}; | ||
</eg> | ||
|
||
<p>The effect of the <code>duplicates</code> option here is that when two values are supplied for the same field, | ||
one as a direct argument in the function call and the other in the <code>options</code> map, the value supplied | ||
as a direct argument is used in preference.</p> | ||
as a direct argument is used in preference. The effect of the <code>ordering</code> option is that the resulting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a direct argument is used in preference. The effect of the <code>ordering</code> option is that the resulting | |
as a direct argument is used in preference. The resulting |
@@ -2242,8 +2251,7 @@ local:depth(doc("partlist.xml")) | |||
<item><p>The optional final subexpression, if present, takes the form <code>$options</code>, | |||
where <code>$options</code> is the name allocated to the final parameter.</p></item> | |||
<item><p>The second argument in the call of the function <code>map:merge</code> | |||
is the map <code>{ "duplicates": "use-first" }</code>. This can be omitted if the record is not | |||
extensible, because in this case duplicate field names cannot arise.</p></item> | |||
is the map <code>{ "duplicates": "use-first", "retain-order": true() }</code>.</p></item> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the map <code>{ "duplicates": "use-first", "retain-order": true() }</code>.</p></item> | |
is the map <code>{ "duplicates": "use-first" }</code>.</p></item> |
Reopened pull request introducing ordered maps.
Fix #1651.