# \#range

**URL:** https://discourse.julialang.org/tag/range/562.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Time range with reversed bounds](https://discourse.julialang.org/t/time-range-with-reversed-bounds/129693)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 5\
**Last updated:** [June 6, 2025, 4:51pm UTC](https://discourse.julialang.org/t/time-range-with-reversed-bounds/129693 "2025-06-06T16:51:12Z")

</div>

Hi, I have: using Dates lower\_bound = Dates.Time(23,59,00) upper\_bound = Dates.Time(00,01,00) I do: julia\> collect(upper\_bound:Dates.Minute(1):lower\_bound) 1439-element Vector{Time}: 00:01:00 00:02:00 00:03:00 ⋮ …

---

## [Why is there no isless(::Int64, ::UnitRange{Int64})?](https://discourse.julialang.org/t/why-is-there-no-isless-int64-unitrange-int64/112648)

<div class="topic-metadata">

**Author:** [@mnemnion](https://discourse.julialang.org/u/mnemnion)\
**Replies:** 45\
**Last updated:** [April 9, 2025, 1:54am UTC](https://discourse.julialang.org/t/why-is-there-no-isless-int64-unitrange-int64/112648 "2025-04-09T01:54:22Z")

</div>

It seems to me that all of these are unambiguous: 1 \< 4:5 == true 2 ≤ 2:5 == true 3 ≤ 2:5 == true 5 ≤ 2:5 == true 6 ≤ 2:5 == false 6 \> 2:5 == true 4 \> 2:5 == false That is, for any Int, we can derive an unambiguous a…

---

## [Concatenated ranges](https://discourse.julialang.org/t/concatenated-ranges/126042)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 7\
**Last updated:** [February 19, 2025, 4:51pm UTC](https://discourse.julialang.org/t/concatenated-ranges/126042 "2025-02-19T16:51:44Z")

</div>

For some applications concatenated ranges would be nice. E.g. it would simplify working with rotated indices, obviating the need for fftshift for some calculations. E.g. if I want to construct a suitable Gaussian in Four…

---

## [NonLinearRange](https://discourse.julialang.org/t/nonlinearrange/125221)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 7\
**Last updated:** [January 28, 2025, 8:58am UTC](https://discourse.julialang.org/t/nonlinearrange/125221 "2025-01-28T08:58:54Z")

</div>

I was looking for way to way to allow multi-kernel broadcasting to act also over non-linear ranges. E.g. consider a complex exponential exp.(1im .\* k0 .\* x) with k0=1.35 being a scalar and x=0:255 a linear range. This …

---

## [Better way to have "filled" ranges?](https://discourse.julialang.org/t/better-way-to-have-filled-ranges/122383)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 2\
**Last updated:** [November 7, 2024, 4:11pm UTC](https://discourse.julialang.org/t/better-way-to-have-filled-ranges/122383 "2024-11-07T16:11:26Z")

</div>

Is there a better (more elegant) way of the one below in order to obtain a vector representing ranges filled with the first element of the range ? years = collect(2000:2019) step = 5 desired\_res = \[2000,2000,2000,2000,…

---

## [Why are empty ranges normalized?](https://discourse.julialang.org/t/why-are-empty-ranges-normalized/109836)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 5\
**Last updated:** [February 7, 2024, 8:55am UTC](https://discourse.julialang.org/t/why-are-empty-ranges-normalized/109836 "2024-02-07T08:55:16Z")

</div>

What the motivation for this normalization? julia\> 5:1 5:4

---

## [The colon punctuation: Why doesn't 5:1 return \[5, 4, 3, 2, 1\]?](https://discourse.julialang.org/t/the-colon-punctuation-why-doesnt-5-1-return-5-4-3-2-1/107676)

<div class="topic-metadata">

**Author:** [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Replies:** 8\
**Last updated:** [December 16, 2023, 6:04pm UTC](https://discourse.julialang.org/t/the-colon-punctuation-why-doesnt-5-1-return-5-4-3-2-1/107676 "2023-12-16T18:04:19Z")

</div>

I got surprised by this: julia\> 1:5 # Expected 1:5 julia\> 5:1 # Unexpected 5:4 julia\> collect(1:5) # Expected 5-element Vector{Int64}: 1 2 3 4 5 julia\> collect(5:1) # Doubly Unexpected Int64\[\] julia\> collect(5:…

---

## [Should we disallow non-compliant \`AbstractUnitRange\`s where \`typeof(step)\` doesn't match the \`eltype\`?](https://discourse.julialang.org/t/should-we-disallow-non-compliant-abstractunitrange-s-where-typeof-step-doesnt-match-the-eltype/101695)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 7\
**Last updated:** [July 17, 2023, 8:13pm UTC](https://discourse.julialang.org/t/should-we-disallow-non-compliant-abstractunitrange-s-where-typeof-step-doesnt-match-the-eltype/101695 "2023-07-17T20:13:33Z")

</div>

Currently, the docstring for AbstractUnitRange states: AbstractUnitRange{T} \<: OrdinalRange{T, T} Supertype for ranges with a step size of \`oneunit(T)\` with elements of type \`T\`. This implies that the step must be…

---

## [Stop of a range with length 0](https://discourse.julialang.org/t/stop-of-a-range-with-length-0/99865)

<div class="topic-metadata">

**Author:** [@abs](https://discourse.julialang.org/u/abs)\
**Replies:** 3\
**Last updated:** [June 5, 2023, 6:49am UTC](https://discourse.julialang.org/t/stop-of-a-range-with-length-0/99865 "2023-06-05T06:49:29Z")

</div>

Just curious: For the following kind of ranges of length 0, please note the submitted stop and returned julia\> 12:1:\*\*3\*\* 12:1:\*\*11\*\* julia\> range(12,\*\*stop=3\*\*;step = 1) 12:1:\*\*11\*\* Is this by design? \_range(start:…

---

## [Unusual empty \`UnitRange\`s while reinterpreting a vector](https://discourse.julialang.org/t/unusual-empty-unitrange-s-while-reinterpreting-a-vector/92546)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 4\
**Last updated:** [January 5, 2023, 5:25pm UTC](https://discourse.julialang.org/t/unusual-empty-unitrange-s-while-reinterpreting-a-vector/92546 "2023-01-05T17:25:51Z")

</div>

julia\> r = reinterpret(UnitRange{Int}, \[1,-1\])\[1\] 1:-1 julia\> isempty(r) true julia\> length(r) # source of errors -1 julia\> 1:-1 # the constructor changes the endpoint to ensure that the length is zero 1:0 julia\> r =…

---

## [(why) is there no Abstract Collection type](https://discourse.julialang.org/t/why-is-there-no-abstract-collection-type/89233)

<div class="topic-metadata">

**Author:** [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Replies:** 11\
**Last updated:** [November 4, 2022, 5:13pm UTC](https://discourse.julialang.org/t/why-is-there-no-abstract-collection-type/89233 "2022-11-04T17:13:22Z")

</div>

Hi everyone, A common code pattern seems to be: function thingthatiterates(x, collection::AbstractArray) for i in collection ... end end Now in some cases, it might be better to use something non-allocating …

---

## [AbstractVector vs AbstractRange: length vs size -- which is fundamental?](https://discourse.julialang.org/t/abstractvector-vs-abstractrange-length-vs-size-which-is-fundamental/64689)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 3\
**Last updated:** [July 28, 2022, 9:01pm UTC](https://discourse.julialang.org/t/abstractvector-vs-abstractrange-length-vs-size-which-is-fundamental/64689 "2022-07-28T21:01:17Z")

</div>

It appears that julia master has changed a behavior from previous versions, and now size for an AbstractRange is defined as (length(r),) instead of the previous behavior where length was defined as prod(size(r)). This ma…

---

## [Is there a way to bring the range of a summation back from an array?](https://discourse.julialang.org/t/is-there-a-way-to-bring-the-range-of-a-summation-back-from-an-array/81937)

<div class="topic-metadata">

**Author:** [@vicentemunozlh](https://discourse.julialang.org/u/vicentemunozlh)\
**Replies:** 7\
**Last updated:** [May 31, 2022, 9:24pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-bring-the-range-of-a-summation-back-from-an-array/81937 "2022-05-31T21:24:10Z")

</div>

Hello, I am new to Julia and trying to model a relatively complicated optimization problem from other lenguage(GAMS). I am stuck in trying to apply a summation in a constraint and its depndence index to be in a range pr…

---

## [Strange behavior of Range object](https://discourse.julialang.org/t/strange-behavior-of-range-object/72048)

<div class="topic-metadata">

**Author:** [@mottelet](https://discourse.julialang.org/u/mottelet)\
**Replies:** 1\
**Last updated:** [November 25, 2021, 9:37am UTC](https://discourse.julialang.org/t/strange-behavior-of-range-object/72048 "2021-11-25T09:37:53Z")

</div>

Hello, I am wondering why a “potentially” empty (when collected) range such as 10:1 is echoed differently (although equivalently empty) julia\> 10:1 10:9 S.

---

## [Is this a bug (scalar+ranges) with the parser?](https://discourse.julialang.org/t/is-this-a-bug-scalar-ranges-with-the-parser/70670)

<div class="topic-metadata">

**Author:** [@Noel\_Araujo](https://discourse.julialang.org/u/Noel_Araujo)\
**Replies:** 9\
**Last updated:** [October 31, 2021, 9:06am UTC](https://discourse.julialang.org/t/is-this-a-bug-scalar-ranges-with-the-parser/70670 "2021-10-31T09:06:41Z")

</div>

I want to add one scalar value with all value of a unitRange. Naively, I would do the x = 1:5 .+ 0.5 code, but I realize that actually the parser is doing y=1:(5 .+ 0.5). Below a full example: expected = \[1,2,3,4,5\] .+…

---

## [UnitRange in 1.7-rc1, bug?](https://discourse.julialang.org/t/unitrange-in-1-7-rc1-bug/68327)

<div class="topic-metadata">

**Author:** [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Replies:** 7\
**Last updated:** [September 17, 2021, 2:01pm UTC](https://discourse.julialang.org/t/unitrange-in-1-7-rc1-bug/68327 "2021-09-17T14:01:37Z")

</div>

(1:5) .- 1/7 in 1.7-rc1 (Win64) gives 0.8571428571428572:1.0:3.857142857142857, while 1.6.2 gives (the more reasonable) 0.8571428571428572:1.0:4.857142857142858 Can anyone confirm? If so, I’ll file an issue.

---

## [Inconsistency in interpreting and indexing with ranges of CartesianIndexes if a step is specified while constructing them](https://discourse.julialang.org/t/inconsistency-in-interpreting-and-indexing-with-ranges-of-cartesianindexes-if-a-step-is-specified-while-constructing-them/66828)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 1\
**Last updated:** [August 23, 2021, 5:48am UTC](https://discourse.julialang.org/t/inconsistency-in-interpreting-and-indexing-with-ranges-of-cartesianindexes-if-a-step-is-specified-while-constructing-them/66828 "2021-08-23T05:48:47Z")

</div>

This is related to the issue https://github.com/JuliaLang/julia/issues/41959, but I didn’t want to derail the issue so thought I would continue the conversation on discourse. Fundamentally, CartesianIndices represent an…

---

## [Help understand the role of semicolon in turning a UnitRange to a Vector](https://discourse.julialang.org/t/help-understand-the-role-of-semicolon-in-turning-a-unitrange-to-a-vector/64856)

<div class="topic-metadata">

**Author:** [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Replies:** 6\
**Last updated:** [July 18, 2021, 1:41pm UTC](https://discourse.julialang.org/t/help-understand-the-role-of-semicolon-in-turning-a-unitrange-to-a-vector/64856 "2021-07-18T13:41:53Z")

</div>

I understand the difference between the UnitRange and Array/Vector types. I sort of get the syntax for stacking two ranges and converting them into a vector using ; and \[\] as in julia\> a = \[1:3;4:5\] 5-element Vector{Int…

---

## [Creation of range along given dimension](https://discourse.julialang.org/t/creation-of-range-along-given-dimension/56747)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 5\
**Last updated:** [March 10, 2021, 9:13am UTC](https://discourse.julialang.org/t/creation-of-range-along-given-dimension/56747 "2021-03-10T09:13:42Z")

</div>

I currently have to handle multi-dimensional data, where I have to compute several broadcasting operations with ranges. In 2D I use e.g (1:10) .\* (1:5)' which gives a nice matrix. The first vector is of type UnitRange…

---

## [Range(stop)](https://discourse.julialang.org/t/range-stop/53478)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 17\
**Last updated:** [January 22, 2021, 11:24pm UTC](https://discourse.julialang.org/t/range-stop/53478 "2021-01-22T23:24:03Z")

</div>

Should Julia have a range(stop) similar to the Python range(stop)? In Julia master (1.7.0-DEV), we recently merged an all keyword range(; start, stop, length, step) in #38041. In addition to allowing all range arguments…
