{remove}
Removes the values of a sequence that belong to a sequence type - the inverse of keep.
Syntax
{remove '1..10', prime} ... {/remove}
{remove prime, rows=5} ... {/remove}
{remove:odd rows=5} ... {/remove:odd}
{remove store, even} ... {/remove}
Parameters
-
values -
Where the values come from: a range
'1..10', a stored sequence named bare (not quoted), or left out - the candidates then run fromfromupward. -
type -
The sequence type whose members are removed:
prime,odd,square, ... A type with a value is written as an option:multiple=3.
Description
{remove '1..10', prime} runs a sequence in remove mode: every value that belongs to the named type is dropped, the rest stay - here 1 4 6 8 9 10. It is the same run as {sequence '1..10', remove, prime}, and the exact inverse of {keep}: together the two split a list in two.
Without a range the candidates run from from (default 1) upward, and rows counts what is left: {remove prime, rows=5} is the first five numbers that are not prime, 1 4 6 8 9. A stored sequence, named bare, works as the source as well, and the prefix form {remove:odd rows=5} names the type in the tag.
To invert an action - all but the first three - use the negative option of {sequence} instead; remove is the inversion for plays.
Examples
What is not prime
The same range through remove and keep - together they hold every number once.
<p>remove: {remove '1..20', prime}{$sequence} {/remove}</p>
<p>keep: {keep '1..20', prime}{$sequence} {/keep}</p>
remove: 1 4 6 8 9 10 12 14 15 16 18 20
keep: 2 3 5 7 11 13 17 19
From a store
The odd numbers removed from a stored list of the first ten triangular numbers.
{sequence triangular, rows=10, push='triangles'}
<p>All: {pull 'triangles'}{$sequence} {/pull}</p>
<p>Not odd: {remove triangles, odd}{$sequence} {/remove}</p>
All: 1 3 6 10 15 21 28 36 45 55
Not odd: 6 10 28 36
See also
- {keep} Keeps only the values of a sequence that belong to a sequence type.
- {flag} Replaces every value of a sequence with 1 or 0: whether it belongs to a sequence type.
- {make} Replaces every value of a sequence with what a sequence type makes of it.
- {sequence} Generates a range, a list or one of 80 mathematical sequences, and iterates its values.
- {pull} Iterates a stored sequence, optionally through plays and actions.