November 2018
Intermediate to advanced
460 pages
14h 1m
English
Start with defining the custom Point type, and next learn how to store it in an array as follows:
julia> struct Point{T<:Integer, S<:AbstractString} pos::Complex{T} label::S endjulia> Point(x::T, y::T, label::S) where {T<:Integer, S<:AbstractString} = Point{T,S}(Complex(x,y), label)Pointjulia> Point(x, y, label) = Point(promote(Integer.((x,y))...)..., label)Point
julia> p1 = Point(1, 0, "1")Point{Int64,String}(1 + 0im, "1")julia> p2 = Point(1, 0, SubString("1", 1))Point{Int64,SubString{String}}(1 + 0im, "1")julia> p3 = Point(true, false, "1")Point{Bool,String}(Complex(true,false), "1")julia> p4 = Point(2, 0, "2")Point{Int64,String}(2 ...Read now
Unlock full access