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

Initialising typed array of tuples of ints

$
0
0

Hi,
I’m coming from Python so I’m not too hot on static types.

I want an array of tuples of Ints. The number of elements in the array will change depending on the data set used, but the tuples will always be 4 ints. I have this code working:

citArr = []

iter = 1
println(citArr)

for i in shapes
    global iter
    println(iter)
    x1 = Int32(round(i[1][1]*100000))
    y1 = Int32(round(i[1][2]*100000))
    x2 = Int32(round(i[end][1]*100000))
    y2 = Int32(round(i[end][1]*100000))

    push!(citArr, (x1,y1,x2,y2))

    iter += 1

end

println(citArr)

which yields an array of type “any”. I’m struggling to initialize an empty array of type Tuple and then push an arbitrary number of tuples to it.

Thanks for any help.

4 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images