How to calculate Euclidean distance between a tuple and each tuple in a Vector using map in Julia?

I want to calculate the Euclidean distance between a tuple and each tuple within a Vector in Julia using the map function, like below (but I get two values instead of three): julia> tups = [ (1, 3), (11, 2), (0, 1) ]; julia> map((x, y) -> √(sum((x.-y).^2)), tups, (3, 3)) 2-element Vector{Float64}: 2.0 8.06225774829855… Read More How to calculate Euclidean distance between a tuple and each tuple in a Vector using map in Julia?

Modify the last dimension of a multi-dimensional array of arbitrary dimensions

Suppose I have a two dimensional array. test_array = ones(2,2) I can modify the last dimension of test_array by doing test_array[:,1] = -99. If I had test_array = ones(2,2,2), I can do test_array[:,:,1] = – 99. Suppose I want to write a function where I want to modify an array of arbitrary dimensions. For example,… Read More Modify the last dimension of a multi-dimensional array of arbitrary dimensions

Julia – Passing two arguments to make array, iterate through first argument but not second

I am new to Julia and would be very appreciative of your help. I have a function that takes an integer and an array of integers, which will return an integer. I want to make an array of the results of this function over a range. However, I am struggling to get Julia to recognise… Read More Julia – Passing two arguments to make array, iterate through first argument but not second

How to use `endswith()` against multiple values in Julia?

I have a string and I want to use endswith() on it but against multiple values. My first guess was to try it with a tuple: # {string} suffixes = ({multiple suffixes here}) endswith(i,extensions) This generated the error message: MethodError: no method matching endswith(::String, ::Tuple{String, String}) So, I went looking for official documentation at Julia… Read More How to use `endswith()` against multiple values in Julia?