Skip to content

Commit ffebfb4

Browse files
authored
Define an algorithm to create a set from a list
1 parent 7351436 commit ffebfb4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

infra.bs

+10
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,16 @@ unordered one, since interoperability requires that any developer-exposed enumer
16941694
contents be consistent between browsers. In those cases where order is not important, we still use
16951695
ordered sets; implementations can optimize based on the fact that the order is not observable.
16961696

1697+
<div algorithm>
1698+
<p>To <dfn export for=set>create</dfn> a [=/set=], given a [=/list=] |input|:
1699+
1700+
<ol>
1701+
<li><p>Let |result| be an empty [=/set=].
1702+
<li><p>[=list/For each=] |item| of |input|, [=set/append=] |item| to |result|.
1703+
<li><p>Return |result|.
1704+
</ol>
1705+
</div>
1706+
16971707
<p>To <dfn export for=set>append</dfn> to an <a>ordered set</a>: if the set <a for=list>contains</a>
16981708
the given <a for=set>item</a>, then do nothing; otherwise, perform the normal <a>list</a>
16991709
<a for=list>append</a> operation.

0 commit comments

Comments
 (0)