Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Scalar contained by vector of StaticArrays

$
0
0

Hi!
I want to check if an integer is contained by a vector of StaticArrays. Here’s an example (with regular arrays, but it’s the same issue).

a = [[1,2], [3,4]]
1 in a # false

I guess I could write a for loop, but that’s not very elegant.
Notes:

  • The number I’m looking for will always be in the first “column” (i.e., first position of a subarray).
  • If the number is in a, I will need to find it’s position, something like this: findfirst(x->x==1,a), which doesn’t work in this case either.

Thanks a lot!
PS: this is a silly question, but a difficult one to Google. The word “in” is a bit too common.

6 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images