Infix operator: Difference between revisions
BrettGiles (talk | contribs) m (Infix operators moved to Infix operator) |
BrettGiles (talk | contribs) m (Categorize, link to "section of an infix operator") |
||
Line 1: | Line 1: | ||
[[Category:Syntax]] [[Category:Glossary]] | |||
== Overview == | == Overview == | ||
Line 23: | Line 24: | ||
Note that you can only do this with a function that takes two arguments. | Note that you can only do this with a function that takes two arguments. | ||
==Section== | |||
See the article [[section of an infix operator]] |
Revision as of 17:46, 22 July 2007
Overview
Functions in Haskell are usually called using prefix notation, or the function name followed by its arguments. However, some functions, like +, are called with infix notation, or putting the function name between its two arguments.
Using infix functions with prefix notation
Putting parenthesis around an infix operator converts it into a prefix function:
Prelude> (+) 1 2 3 Prelude> (*) 3 4 12
Using prefix functions with infix notation
Putting ` marks around a prefix function allows us to use it like an infix function:
Prelude> let concatPrint x y = putStrLn $ (++) x y Prelude> concatPrint "a" "b" ab Prelude> "a" `concatPrint` "b" ab
Note that you can only do this with a function that takes two arguments.
Section
See the article section of an infix operator