Skip to content

Commit

Permalink
Specify the convenience method for List multiple assignment
Browse files Browse the repository at this point in the history
Add documentation and a example to specify and document List mulitple assignment.
  • Loading branch information
dlrobertson committed Aug 11, 2024
1 parent 283e1b6 commit 1155aff
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions infra.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,28 @@ out-of-bounds, except when used with <a for=list>exists</a>.
"<code>b</code>", "<code>c</code>", "<code>a</code>" ». Then |example|[1] is the <a>string</a>
"<code>b</code>".

<p>For notational convenience, a multiple assignment syntax may be use to assign multiple variables
to the <a>list</a>'s <a for=list>items</a>, by surrounding the variables to be assigned by « »
characters and separating each variable name with a comma. To
<dfn export for=list>assign multiple variables</dfn> from a <a>list</a> is to <a>Assert</a> that the
<a>list</a>'s <a for=list>size</a> is the same as the number of variables to be assigned, and set
each variable given to the value of the <a>list</a>'s <a for=list>item</a> at the corresponding
index.

<div class=example id=example-list-multiple-assignment>
<ol>
<li><p> Let |value| be the <a>list</a> « "<code>a</code>", "<code>b</code>", "<code>c</code>" ».

<li><p> Let « |a|, |b|, |c| » be |value|.

<li><p> <a>Assert</a>: |a| is "<code>a</code>"

<li><p> <a>Assert</a>: |b| is "<code>b</code>"

<li><p> <a>Assert</a>: |c| is "<code>c</code>"
</ol>
</div>

<hr>

<p>To <dfn export for=list>append</dfn> to a <a>list</a> that is not an <a>ordered set</a> is to
Expand Down

0 comments on commit 1155aff

Please sign in to comment.