Function wrapper with parameterse from struct

You can make the Struct callable it self:

struct SpinOperator  <: Operator
    state::Int
    sigma::Int
    SpinOperator(state::Int, sigma::Int) = new(state, sigma)
end

function (act::SpinOperator)(psi::Union{Array{Complex{Float64},1},Array{Float64,1}})
        number_operator!(H::Hubbard, psi, act.state, act.sigma)# EDIT:  typo
end

# Use it like this
function foo(s::SpinOperator)
   return s([42])
end

1 Like