diff --git a/infra.bs b/infra.bs index 800f0c2..54c6bda 100644 --- a/infra.bs +++ b/infra.bs @@ -1661,10 +1661,30 @@ set of steps on each item in order, use phrasing of the form "For each |item| of list", and then operate on |item| in the subsequent prose. -

To clone a list |list| is to create a new -list |clone|, of the same designation, and, for each |item| of |list|, -append |item| to |clone|, so that |clone| contains the same -items, in the same order as |list|. +

+

To slice a list |list|, with an optional +integer from (default 0) and an optional integer +to (default |list|'s size), perform the +following steps. They return a list of the same designation as |list|. + +

    +
  1. Assert: |from| is greater than or equal to 0. + +

  2. Assert: |to| is less than or equal to |list|'s size. + +

  3. Assert: |to| is greater than or equal to |from|. + +

  4. Let |slice| be a new list of the same designation as |list|. + +

  5. For each |i| of the range |from| to |to|, + exclusive: append |list|[|i|] to |slice|. + +

  6. Return |slice|. +

+
+ +

To clone a list |list| is to return a +slice of |list|.

This is a "shallow clone", as the items themselves are not cloned in any way.