Range

Range[imax]

generates the list {1,2,,imax}.

Range[imin,imax]

generates the list {imin,,imax}.

Range[imin,imax,di]

uses step di.

Details

  • The arguments to Range need not be integers.
  • Range starts from imin and successively adds increments of di until the result is greater than imax.
  • Range uses the standard Wolfram Language iteration specification, as applied to a single variable.
  • Range has attribute Listable.

Examples

open allclose all

Basic Examples  (3)

Scope  (6)

Use a step of 2:

Use a negative step:

Use an exact numeric-valued step:

Use a machine-number step:

Use a precision-24 step:

Range of very large numbers:

Generalizations & Extensions  (2)

Use a symbolic step:

Use a list of range specifications:

Applications  (4)

Produce a geometric sequence:

Form a polynomial from coefficients:

Form a random permutation:

Find an inverse permutation:

Properties & Relations  (2)

Range[imin,imax,di] is equivalent to Table[i,{imin,imax,di}]:

Use Range or Span (;;) as Part specification:

Possible Issues  (3)

For some step sizes, Range may not include the upper limit given:

Even though the lower limit was exact, the inexact step makes the first element inexact:

Range accepts Quantity expressions as limits and steps:

For Quantity expressions, Precision is taken into account when determining whether elements are within the bounds of the limits:

Neat Examples  (1)

Make nested ranges:

Show it in tree form:

Wolfram Research (1988), Range, Wolfram Language function, https://reference.wolfram.com/language/ref/Range.html.

Text

Wolfram Research (1988), Range, Wolfram Language function, https://reference.wolfram.com/language/ref/Range.html.

CMS

Wolfram Language. 1988. "Range." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Range.html.

APA

Wolfram Language. (1988). Range. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Range.html

BibTeX

@misc{reference.wolfram_2024_range, author="Wolfram Research", title="{Range}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/Range.html}", note=[Accessed: 17-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_range, organization={Wolfram Research}, title={Range}, year={1988}, url={https://reference.wolfram.com/language/ref/Range.html}, note=[Accessed: 17-November-2024 ]}