From adb18957c1be07d53abb7b5305b26e95a27ce48a Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Sun, 11 Aug 2024 13:14:08 -0400 Subject: [PATCH 1/2] Specify the convenience method for List multiple assignment Add documentation and a example to specify and document List mulitple assignment. --- infra.bs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/infra.bs b/infra.bs index 14ab8a5..00172b5 100644 --- a/infra.bs +++ b/infra.bs @@ -1426,6 +1426,37 @@ out-of-bounds, except when used with exists. "b", "c", "a" ». Then |example|[1] is the string "b". +

For notational convenience, a multiple assignment syntax may be used to assign multiple variables +to the list's items, by surrounding the variables to be assigned by « » +characters and separating each variable name with a comma. The list's size +must be the same as the number of variables to be assigned. Each variable given is then set to the +value of the list's item at the corresponding index. + +

+
    +
  1. Let |value| be the list « "a", "b", "c" ». + +

  2. Let « |a|, |b|, |c| » be |value|. + +

  3. Assert: |a| is "a" + +

  4. Assert: |b| is "b" + +

  5. Assert: |c| is "c" +

+
+ +

When a list's contents are not fully controlled, as is the case for lists from user input, +the list's size should be checked to ensure it is the expected size before +list multiple assignment syntax is used. + +

+
    +
  1. If |list|'s size is not 3, then return failure. +

  2. Let « |a|, |b|, |c| » be |list|. +

+
+

To append to a list that is not an ordered set is to From badb5de5a83625b384bab6d644aef2ba2c44efbf Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 14 Aug 2024 13:01:17 +0200 Subject: [PATCH 2/2] Update infra.bs Co-authored-by: Domenic Denicola --- infra.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/infra.bs b/infra.bs index 00172b5..ae30c20 100644 --- a/infra.bs +++ b/infra.bs @@ -1438,11 +1438,11 @@ value of the list's item at the corresponding index.

  • Let « |a|, |b|, |c| » be |value|. -

  • Assert: |a| is "a" +

  • Assert: |a| is "a". -

  • Assert: |b| is "b" +

  • Assert: |b| is "b". -

  • Assert: |c| is "c" +

  • Assert: |c| is "c".