Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions infra.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1661,10 +1661,15 @@ set of steps on each <a for=list>item</a> in order, use phrasing of the form
"<a for=list>For each</a> |item| of <var ignore>list</var>", and then operate on |item| in the
subsequent prose.

<p>To <dfn export for=list,stack,queue,set>clone</dfn> a <a>list</a> |list| is to create a new
<a>list</a> |clone|, of the same designation, and, <a for=list>for each</a> |item| of |list|,
<a for=list>append</a> |item| to |clone|, so that |clone| <a for=list>contains</a> the same
<a for=list>items</a>, in the same order as |list|.
<p>To <dfn export for=list,stack,queue,set>slice</dfn> a <a>list</a> |list|, with an optional index
<dfn export for=list/slice><var>from</var></dfn> (default 0) and an optional index
<dfn export for=list/slice><var>to</var></dfn> (default |list|'s <a for=list>size</a>), is to create a new
<a>list</a> |slice|, of the same designation, and <a for=list>append</a> each
<a for=list>item</a> of |list|, where the index is greater than or equal to |from| and less than
|to|, to |slice|, maintaining order.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make this a list of steps for clarity. That way we can also assert the obvious things about from and to.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's fair.

Are you ok with clone being defined in terms of slice?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that seems good. Always nice to have fewer fundamental primitives.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


<p>To <dfn export for=list,stack,queue,set>clone</dfn> a <a>list</a> |list| is to return a
<a for=list>slice</a> of |list|.

<p class=note>This is a "shallow clone", as the <a for=list>items</a> themselves are not cloned in
any way.
Expand Down