Skip to content

Commit

Permalink
Add extend for lists
Browse files Browse the repository at this point in the history
To insert the items of the first given list at the end of the second given list.

Fixes #238.
  • Loading branch information
annevk authored Mar 31, 2019
1 parent b49b463 commit 8970e9f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions infra.bs
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,22 @@ out-of-bounds, except when used with <a for=list>exists</a>.
<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|.

<div class=example id=example-list-extend>
<ol>
<li><p>Let |ghostbusters| be « "<code>Erin Gilbert</code>", "<code>Abby Yates</code>" ».

<li><p><a for=list>Extend</a> |ghostbusters| with « "<code>Jillian Holtzmann</code>",
"<code>Patty Tolan</code>" ».

<li><p><a>Assert</a>: |ghostbusters|'s <a for=list>size</a> is 4.

<li><p><a>Assert</a>: |ghostbusters|[2] is "<code>Jillian Holtzmann</code>".
</ol>
</div>

<p>To <dfn export for=list>prepend</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 beginning of the list.

Expand Down

0 comments on commit 8970e9f

Please sign in to comment.