Vcat for Vector{Any}

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]


#can be changed
b = vcat[Vector{Any}(a_1), a_2]

It throws this error:

ERROR: LoadError: syntax: unexpected semicolon in array expression around /home/matteobacci/Desktop/Programmi/MODULO_05/executable_and_libraries/bin/aa.jl:95

I want to concatenate the views of these array. Do I need to drop the view?
They could be pretty long arrays and I don’t want too much stuff on the computer.

You need parentheses to call vcat, i.e.

vcat(Vector{Any}(a_1), a_2)

Alternatively, you can use square brackets with a semicolon, and no vcat, which implicitly calls vcat:

[Vector{Any}(a_1); a_2]

Your code doesn’t give that error for me. The error message that I get from your code with vcat[...] is

ERROR: MethodError: no method matching getindex(::typeof(vcat), ...)

which makes sense because vcat[...] is equivalent to getindex(vcat, ...).

1 Like