Skip to content

Range ​

Generated from the engine's own definition: compute-engine's symbol, which we neither extend nor document by hand.

A sequence of numbers from a start to an end value with an optional step.

✓ checked against that system · ! checked, with disagreements (hover a chip)FungrimRangeWolfram LanguageRange✓
Range(number, number?, step: number?) -> indexed_collection<number>as compute-engine declares it
Typed signatures
TypePackageApplies
(number, number?, step: number?) -> list<number>compute-enginealways

Domain: Compute engine

Examples

Basic #

Ranges are inclusive at both ends

live ↗
In1..41..4Out[1,2,3,4]\bigl\lbrack1, 2, 3, 4\bigr\rbrack
Scope #

A step of 2 skips every other integer

live ↗
In1..3..101..3..10Out[1,3,5,7,9]\bigl\lbrack1, 3, 5, 7, 9\bigr\rbrack

A negative step counts down

live ↗
In10..9..110..9..1Out[10,9,8,7,6,5,4,3,2,1]\bigl\lbrack10, 9, 8, 7, 6, 5, 4, 3, 2, 1\bigr\rbrack

A high-precision step gives machine floats, stopping before 10

live ↗
In0..(0+3.141 592 653 589 793 238 46)..100..(0+3.141\,592\,653\,589\,793\,238\,46)..10Out[0,3.141 592 653 589 793,6.283 185 307 179 586,9.424 777 960 769 38]\bigl\lbrack0, 3.141\,592\,653\,589\,793, 6.283\,185\,307\,179\,586, 9.424\,777\,960\,769\,38\bigr\rbrack

The same range with a slightly shorter step literal gives the same floats

live ↗
In0..(0+3.141 592 653 589 793 238 46)..100..(0+3.141\,592\,653\,589\,793\,238\,46)..10Out[0,3.141 592 653 589 793,6.283 185 307 179 586,9.424 777 960 769 38]\bigl\lbrack0, 3.141\,592\,653\,589\,793, 6.283\,185\,307\,179\,586, 9.424\,777\,960\,769\,38\bigr\rbrack

A rational step materializes exact thirds, not floating-point approximations

live ↗
In0..(0+13)..30..(0+\frac{1}{3})..3Out[0,13,23,1,43,53,2,73,83,3]\bigl\lbrack0, \frac{1}{3}, \frac{2}{3}, 1, \frac{4}{3}, \frac{5}{3}, 2, \frac{7}{3}, \frac{8}{3}, 3\bigr\rbrack

Known value · Range(a, b, s): each element is a + k*s, exact over ℚ

Same for a rational step that lands on integers partway through

live ↗
In1..(1+12)..51..(1+\frac{1}{2})..5Out[1,32,2,52,3,72,4,92,5]\bigl\lbrack1, \frac{3}{2}, 2, \frac{5}{2}, 3, \frac{7}{2}, 4, \frac{9}{2}, 5\bigr\rbrack

Known value · Range(a, b, s): each element is a + k*s, exact over ℚ

live ↗
In2225..(5+2225)2^{225}..(5+2^{225})Out[53 919 893 334 301 279 589 334 030 174 039 261 347 274 288 845 081 144 962 207 220 498 432,53 919 893 334 301 279 589 334 030 174 039 261 347 274 288 845 081 144 962 207 220 498 433,53 919 893 334 301 279 589 334 030 174 039 261 347 274 288 845 081 144 962 207 220 498 434,53 919 893 334 301 279 589 334 030 174 039 261 347 274 288 845 081 144 962 207 220 498 435,53 919 893 334 301 279 589 334 030 174 039 261 347 274 288 845 081 144 962 207 220 498 436,53 919 893 334 301 279 589 334 030 174 039 261 347 274 288 845 081 144 962 207 220 498 437]\bigl\lbrack53\,919\,893\,334\,301\,279\,589\,334\,030\,174\,039\,261\,347\,274\,288\,845\,081\,144\,962\,207\,220\,498\,432, 53\,919\,893\,334\,301\,279\,589\,334\,030\,174\,039\,261\,347\,274\,288\,845\,081\,144\,962\,207\,220\,498\,433, 53\,919\,893\,334\,301\,279\,589\,334\,030\,174\,039\,261\,347\,274\,288\,845\,081\,144\,962\,207\,220\,498\,434, 53\,919\,893\,334\,301\,279\,589\,334\,030\,174\,039\,261\,347\,274\,288\,845\,081\,144\,962\,207\,220\,498\,435, 53\,919\,893\,334\,301\,279\,589\,334\,030\,174\,039\,261\,347\,274\,288\,845\,081\,144\,962\,207\,220\,498\,436, 53\,919\,893\,334\,301\,279\,589\,334\,030\,174\,039\,261\,347\,274\,288\,845\,081\,144\,962\,207\,220\,498\,437\bigr\rbrack
Applications #
live ↗
Inq1..5q^{1..5}Out[q,q2,q3,q4,q5]\bigl\lbrack q, q^2, q^3, q^4, q^5\bigr\rbrack
Properties #

Starts at −4-4 and steps by 3, stopping at 8

live ↗
In(−4)..(−1)..9(-4)..(-1)..9Out[−4,−1,2,5,8]\bigl\lbrack-4, -1, 2, 5, 8\bigr\rbrack

At reaches the same exact element, not the double it would round to

live ↗
In(0..(0+13)..3)[3](0..(0+\frac{1}{3})..3)[3]Out23\frac{2}{3}

Known value · Range(a, b, s): each element is a + k*s, exact over ℚ

The element count is exact too, not a floor of a rounded quotient

live ↗
InLength(0..(0+13)..3)\mathrm{Length}(0..(0+\frac{1}{3})..3)Out1010

Known value · Range(a, b, s): the grid runs from a to the last multiple of s at or before b

Possible issues #

The end 10 is not hit exactly, so the last element is 9

live ↗
In0..3..100..3..10Out[0,3,6,9]\bigl\lbrack0, 3, 6, 9\bigr\rbrack
About
Examples13
Checked againstWolfram Language 13 agreemathlib4 6 agree6 error
CrosswalkFungrimWolfram Language

Implementation

mappedmathlib4packages/oracle/src/mappings.ts

inclusive, counting down when the start is past the end; integer endpoints only (a rational endpoint fails to elaborate rather than rounding), read as rationals like the lane's lists

mappedmathlib4packages/oracle/src/mappings.ts

stops before an end the step misses; empty when the step is 0 or points away from the end; integer endpoints and step only (a rational or decimal one fails to elaborate rather than rounding)

mappedmathlib4packages/oracle/src/mappings.ts

Range(n) is Range(1, n), so it counts down from 1 when n is below 1; an integer n only