What's the difference between "operator" and "function"?

Hi Folks, In a book that I am reading the author distinguishes between "operator" and "function." Example: The "+" is an operator. The "map" is a function. What's the difference between operator and function? /Roger

2011/10/10 Costello, Roger L.
What's the difference between operator and function?
http://www.haskell.org/onlinereport/exps.html#sect3.2
An operator is either an operator symbol, such as + or $$, or is an ordinary identifier enclosed in grave accents (backquotes), such as `op`. For example, instead of writing the prefix application op x y, one can write the infix application x `op` y. If no fixity declaration is given for `op` then it defaults to highest precedence and left associativity (see Section 4.4.2).
Dually, an operator symbol can be converted to an ordinary identifier by enclosing it in parentheses. For example, (+) x y is equivalent to x + y, and foldr (*) 1 xs is equivalent to foldr (\x y -> x*y) 1 xs.

Usually, operator is function that takes two values and return a value, and used in infix form, since in haskell infix and prefix form is interchangable, so you can define operator as function taking two arguments.
1+2 3 (+) 1 2 3 map (+1) [1,2,3] [2,3,4] (+1) `map` [1,2,3] [2,3,4]
Hope you can understand my pool english ;-)
Best regards.
On Mon, Oct 10, 2011 at 8:08 PM, Costello, Roger L.
Hi Folks,
In a book that I am reading the author distinguishes between "operator" and "function."
Example: The "+" is an operator. The "map" is a function.
What's the difference between operator and function?
/Roger
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (3)
-
Christopher Done
-
Costello, Roger L.
-
yi huang