# \#collection

**URL:** https://discourse.julialang.org/tag/collection/323.md

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

---

## [Recommended idiom for collecting narrowest type](https://discourse.julialang.org/t/recommended-idiom-for-collecting-narrowest-type/136604)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 16\
**Last updated:** [April 10, 2026, 1:59am UTC](https://discourse.julialang.org/t/recommended-idiom-for-collecting-narrowest-type/136604 "2026-04-10T01:59:47Z")

</div>

Suppose I have a Vector with an abstract element type. What is the recommended idiom for collecting the elements into a vector with the narrowest possible element type? MWE: struct Foo{T} x::T end X = Foo\[Foo(1), Fo…

---

## [New package: Collects.jl - meant to improve upon and generalize the interface of collect](https://discourse.julialang.org/t/new-package-collects-jl-meant-to-improve-upon-and-generalize-the-interface-of-collect/129468)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 9\
**Last updated:** [February 17, 2026, 11:36pm UTC](https://discourse.julialang.org/t/new-package-collects-jl-meant-to-improve-upon-and-generalize-the-interface-of-collect/129468 "2026-02-17T23:36:31Z")

</div>

Just requested the registration of the new package, Collects.jl, meaning it should be registered after three days pass. Basically it’s meant to replace collect, especially when the desired output container type is not A…

---

## [Wanted: an API for merging sorted collections](https://discourse.julialang.org/t/wanted-an-api-for-merging-sorted-collections/115722)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 1\
**Last updated:** [June 16, 2024, 6:57pm UTC](https://discourse.julialang.org/t/wanted-an-api-for-merging-sorted-collections/115722 "2024-06-16T18:57:56Z")

</div>

I don’t think there’s a public function for the merge algorithm anywhere in Julia or the ecosystem. It’s what merge sort is based on. Wikipedia introduces merging like this: Merge algorithms are a family of algorithms …

---

## [I don't get Base.IteratorElType](https://discourse.julialang.org/t/i-dont-get-base-iteratoreltype/113604)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 6\
**Last updated:** [April 30, 2024, 7:50am UTC](https://discourse.julialang.org/t/i-dont-get-base-iteratoreltype/113604 "2024-04-30T07:50:15Z")

</div>

Motivation I’m implementing a collect-like function for a certain subtype of AbstractArray, FixedSizeArray (@giordano). The function is supposed to take an arbitrary iterator, consume it, and return a FixedSizeArray valu…

---

## [Iteration with companion matrix to make future estimates](https://discourse.julialang.org/t/iteration-with-companion-matrix-to-make-future-estimates/88911)

<div class="topic-metadata">

**Author:** [@Filippati](https://discourse.julialang.org/u/Filippati)\
**Replies:** 1\
**Last updated:** [October 19, 2022, 9:11am UTC](https://discourse.julialang.org/t/iteration-with-companion-matrix-to-make-future-estimates/88911 "2022-10-19T09:11:21Z")

</div>

Hello everyone, I have just started to learn Julia, and Julia is the only language with which I’ve worked for more than 3 months, so I am new to programming in general. I need to make 46 future quarterly estimates of in…

---

## [RGB has a length but no iterate?](https://discourse.julialang.org/t/rgb-has-a-length-but-no-iterate/84446)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 2\
**Last updated:** [July 19, 2022, 9:34am UTC](https://discourse.julialang.org/t/rgb-has-a-length-but-no-iterate/84446 "2022-07-19T09:34:36Z")

</div>

I’m defining a handy function for me to flatten data recursively into matrices and tensors. One way to do it is to descend into the list-of-lists until we see something with length(x)==1, and then we consider that to be …

---

## [Edge case in Sets with Floats](https://discourse.julialang.org/t/edge-case-in-sets-with-floats/78787)

<div class="topic-metadata">

**Author:** [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Replies:** 6\
**Last updated:** [March 31, 2022, 12:25pm UTC](https://discourse.julialang.org/t/edge-case-in-sets-with-floats/78787 "2022-03-31T12:25:00Z")

</div>

Hi Julia Community, recently I was approached by a colleague who just got started with Julia and ran into a problem that took him ages to debug. We then seat down together and could come up with the following MWE: juli…

---

## [Mutable sorted collections](https://discourse.julialang.org/t/mutable-sorted-collections/64938)

<div class="topic-metadata">

**Author:** [@Mark\_Nahabedian](https://discourse.julialang.org/u/Mark_Nahabedian)\
**Replies:** 7\
**Last updated:** [July 20, 2021, 6:13pm UTC](https://discourse.julialang.org/t/mutable-sorted-collections/64938 "2021-07-20T18:13:07Z")

</div>

I don’t understand what the use case for SortedSet is. It seems to only collect and sort keys, with no values associated with those keys. I have a homogeneous collection of structs (points of a parameterized curve in a …

---

## [Correctly initializing collection of matrices](https://discourse.julialang.org/t/correctly-initializing-collection-of-matrices/62116)

<div class="topic-metadata">

**Author:** [@nandoconde](https://discourse.julialang.org/u/nandoconde)\
**Replies:** 5\
**Last updated:** [May 31, 2021, 10:13am UTC](https://discourse.julialang.org/t/correctly-initializing-collection-of-matrices/62116 "2021-05-31T10:13:55Z")

</div>

Hello! I am following suggestions from another post and, instead of having a 3-D array, I am refactoring my code to use a Vector of Matrix so I can use broadcasting on the matrices. Is there a way to initialize the who…

---

## [Intrusive Collections in Julia](https://discourse.julialang.org/t/intrusive-collections-in-julia/59381)

<div class="topic-metadata">

**Author:** [@bjkaria](https://discourse.julialang.org/u/bjkaria)\
**Replies:** 9\
**Last updated:** [April 20, 2021, 3:33am UTC](https://discourse.julialang.org/t/intrusive-collections-in-julia/59381 "2021-04-20T03:33:33Z")

</div>

Would intrusive collections modeled after the boost intrusive boost intrusive 1.75.0 collection be a useful addition for Julia. Does Julia already have mechanisms which make such collections superfluous. Consider the ad…

---

## [Preventing collect on broadcasting expressions](https://discourse.julialang.org/t/preventing-collect-on-broadcasting-expressions/57996)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 6\
**Last updated:** [March 27, 2021, 2:22pm UTC](https://discourse.julialang.org/t/preventing-collect-on-broadcasting-expressions/57996 "2021-03-27T14:22:20Z")

</div>

In writing efficient code for image processing, views are incredibly useful. They can nicely be chained for example to implement a phasor in optics propagation: using IndexFunArrays k0 = 5; phasor = exp.(1im .\* 2pi .\*sq…

---

## [Collecting homogenized vectors: modify iterator vs modify collector](https://discourse.julialang.org/t/collecting-homogenized-vectors-modify-iterator-vs-modify-collector/42957)

<div class="topic-metadata">

**Author:** [@BMO](https://discourse.julialang.org/u/BMO)\
**Replies:** 3\
**Last updated:** [September 30, 2020, 5:24pm UTC](https://discourse.julialang.org/t/collecting-homogenized-vectors-modify-iterator-vs-modify-collector/42957 "2020-09-30T17:24:38Z")

</div>

Nemo is a computer algebra package for the Julia programming language. For a multivariated polynomial p there is an iterator exponent\_vectors(p) whose values are vectors corresponding to the exponents of the terms of p (…

---

## [What is the agreed abstraction for the "size" of finite collections?](https://discourse.julialang.org/t/what-is-the-agreed-abstraction-for-the-size-of-finite-collections/32757)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 38\
**Last updated:** [December 31, 2019, 12:42pm UTC](https://discourse.julialang.org/t/what-is-the-agreed-abstraction-for-the-size-of-finite-collections/32757 "2019-12-31T12:42:27Z")

</div>

Suppose I have a type that is a collection of samples (e.g. DataFrame). Unlike a simple Vector for which the name length can be used to retrieve the number of elements, my type doesn’t have the function length, but inste…
