|
|
> At this point, we can say
>
> quadratic c z = addCx (mulCx z z) c
>
> This is, of course, awful.
I missed a step. I meant to use this as a neat opportunity to point out
that you can do
quadratic c z = (z `mulCx` z) `addCx` c
Putting any function name in backticks magically makes it infix. This is
an improvement, although not a large one in the example given.
Then again, for standard arithmetic operations, there are well-known
symbols, which are much more concise. For less common operations like
set union, writing
setA `union` setB
is regarded by many as being nicer than
union setA setB
Each to their own. Perhaps the "mod" function is a better example:
p^e `mod` m
verses
mod (p^e) m
Weirdly, you can even set an "operator precedence" for backtick infix...
(In case I didn't explain, "infixr" means infix with Right
associativity, while "infixl" means Left associativity.)
Post a reply to this message
|
|