{resume}

Transforms the sequence pushed last, in place, through an action or a play.

Sequences Single tags

Syntax

{resume reverse}
{resume add=10}
{resume keep, prime}
{resume first=3}

Options

action
Any sequence action, as an option of its own or named with action='reverse' - reverse, sort, sum, first=3, ... - or a play with a type: add=10 (make), keep, prime, remove, even, flag, odd.

Description

{resume reverse} picks up the sequence that was stored last - by push= or name= on a {sequence} - runs the action or play written with it, and writes the result back over that store. It prints nothing: read the store afterwards with {pull} or by its own name.

Each {resume} works on what the one before left, so a list can be built in steps: {resume add=10} then {resume reverse} turns 1 2 3 into 13 12 11. Plays work as well as actions - {resume keep, prime} filters the store, {resume add=100} transforms every value.

It always acts on the store pushed last; it takes no store name. A store named in the tag is not read as one, and the prefix form {resume:name} is an error - there is no type named 'resume'. A {resume} before anything was pushed is an error too: nothing has been pushed. It has nothing to do with {cease} or loops; to apply an action without changing the store, use {action} or {pull}.

Examples

Build a list in steps

Three resumes rewrite the stored range one after another; the store holds the end result.

Templateexamples/resume/1-steps.pad
{sequence '1..5', push='steps'}
{resume add=100}
{resume reverse}
{resume first=3}
<p>{pull steps}{$sequence} {/pull}</p>
Resultopen alone

105 104 103

Filter a store in place

keep, prime as a resume: the store itself now holds only the primes.

Templateexamples/resume/2-filter.pad
{sequence '1..30', push='candidates'}
{resume keep, prime}
<p>{candidates}{$candidates} {/candidates}</p>
Resultopen alone

2 3 5 7 11 13 17 19 23 29

See also

  • {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.
  • {action} Runs one sequence action - reverse, sum, first and the rest - over a store, a range or a type, and iterates the result.