Skip to content

Commit

Permalink
Define replace for lists and sets
Browse files Browse the repository at this point in the history
Fixes #103.
  • Loading branch information
annevk authored and domenic committed Mar 30, 2017
1 parent a743dbd commit 4b5c3f3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions infra.bs
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,16 @@ add the given <a for=list>item</a> to the end of the list.
<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.

<p>To <dfn export for=list>replace</dfn> within a <a>list</a> that is not an <a>ordered set</a> is
to replace all items from the list that match a given condition with the given <a for=list>item</a>,
or do nothing if none do.

<p class=note>The above definitions are modified when the <a>list</a> is an <a>ordered set</a>; see
below for <a for=set lt=append>ordered set append</a> and
<a for=set lt=prepend>ordered set prepend</a>.
below for <a for=set lt=append>ordered set append</a>, <a for=set>prepend</a>, and
<a for=set>replace</a>.

<p>To <dfn export for=list,set>remove</dfn> an <a for=list>item</a> from a <a>list</a> is to remove
all items from the list that match a given condition, or do nothing if none do.
<p>To <dfn export for=list,set>remove</dfn> zero or more <a for=list>items</a> from a <a>list</a> is
to remove all items from the list that match a given condition, or do nothing if none do.

<div class=example id=example-list-remove>
<p><a for=list>Removing</a> |x| from the <a>list</a> « |x|, |y|, |z|, |x| » is to remove all
Expand Down Expand Up @@ -715,6 +719,10 @@ ordered sets; implementations can optimize based on the fact that the order is n
<a for=list>contains</a> the given <a for=set>item</a>, or to perform the normal <a>list</a>
<a for=list>prepend</a> operation otherwise.

<p>To <dfn export for=set>replace</dfn> within an <a>ordered set</a> is to replace the first item
from the set that matches a given condition with the given <a for=set>item</a> and remove the other
matching items, or do nothing if none match.


<h3 id=maps>Maps</h3>

Expand Down

0 comments on commit 4b5c3f3

Please sign in to comment.