# \#vector

**URL:** https://discourse.julialang.org/tag/vector/354.md

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

---

## [Accessing a column from a vector of vectors](https://discourse.julialang.org/t/accessing-a-column-from-a-vector-of-vectors/136722)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 9\
**Last updated:** [June 2, 2026, 10:45am UTC](https://discourse.julialang.org/t/accessing-a-column-from-a-vector-of-vectors/136722 "2026-06-02T10:45:25Z")

</div>

Hi, I have something like: a = \[\["a", "1" ,"11"\], \["b", "2" ,"22"\], \["c", "3" ,"33"\]\] 3-element Vector{Vector{String}}: \["a", "1", "11"\] \["b", "2", "22"\] \["c", "3", "33"\] And I would like to get e.g. th…

---

## [Inferring the return type of an operation on two variables](https://discourse.julialang.org/t/inferring-the-return-type-of-an-operation-on-two-variables/134778)

<div class="topic-metadata">

**Author:** [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Replies:** 2\
**Last updated:** [December 29, 2025, 4:09pm UTC](https://discourse.julialang.org/t/inferring-the-return-type-of-an-operation-on-two-variables/134778 "2025-12-29T16:09:32Z")

</div>

Suppose I have two vectors: A::Vector{Type1} and B::Vector{Type2}. I want to create a vector C::Vector{Type3} where Type3 is the type of a \* b, where a and b are elements of A and B, respectively. A basic example of thi…

---

## [What is the most fitting container in foreach](https://discourse.julialang.org/t/what-is-the-most-fitting-container-in-foreach/133775)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 6\
**Last updated:** [November 10, 2025, 2:02pm UTC](https://discourse.julialang.org/t/what-is-the-most-fitting-container-in-foreach/133775 "2025-11-10T14:02:29Z")

</div>

It’s a small question but I have an impulse to ask: I find that the generator is lazy julia\> const a = fill(0, 4); julia\> function f!(i) i == 3 && error() a\[i\] = i -i end; juli…

---

## [\[ANN\] SmallCollections.jl: fast small vectors, sets and dictionaries](https://discourse.julialang.org/t/ann-smallcollections-jl-fast-small-vectors-sets-and-dictionaries/128787)

<div class="topic-metadata">

**Author:** [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Replies:** 9\
**Last updated:** [November 7, 2025, 1:01pm UTC](https://discourse.julialang.org/t/ann-smallcollections-jl-fast-small-vectors-sets-and-dictionaries/128787 "2025-11-07T13:01:55Z")

</div>

The standard container types in Julia (Vector, Set, Dict) can hold an arbitrary number of elements. If the size is known in advance, one can use dedicated types like SVector or MVector from StaticArrays.jl that are much …

---

## [Plotting function returning complex vector](https://discourse.julialang.org/t/plotting-function-returning-complex-vector/130393)

<div class="topic-metadata">

**Author:** [@rokke](https://discourse.julialang.org/u/rokke)\
**Replies:** 7\
**Last updated:** [July 2, 2025, 8:34am UTC](https://discourse.julialang.org/t/plotting-function-returning-complex-vector/130393 "2025-07-02T08:34:02Z")

</div>

I have some functions which each return a constant n number of complex values, and would like to plot one as a series of lines on the complex plane. if I do something like plot(real.(\[f.(0.1:.1:5)...;;\]'),-imag.(\[f.(0.1…

---

## [Literal expression for array of vectors](https://discourse.julialang.org/t/literal-expression-for-array-of-vectors/130184)

<div class="topic-metadata">

**Author:** [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Replies:** 12\
**Last updated:** [June 25, 2025, 1:06pm UTC](https://discourse.julialang.org/t/literal-expression-for-array-of-vectors/130184 "2025-06-25T13:06:12Z")

</div>

Is there an array literal that gives me this object (and a variation with some integer elements in some of the vectors)? julia\> ... 3×5 Matrix{Vector{Int64}}: \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] \[\] …

---

## [How to get ranges of valid data in vectors or dataframes?](https://discourse.julialang.org/t/how-to-get-ranges-of-valid-data-in-vectors-or-dataframes/129985)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 7\
**Last updated:** [June 23, 2025, 6:59pm UTC](https://discourse.julialang.org/t/how-to-get-ranges-of-valid-data-in-vectors-or-dataframes/129985 "2025-06-23T18:59:08Z")

</div>

Hi, using DataFrames df = DataFrame(col1 = \[1, NaN, 3, 4, NaN, 6, 7, 8, 9, 10, NaN, NaN\], col2 = \[missing, 2, 3, 4, 5, 6, missing, 8, 9, 10, 11, 12\]) 12×2 DataFrame Row │ col1 col2 │ Float64 Int64? ──…

---

## [Get the transpose of Vector{Vector{Float64}}](https://discourse.julialang.org/t/get-the-transpose-of-vector-vector-float64/128141)

<div class="topic-metadata">

**Author:** [@15et7dtwq](https://discourse.julialang.org/u/15et7dtwq)\
**Replies:** 9\
**Last updated:** [April 17, 2025, 8:36pm UTC](https://discourse.julialang.org/t/get-the-transpose-of-vector-vector-float64/128141 "2025-04-17T20:36:50Z")

</div>

I am coming from numpy, trying tosee if Julia can be faster. Right now I am dealing with a function that generates for me what I thought had to be a matrix, but no, it’s a vector of vector. Fine. How do I make it’s trans…

---

## [Repeat and reshape vector into a matrix](https://discourse.julialang.org/t/repeat-and-reshape-vector-into-a-matrix/127451)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 9\
**Last updated:** [March 28, 2025, 9:13pm UTC](https://discourse.julialang.org/t/repeat-and-reshape-vector-into-a-matrix/127451 "2025-03-28T21:13:31Z")

</div>

Hi, this is a Python code I’m translating in Julia: import numpy as np val = \[1,2,3,4,5,6\] val\_length = len(val) rpt = 3 np.repeat(val, rpt).reshape((val\_length, rpt)) It gives: \>\>\> val = \[1,2,3,4,5,6\] \>\>\> val\_leng…

---

## [Writing code that works allocation-free on both vectors and SVectors](https://discourse.julialang.org/t/writing-code-that-works-allocation-free-on-both-vectors-and-svectors/127048)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 6\
**Last updated:** [March 17, 2025, 11:59am UTC](https://discourse.julialang.org/t/writing-code-that-works-allocation-free-on-both-vectors-and-svectors/127048 "2025-03-17T11:59:58Z")

</div>

I’d like to write generic code that operates on abstract vectors, and is non-allocating. A specific example is a function that subtracts the mean and normalizes a vector. This can be done in-place. However, the problem w…

---

## [Slicing a Vector into a Matrix using views](https://discourse.julialang.org/t/slicing-a-vector-into-a-matrix-using-views/126918)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 13\
**Last updated:** [March 16, 2025, 11:06am UTC](https://discourse.julialang.org/t/slicing-a-vector-into-a-matrix-using-views/126918 "2025-03-16T11:06:07Z")

</div>

Hi, I loaded data from a simple file input.txt: 1 2 3 4 5 6 7 8 9 into a vector with: data = CSV.File("input.txt", ntasks=1, header=false).Column1 So it’s equivalent to: julia\> data = \[1,2,3,4,5,6,7,8,9\] 9…

---

## [Storing sortedness for numeric vectors](https://discourse.julialang.org/t/storing-sortedness-for-numeric-vectors/124381)

<div class="topic-metadata">

**Author:** [@ajinkya-k](https://discourse.julialang.org/u/ajinkya-k)\
**Replies:** 14\
**Last updated:** [January 4, 2025, 11:07pm UTC](https://discourse.julialang.org/t/storing-sortedness-for-numeric-vectors/124381 "2025-01-04T23:07:17Z")

</div>

Hello! I was wondering if it would be a good idea to store whether a numeric Vector is sorted in the vector struct itself. The current implementation Vector has the fields (:ref,:size), what I am suggesting for numeric …

---

## [Strange error message when using maximum()](https://discourse.julialang.org/t/strange-error-message-when-using-maximum/122889)

<div class="topic-metadata">

**Author:** [@dnldlg](https://discourse.julialang.org/u/dnldlg)\
**Replies:** 9\
**Last updated:** [November 21, 2024, 1:54pm UTC](https://discourse.julialang.org/t/strange-error-message-when-using-maximum/122889 "2024-11-21T13:54:12Z")

</div>

Hello everyone, I encounter a strange error when using the maximum function on Julia v1.10.6. Let’s look at a variable Na, which is a vector of integers. Example code: println(Na) println(typeof(Na)) println(typeof(Na…

---

## [How to convert a dataframe into a 1-D vector, line by line?](https://discourse.julialang.org/t/how-to-convert-a-dataframe-into-a-1-d-vector-line-by-line/122594)

<div class="topic-metadata">

**Author:** [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Replies:** 6\
**Last updated:** [November 14, 2024, 4:29pm UTC](https://discourse.julialang.org/t/how-to-convert-a-dataframe-into-a-1-d-vector-line-by-line/122594 "2024-11-14T16:29:19Z")

</div>

Hi, I have a dataframe looking like: using DataFrames df = DataFrame(a=1:4, b=5:8) 4×2 DataFrame Row │ a b │ Int64 Int64 ─────┼────────────── 1 │ 1 5 2 │ 2 6 3 │ 3 …

---

## [Slicing array on julia 4000ms vs c++ 400ms](https://discourse.julialang.org/t/slicing-array-on-julia-4000ms-vs-c-400ms/122389)

<div class="topic-metadata">

**Author:** [@tradingtsm](https://discourse.julialang.org/u/tradingtsm)\
**Replies:** 24\
**Last updated:** [November 10, 2024, 2:17am UTC](https://discourse.julialang.org/t/slicing-array-on-julia-4000ms-vs-c-400ms/122389 "2024-11-10T02:17:04Z")

</div>

Hi everyone, I’ve trying to compare a function, on slicing an array on cpp vs julia, I get different results as I wrote on the title and I don’t understand why, would appreaciate your help. I’m using custom data for th…

---

## [When to use Tuples instead of Vectors?](https://discourse.julialang.org/t/when-to-use-tuples-instead-of-vectors/119109)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 16\
**Last updated:** [September 6, 2024, 3:42pm UTC](https://discourse.julialang.org/t/when-to-use-tuples-instead-of-vectors/119109 "2024-09-06T15:42:49Z")

</div>

Hello, I’m developing QuantumToolbox.jl for simulating quantum systems in Julia. Everything is based on the QuantumObject constructor, which is currently defined as follows struct QuantumObject{MT\<:AbstractArray,ObjTyp…

---

## [Vector to Matrix. How to do it generally](https://discourse.julialang.org/t/vector-to-matrix-how-to-do-it-generally/118579)

<div class="topic-metadata">

**Author:** [@martin\_sanchez](https://discourse.julialang.org/u/martin_sanchez)\
**Replies:** 2\
**Last updated:** [August 25, 2024, 9:25am UTC](https://discourse.julialang.org/t/vector-to-matrix-how-to-do-it-generally/118579 "2024-08-25T09:25:56Z")

</div>

I have a DataFrame, and I am creating a function that receives it, extracts a few columns and convert those columns into a matrix. I was using Matrix{T}(df) and it worked, but when the slected columns turn to be 1, it sa…

---

## [Suggestion for enhanced \`sizehint!\`](https://discourse.julialang.org/t/suggestion-for-enhanced-sizehint/118051)

<div class="topic-metadata">

**Author:** [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Replies:** 5\
**Last updated:** [August 12, 2024, 9:09am UTC](https://discourse.julialang.org/t/suggestion-for-enhanced-sizehint/118051 "2024-08-12T09:09:12Z")

</div>

I have a couple of times had the following problem. An algorithm which uses a vector v and does some push! and some pushfirst!. I know in advance the maximum number of pushfirst!, and the maximum number of push! that mig…

---

## [Problem with creating view of vectors in vector of vectors (it keeps allocating)](https://discourse.julialang.org/t/problem-with-creating-view-of-vectors-in-vector-of-vectors-it-keeps-allocating/116825)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 2\
**Last updated:** [July 9, 2024, 3:20pm UTC](https://discourse.julialang.org/t/problem-with-creating-view-of-vectors-in-vector-of-vectors-it-keeps-allocating/116825 "2024-07-09T15:20:58Z")

</div>

I have a problem where Julai keeps allocating, causing something I think should be fast to be slow. Simple example: vec\_vec = \[1:100 for i in 1:100\] @time vals = \[vec for vec in vec\_vec\] # Fast, few allocations @time va…

---

## [Update Vector with dot Operator - Different Behavior when using Vector and Other Types](https://discourse.julialang.org/t/update-vector-with-dot-operator-different-behavior-when-using-vector-and-other-types/116138)

<div class="topic-metadata">

**Author:** [@Andy\_Zhang](https://discourse.julialang.org/u/Andy_Zhang)\
**Replies:** 1\
**Last updated:** [June 24, 2024, 12:38pm UTC](https://discourse.julialang.org/t/update-vector-with-dot-operator-different-behavior-when-using-vector-and-other-types/116138 "2024-06-24T12:38:10Z")

</div>

Here is a piece of code: v1 = \[2, 3, 5, 7, 11, 13, 17\] @show v1 v1\[1:3\] = \[1, 2, 3\] @show v1 v1\[1:3\] .= 0 @show v1 v1\[1:3\] .= \[4, 5, 6\] @show v1 v1\[1:3\] .= "1" Output: v1 = \[2, 3, 5, 7, 11, 13, 17\] v1 = \[1, 2, 3, 7, 1…

---

## [Slicing vector into matrix](https://discourse.julialang.org/t/slicing-vector-into-matrix/115844)

<div class="topic-metadata">

**Author:** [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Replies:** 1\
**Last updated:** [June 19, 2024, 9:19am UTC](https://discourse.julialang.org/t/slicing-vector-into-matrix/115844 "2024-06-19T09:19:15Z")

</div>

How to do this ? If there is a function? I have a large vector with repeating numbers after some interval. I want to slice it just like how showed in second output. Thank you :slight\_smile: julia\> a = \[1, 1, 1, 1, 2,…

---

## [Why is \`getindex\` slower the second time in a vector of vectors?](https://discourse.julialang.org/t/why-is-getindex-slower-the-second-time-in-a-vector-of-vectors/113819)

<div class="topic-metadata">

**Author:** [@alex180500](https://discourse.julialang.org/u/alex180500)\
**Replies:** 7\
**Last updated:** [May 5, 2024, 1:56pm UTC](https://discourse.julialang.org/t/why-is-getindex-slower-the-second-time-in-a-vector-of-vectors/113819 "2024-05-05T13:56:15Z")

</div>

Why is in this function calling the getindex method the second time slower? This function (the smallest working example I could make) is a snippet of a bigger project I’m making on agent based models where I choose a ra…

---

## [Performance issue: Axelrod model of dissemination of culture optimization](https://discourse.julialang.org/t/performance-issue-axelrod-model-of-dissemination-of-culture-optimization/113326)

<div class="topic-metadata">

**Author:** [@alex180500](https://discourse.julialang.org/u/alex180500)\
**Replies:** 6\
**Last updated:** [April 22, 2024, 1:30pm UTC](https://discourse.julialang.org/t/performance-issue-axelrod-model-of-dissemination-of-culture-optimization/113326 "2024-04-22T13:30:40Z")

</div>

Hello! I’m implementing an Agent Based Model (axelrod model of dissemination of culture). Every node has an associated vector of “opinions” (data) on different subjects (number of features is feat). Each step two nodes a…

---

## [Vcat for Vector{Any}](https://discourse.julialang.org/t/vcat-for-vector-any/111065)

<div class="topic-metadata">

**Author:** [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Replies:** 1\
**Last updated:** [March 2, 2024, 3:57pm UTC](https://discourse.julialang.org/t/vcat-for-vector-any/111065 "2024-03-02T15:57:39Z")

</div>

I have this part of code: #can't be change len::Int64 = 4 a = rand(Float64, len) a\_1 = Int64.(floor.(@view a\[1:2:len\])) a\_2 = @view a\[2:2:len\] display(a\_1) #can be changed b = vcat\[Vector{Any}(a\_1), a\_2\] It throws th…

---

## [Difference between \[1, 2, 3, 4\] / \[1, 2, 3, 4\] vs \[1, 2, 3, 4\] ./ \[1, 2, 3, 4\]](https://discourse.julialang.org/t/difference-between-1-2-3-4-1-2-3-4-vs-1-2-3-4-1-2-3-4/110999)

<div class="topic-metadata">

**Author:** [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Replies:** 9\
**Last updated:** [March 1, 2024, 10:58am UTC](https://discourse.julialang.org/t/difference-between-1-2-3-4-1-2-3-4-vs-1-2-3-4-1-2-3-4/110999 "2024-03-01T10:58:50Z")

</div>

Hello, Does someone know what exactly happens in background when we do \[1, 2, 3, 4\] / \[1, 2, 3, 4\]. For \[1, 2, 3, 4\] ./ \[1, 2, 3, 4\] is clear that it’s doing element-wise division as shown below. But what about \[1, 2…

---

## [Get a vector from field](https://discourse.julialang.org/t/get-a-vector-from-field/110713)

<div class="topic-metadata">

**Author:** [@mary](https://discourse.julialang.org/u/mary)\
**Replies:** 4\
**Last updated:** [February 25, 2024, 10:12pm UTC](https://discourse.julialang.org/t/get-a-vector-from-field/110713 "2024-02-25T22:12:57Z")

</div>

hi I wrote this code in julia gridap. h value is a field. i need a vector of values. how can i get that? ∂Hn+1/∂hnj={−1 , if i = j and ψ+n+1(e (ξ i ) )\< hn(ξ i ) 0 , otherwise function dh(hh\_in, ψPlusnext\_in) h\_…

---

## [\[ANN\] OptimalSortingNetworks: Sort small collections efficiently and with good type inference](https://discourse.julialang.org/t/ann-optimalsortingnetworks-sort-small-collections-efficiently-and-with-good-type-inference/105544)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 14\
**Last updated:** [February 25, 2024, 6:59pm UTC](https://discourse.julialang.org/t/ann-optimalsortingnetworks-sort-small-collections-efficiently-and-with-good-type-inference/105544 "2024-02-25T18:59:05Z")

</div>

OptimalSortingNetworks (OSN for short) is being registered. Use it to sort small tuples or vectors: julia\> using OptimalSortingNetworks julia\> sorted(\[10, 5, 7, 9\]) 4-element Vector{Int64}: 5 7 9 10 julia\> sort…

---

## [Algorithm for product of vectors](https://discourse.julialang.org/t/algorithm-for-product-of-vectors/110049)

<div class="topic-metadata">

**Author:** [@blociss](https://discourse.julialang.org/u/blociss)\
**Replies:** 32\
**Last updated:** [February 14, 2024, 8:39pm UTC](https://discourse.julialang.org/t/algorithm-for-product-of-vectors/110049 "2024-02-14T20:39:26Z")

</div>

Consider uu=\[ \[ ((1, 2), (3, -2)), ((1, 3), (3, -3))\], \[ ((1, -1), (2, 1))\], \[((1, 1), (2, -1)), ((1, -1), (2, 1))\], \[ ((2, -2), (4, 2)), ((2, -3), (4, 3))\], \[((3, 1), (4, -1)), ((3, 4), (4, -4))\], \[((3, 1), (4, …

---

## [Select a dictionary in a vector based on a specific entry value](https://discourse.julialang.org/t/select-a-dictionary-in-a-vector-based-on-a-specific-entry-value/109876)

<div class="topic-metadata">

**Author:** [@sardinecan](https://discourse.julialang.org/u/sardinecan)\
**Replies:** 4\
**Last updated:** [February 9, 2024, 2:48pm UTC](https://discourse.julialang.org/t/select-a-dictionary-in-a-vector-based-on-a-specific-entry-value/109876 "2024-02-09T14:48:54Z")

</div>

Hi everyone, I’m looking for an easy way to filter/select dict in vector based on the value of one of the key. In the example below, I need to find the title of a data, given by the first Dict of the vector (but it is …

---

## [How to apply an in-place function to a slice of a vector?](https://discourse.julialang.org/t/how-to-apply-an-in-place-function-to-a-slice-of-a-vector/108520)

<div class="topic-metadata">

**Author:** [@homocomputeris](https://discourse.julialang.org/u/homocomputeris)\
**Replies:** 11\
**Last updated:** [January 9, 2024, 11:02am UTC](https://discourse.julialang.org/t/how-to-apply-an-in-place-function-to-a-slice-of-a-vector/108520 "2024-01-09T11:02:07Z")

</div>

I want to have an in-place function that takes a vector as an argument and applies another in-place function to a subarray (in general sense). How do I do this? function f!(du, u) println("\\nf called") @show u …

[Next page](https://discourse.julialang.org/tag/vector/354.md?match_all_tags=true&page=1&tags%5B%5D=vector)
