# series

Definition: | object res = series(object start, object increment, integer count = 2, integer op = '+')
Description: | Create a sequence as a series starting from a given object. start: the initial value from which to start increment: the value to recursively add to `start` to get new elements. count: the number of items in the returned sequence. The default is 2. op: the operation used to build the series, either '+' (the default) or '*'. Returns either 0 on failure or a sequence containing the series.
pwa/p2js: | Supported, though naturally I’m much more of a tagset() person.
Comments: | The first item in the returned series is always `start`. A linear series is formed by adding `increment` to `start`. A geometric series is formed by multiplying `increment` by `start`. If `count` is negative, or if `start op increment` is invalid, 0 is returned. Otherwise, returns a sequence of length `count`, starting with `start` and whose adjacent elements differ by `increment`.
Example: |
    s = series( 1, 4, 5)                    -- s is {1, 5, 9, 13, 17}
    s = series( 1, 2, 6, '*')               -- s is {1, 2, 4, 8, 16, 32}
    s = series({1,2,3}, 4, 2)               -- s is {{1,2,3}, {5,6,7}}
    s = series({1,2,3}, {4,-1,10}, 2)       -- s is {{1,2,3}, {5,1,13}}
Implementation: | See builtins\pseries.e (an autoinclude) for details of the actual implementation.
See Also: | tagset