Skip to content

Commit

Permalink
Define steps to create a Set from a List
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Dec 18, 2024
1 parent 7351436 commit 875a5f5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions infra.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,16 @@ unordered one, since interoperability requires that any developer-exposed enumer
contents be consistent between browsers. In those cases where order is not important, we still use
ordered sets; implementations can optimize based on the fact that the order is not observable.

<div algorithm>
<p>To <dfn export for=set>create</dfn> a [=/set=], from a [=/list=] |input|:

<ol>
<li><p>Let |result| be an empty [=/set=].
<li><p>For each [=list/item=] |item| in |input|, [=set/append=] |item| to |result|.
<li><p>Return |result|.
</ol>
</div>

<p>To <dfn export for=set>append</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>append</a> operation.
Expand Down

0 comments on commit 875a5f5

Please sign in to comment.