Creating a struct containing "derived variables"

Sure, you only need to define a constructor:

julia> struct A
           sigma::Float64
           computed::Vector{Float64}
       end

julia> function A(sigma)
           computed = [ sigma*i for i in 1:10 ]
           return A(sigma, computed)
       end
A

julia> A(0.1)
A(0.1, [0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6000000000000001, 0.7000000000000001, 0.8, 0.9, 1.0])

(note that Array{Float64} is an abstract type, you probably want Array{Float64,1}, which is the same as Vector{Float64})

3 Likes