Dispatch on all binary operations

Hi all, been using Julia for sometime now, first time I’m posting here.

Is it possible for me to dispatch over all binary operations which have specific type arguments?

I’m working on a Fuzzy Arithmetic package, where Fuzzy Numbers are effectively a nested array of intervals but you do some funky stuff to the membership function.

I’ve got a method function which takes two Fuzzy numbers and a binary operation and computes the resulting fuzzy number

minMaxConv(x :: FuzzyNumber, y :: FuzzyNumber; op = +)

op can be any operation defined for an interval from IntervalArithmetic.jl.

Is there anyway I can dispatch on all binary operations from defined for type Interval instead of having to do:

+( x :: FuzzyNumber, y :: FuzzyNumber)  = minMaxConv(x, y, op = +)

Cheers :slight_smile:

The easiest is to define the methods in a for loop using metaprogramming.

1 Like

happen to have an example at hand

1 Like

Wonderfull, thank you both