It would be easier to submit pull requests (if this were on github).
For problem 1, you can just do import LinearAlgebra as la
these days.
For 7, you can simply do a = [10:49;]
For 10, it’s probably more natural to use !=(0)
than !isequal(0)
.
For 11, you can do I(3)
.
For 15, it would be simpler to just assign the corners twice, e.g. a[:,1] .= 1
instead of a[2:end-1,1] .= 1
. (The performance difference is negligible.)
For 16, I would do b = zeros(eltype(a), size(a) .+ 1)
For 20, you can do CartesianIndices((6,7,8))[100]
Exercise 22 seems ambiguous. Often in linear algebra, “normalize” would mean dividing by some norm, but that’s not what you’re doing here.
For exercise 24 I wouldn’t make it mutable, which would be a bad idea for efficiency of storing arrays of that type.
For 25, I would use x[a .<= x .<= b] .*= -1
.
For 27, I would say “valid” rather than “legal”. (No one is going to arrest you if you throw an exception.)
For 28, the analogue of the numpy exercise would be [0] ./ [0]
and [0] .Ă· [0]
, not [0] / [0]
and [0] // [0]
.
For 35, you could use @. A = (A+B)*(-A/2)
to compute it in-place and store the result in A
.
For 36, I wouldn’t call Int64.
. If you call trunc.(...)
the results are already integer-valued. (Even if they are stored as floating-point numbers, they are still integers.)
I don’t know why you have all the trailing commas in a = rand(10,)
etcetera; it’s not idiomatic.
For 44, I would use hypot
to compute the radius, and cis(x)
instead of exp(im*x)
.