# SVector{N,T}的N作为结构体的参数类型

``````struct Term{N}
comps::SVector{N, <:Integer}
end
``````

``````struct Conjunction{O<:Temporal,N} <: Compound
comps::SVector{N,<:Term}
end

const ConjF = Conjunction{Forward}
const ConjP = Conjunction{Parallel}

function setcondition(cond, i, v)
@nospecialize cond v
@match (cond, v) begin
(::ConjF, ::ConjF) || (::ConjP, ::ConjP) => begin
constructorof(typeof(cond))([cond[1:i-1]..., v.comps..., cond[i+1:end]...])
end
_ => constructorof(typeof(cond))([cond[1:i-1]..., v, cond[i+1:end]...])
end
end
``````

`REPL`里运行

``````julia> c1 = Conjunction{Forward}([Word(:A), Word(:B)])
"(&/,A,B)"

julia> c2 = Conjunction{Forward}([Word(:C), Word(:D)])
"(&/,C,D)"

julia> Junars.setcondition(c1, 1, c2)
"(&/,C,D,B)"

julia> @code_warntype Junars.setcondition(c1, 1, c2)
MethodInstance for Junars.setcondition(::Conjunction{Forward, 2}, ::Int64, ::Conjunction{Forward, 2})
from setcondition(cond, i, v) in Junars at D:\codes\Junars.jl\src\rules\conditional.jl:121
Arguments
#self#::Core.Const(Junars.setcondition)
cond::Conjunction{Forward, 2}
i::Int64
v::Conjunction{Forward, 2}
Locals
355::Union{}
354::Union{}
353::Conjunction{Forward, 2}
352::Conjunction{Forward, 2}
351::Tuple{Conjunction{Forward, 2}, Conjunction{Forward, 2}}
return#349::Union{Nothing, Conjunction{Forward}}
Body::Conjunction{Forward}  # Red!!!
``````

``````struct Term{N, T<:Integer}
comps::SVector{N, T}
end
``````