# 1D arrays stored as Vectors

# Uninitialized Arrays

arr = [];

# Typed Arrays

arr = Int64[];

# Initialized Arrays

arr = [1, 2, 3, 4];
arr = ['a', 1, 2, 3.4];

# Like strings, indexing starts at 1
# - Trying to access invalid indexes will throw BoundsError

# arr[0];
arr[1];
arr[4];
# arr[5];

# Array concatenation

# Commas
arr = [1:2, 3:4]; # creates array of 2 elements, each a UnitRange
println(arr);

# Spaces or tabs
arr = [1:2 3:4]; # creates 2D array, each space creates new column
println(arr);

println(arr[1][1]);

# Semicolons or newlines
arr = [1:2; 3:4]; # creates array of 4 elements
println(arr);
arr = [1:2
        3:4];
println(arr);

# using both
arr = [1 2; 3 4];
println(arr);

# Matrices

mat = [1 2 3; 4 5 6];

# Matrix access by mat[row, col] notation
mat[2, 3];

# Multidimensional arrays

muldimarr = zeros(2, 2, 3);
println(ndims(muldimarr));

# Array slicing

arr = [1, 2, 3, 4, 5, 6, 7];
sliceArr = arr[3:5];
println(sliceArr);

mat = [1 2 3; 4 5 6];
sliceMat = mat[1:2, 2:3];
println(sliceMat);

# Copies and using arrays

a = [1, 2, 3];
# Pointer
b = a;

b[2] = 4;
println(a);
println(b);

# Copy
c = copy(a);
c[2] = 2;
println(a);
println(c);