I have a few “operations” and I will read a CSV file to determine a list of operation to perform.
I also have a collection of operations “ManyOps” that hold multiple operations.
Operate → abstract type
Cut, Roll, Push → concrete type
ManyOps → concrete type with Parametric Types of Cut, Roll, Push
I want to avoid using abstract type “Vector{Operate}”, therefore I have to use Tuple of Operate.
But below generate an error, may I know how to fix it?
Ideally, I want to generate a ManyOps{Cut, Roll}, and the Cut and Roll can be variable size, read from a CSV file
e.g. the CSV file may contain: Cut, Roll, Cut, Roll, Push, Cut
Thank you
abstract type Operate end
struct Cut <: Operate
member::String
Cut() = Cut(“t”)
endstruct Push <: Operate
member::Int
Push() = Push(1)
endstruct Roll <: Operate
member::Symbol
Roll() = Roll(:a)
endstruct ManyOps{T}
ops::T
ManyOps(ops::T) where {T} = new{Union{map(typeof, ops)…}}(ops)
end
ManyOps(ops::Operate…) = ManyOps(ops)
ManyOps(Cut(), Roll())