Hacker News new | ask | show | jobs
by trealira 942 days ago
I was curious about how Julia does 2D matrices and arrays, given they target mathemeticians. They seem to have no shortage of methods of creating them.

  julia> [1,2,3] # An array of `Int`s
  3-element Vector{Int64}:
   1
   2
   3

  julia> [1:2, 4:5] # Has a comma, so no concatenation occurs.
  2-element Vector{UnitRange{Int64}}:
   1:2
   4:5

  julia> [1:2  4:5  7:8]
  2×3 Matrix{Int64}:
   1  4  7
   2  5  8

  julia> [[1,2]  [4,5]  [7,8]]
  2×3 Matrix{Int64}:
   1  4  7
   2  5  8

  julia> [1 2
          3 4]
  2×2 Matrix{Int64}:
   1  2
   3  4

  julia> a=[1 2 5 8 9; 3 4 2 1 33]
  2×5 Array{Int64,2}:
   1  2  5  8   9
   3  4  2  1  33
https://docs.julialang.org/en/v1/manual/arrays/