Function wrapper for custom functions

Why not a simple branch:

function resample(weights, particlesN; method = "systematic")
  if method == "systematic"
    resampling_systematic(...)
  else
    resampling_multinomial(...)
end

I suppose if you really wanted to dispatch at compile time you could define struct Systematic end and struct Multinomial end and define wrappers of the form

function resample(weights, particlesN, method :: Systematic)
  resampling_systematic(...)
end
1 Like