@@ -76,6 +76,34 @@ julia> range(1, step=5, stop=100)
76
76
range (start; length:: Union{Integer,Nothing} = nothing , stop= nothing , step= nothing ) =
77
77
_range (start, step, stop, length)
78
78
79
+ """
80
+ range(start, stop; length, step=1)
81
+
82
+ Construct a range from start and stop values,
83
+ optionally with a given step (defaults to 1, a [`UnitRange`](@ref)).
84
+ If `length` and `step` are both specified, they must agree.
85
+
86
+ If `length` is provided and `step` is not, the step size will be computed
87
+ automatically such that there are `length` linearly spaced elements in the range (a [`LinRange`](@ref)).
88
+
89
+ If `step` is provided and `length` is not, the overall range length will be computed
90
+ automatically such that the elements are `step` spaced (a [`StepRange`](@ref)).
91
+
92
+ # Examples
93
+ ```jldoctest
94
+ julia> range(1, 100)
95
+ 1:100
96
+
97
+ julia> range(1, 10, length=101)
98
+ 1.0:0.09:10.0
99
+
100
+ julia> range(1, 100, step=5)
101
+ 1:5:96
102
+ ```
103
+ """
104
+ range (start, stop; length:: Union{Integer,Nothing} = nothing , step= nothing ) =
105
+ _range (start, step, stop, length)
106
+
79
107
# Range from start to stop: range(a, [step=s,] stop=b), no length
80
108
_range (start, step, stop, :: Nothing ) = (:)(start, step, stop)
81
109
_range (start, :: Nothing , stop, :: Nothing ) = (:)(start, stop)
0 commit comments