Skip to content

Commit

Permalink
Add set extend operation
Browse files Browse the repository at this point in the history
"List extend" didn't really work since it used "list append", which doesn't properly handle duplicates.
  • Loading branch information
domenic committed Jan 29, 2025
1 parent 48531ec commit 8c74b2a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions infra.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1542,8 +1542,8 @@ list multiple assignment syntax is used.
<p>To <dfn export for=list>append</dfn> to a <a>list</a> that is not an <a>ordered set</a> is to
add the given <a for=list>item</a> to the end of the list.

<p>To <dfn export for=list>extend</dfn> a <a>list</a> |A| with a <a>list</a> |B|,
<a for=list>for each</a> |item| of |B|, <a for=list>append</a> |item| to |A|.
<p>To <dfn export for=list>extend</dfn> a <a>list</a> that is not an <a>ordered set</a> |A| with a
<a>list</a> |B|, <a for=list>for each</a> |item| of |B|, <a for=list>append</a> |item| to |A|.

<div class=example id=example-list-extend>
<ol>
Expand Down Expand Up @@ -1709,6 +1709,9 @@ ordered sets; implementations can optimize based on the fact that the order is n
the given <a for=set>item</a>, then do nothing; otherwise, perform the normal <a>list</a>
<a for=list>append</a> operation.

<p>To <dfn export for=set>extend</dfn> an [=ordered set=] |A| with a [=list=] |B|, [=list/for each=]
|item| of |B|, [=set/append=] |item| to |A|.

<p>To <dfn export for=set>prepend</dfn> to an <a>ordered set</a>: if the set
<a for=list>contains</a> the given <a for=set>item</a>, then do nothing; otherwise, perform the
normal <a>list</a> <a for=list>prepend</a> operation.
Expand Down

0 comments on commit 8c74b2a

Please sign in to comment.