Section of an infix operator
From HaskellWiki
(Difference between revisions)
(Category:Glossary) |
(sectioning examples taken from article Currying) |
||
| Line 3: | Line 3: | ||
* <hask>(2^)</hask> is equivalent to <hask>(^) 2</hask> | * <hask>(2^)</hask> is equivalent to <hask>(^) 2</hask> | ||
* <hask>(^2)</hask> is equivalent to <hask>flip (^) 2</hask> | * <hask>(^2)</hask> is equivalent to <hask>flip (^) 2</hask> | ||
| + | |||
| + | |||
| + | Like [[partial application]] and [[lambda abstraction]], sectioning provides a convenient way of writing some functions without having to explicitly name them: | ||
| + | * <hask>(1+)</hask> (unsugared: <hask>(+) 1</hask>) is the "increment" function, | ||
| + | * <hask>(2*)</hask> is the "double" function, | ||
| + | * <hask>('\t':)</hask> is the "indent" function, | ||
| + | * <hask>(`elem` "AEIOU")</hask> is the "is-capital-vowel-in-English" function (ignoring the "sometimes Y"). | ||
| + | |||
| + | == See also == | ||
| + | |||
| + | * [[Currying]] | ||
[[Category:Glossary]] | [[Category:Glossary]] | ||
[[Category:Syntax]] | [[Category:Syntax]] | ||
Revision as of 14:04, 3 July 2007
In Haskell there is a special syntax for partial application on infix operators.
- is equivalent to(2^)(^) 2
- is equivalent to(^2)flip (^) 2
Like partial application and lambda abstraction, sectioning provides a convenient way of writing some functions without having to explicitly name them:
- (unsugared:(1+)) is the "increment" function,(+) 1
- is the "double" function,(2*)
- is the "indent" function,('\t':)
- is the "is-capital-vowel-in-English" function (ignoring the "sometimes Y").(`elem` "AEIOU")
