WOLFRAM

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)Summary of the most common use cases

Out[1]=1
Out[1]=1
Out[1]=1

Scope  (6)Survey of the scope of standard use cases

Use a step of 2:

Out[1]=1

Use a negative step:

Out[1]=1

Use an exact numeric-valued step:

Out[1]=1

Use a machine-number step:

Out[1]=1

Use a precision-24 step:

Out[1]=1

Range of very large numbers:

Out[1]=1

Generalizations & Extensions  (2)Generalized and extended use cases

Use a symbolic step:

Out[1]=1

Use a list of range specifications:

Out[1]=1

Applications  (4)Sample problems that can be solved with this function

Produce a geometric sequence:

Out[1]=1

Form a polynomial from coefficients:

Out[2]=2

Form a random permutation:

Out[1]=1

Find an inverse permutation:

Out[1]=1
Out[2]=2

Properties & Relations  (2)Properties of the function, and connections to other functions

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

Out[1]=1
Out[2]=2

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

Out[2]=2
Out[3]=3

Possible Issues  (3)Common pitfalls and unexpected behavior

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

Out[1]=1

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

Out[1]=1

Range accepts Quantity expressions as limits and steps:

Out[1]=1

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

Out[2]=2
Out[3]=3
Out[4]=4

Neat Examples  (1)Surprising or curious use cases

Make nested ranges:

Out[1]=1
Out[2]=2
Out[3]=3

Show it in tree form:

Wolfram Research (1988), Range, Wolfram Language function, https://reference.wolfram.com/language/ref/Range.html.
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.

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.

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

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

BibTeX

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

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

BibLaTeX

@online{reference.wolfram_2025_range, organization={Wolfram Research}, title={Range}, year={1988}, url={https://reference.wolfram.com/language/ref/Range.html}, note=[Accessed: 01-April-2025 ]}

@online{reference.wolfram_2025_range, organization={Wolfram Research}, title={Range}, year={1988}, url={https://reference.wolfram.com/language/ref/Range.html}, note=[Accessed: 01-April-2025 ]}