{sequence} is the front door of PAD's sequence subsystem. It builds a list of numbers - a range, an explicit list, or the terms of one of 80 mathematical sequence types - runs the plays and actions written with it over that list, and gives the level the values to iterate. Inside the pair the current value is {$sequence}; for a type it is also there under the type's name ({$prime}, {$range}), and name='n' puts it in {$n} instead - and also stores the result under that name, as push does. Like any data tag it has the loop properties: first@sequence, last@sequence, count@sequence.

What to generate

How much

rows=10 asks for ten terms whatever the type, and is usually what you want. from and to bound the loop the terms are generated by, and what that loop counts depends on the type: a type that tests candidates (prime, palindrome) counts values, so {sequence prime, to=20} gives the primes up to 20; a type that computes the nth term (fibonacci, square) counts positions, so {sequence square, to=20} gives twenty squares. stop=100 always names a value: the run ends at the first term that reaches it, that term included. minimal and maximal leave out terms outside a band, skip skips candidates, unique drops repeats.

Plays and actions

A play holds every value against a second type while the list is built: keep, prime keeps the primes, remove, prime drops them, flag, prime turns each value into 1 or 0, and make, prime replaces each value with what that type makes of it. The tags {keep}, {remove}, {flag} and {make} are the same runs with the play as the tag name.

An action works on the finished list, in the order written: aggregates that leave one value (sum, average, median, product, count, minimum, maximum), selections (first=3, last=3, slice, element), orderings (sort, reverse, shuffle), dedup, and actions that bring in a stored sequence (append, prepend, merge, intersection, difference). negative inverts an action's selection: first=3, negative is all but the first three.

Storing

push='name' keeps the result as a store. The single form {sequence prime, rows=10, push='primes'} stores without printing anything; {pull} iterates the store later, {resume} transforms the last pushed one in place and {action} runs an action over one. A store can also be iterated by its own name as a tag: {primes}. name='x' stores as well. A store name may not be the name of a sequence type, an action, a sequence option or a PAD option - name='step' is an error, since step is a type. toData='name' keeps the values as an ordinary data set instead.

In an expression a single term is sequence:fibonacci(8) - the 8th term, 13. Under the strict check an option that nothing reads (rowz=3) and a name that is no type, store or action are errors.