Site Tools


jot

# $EPIC: jot.txt,v 1.2 2006/08/01 03:50:35 sthalik Exp $

Synopsis:

$jot(<start> <stop> <interval>)

Technical:

  • If the <start> argument is omitted the empty string is returned.
  • If the <stop> argument is omitted the empty string is returned.
  • If the <interval> argument is omitted the default value of 1 is used.
  • If the <interval> argument is 0, the empty string is returned.
  • The <interval> argument should be an integer value – support for fractional numbers will be added in the future.
  • The <interval> argument should be positive; but if you specify a negative value, the absolute value of <interval> will be used.
  • If <start> is less than <stop>, then consider the sequence
    [<start>, <start>+<interval>, <start>+<interval>+<interval>, … <L>], where <L> is less than or equal to <stop>.
  • If <start> is greater than <stop>, then consider the sequence
    [<start>, <start>-<interval>, <start>-<interval>-<interval>, … <L>], where <L> is greater than or equal to <stop>.
  • This function returns a list of words that correspond to the elements in the smallest sequence that models the appropriate sequence.

Practical:

This function creates a list of all of the numbers between <start> and <stop>, with a step of <interval>. Ranges can be ascending or descending, depending on whether <stop> is greater than or less than <start>. You can iterate over the return value with FE or FOR i IN. Another popular use is to pass the return value to $chr() to create a range of ascii characters.

Returns:

Every <interval>th number between <start> and <stop>, inclusive.

Examples:

$jot(2 6)             returns "2 3 4 5 6"
$jot(2 7 2)           returns "2 4 6"
$jot(3 -2)            returns "3 2 1 0 -1 -2"
$jot(4)               returns ""  (empty string)
$jot(4 6 8)           returns "4"
$jot(a 4)             returns "0"
jot.txt · Last modified: 2006/08/01 04:13 by 127.0.0.1