Skip to main content
edited tags; edited title
Link
m_goldberg
  • 108.6k
  • 16
  • 107
  • 263

redefining Redefining a built-in operator

Tweeted twitter.com/#!/StackMma/status/627673153540628481
Source Link
Omegaman
  • 279
  • 1
  • 4

redefining a built-in operator

Is there a way I can redefine the || operator such that a||b will be 1/(1/a + 1/b)?

Is it possible to define it infix as above and prefix such that ||[a,b,c] is 1/(1/a+1/b+1/c)?

I'm working with circuit impedances and it's a much more natural way of describing the circuit to use + for series and something simple like || for parallel.