I need to define a pure function that takes two arguments and returns their quotient. If the divisor is 0
then I want to return 0
.
If I had a named function then I would do
div[_, 0] := 0
div[x_, y_] := x / y
how to do the same sort of pattern matching on arguments in a pure function #1 / #2 &
?
Switch
may be useful, for example: