[Haskell-beginners] Still confused
allbery.b at gmail.com
Mon Jul 1 20:20:19 CEST 2013
On Mon, Jul 1, 2013 at 2:03 PM, Marc Gorenstein
<marc.gorenstein at gmail.com>wrote:
> Here are two examples of operator sections. The first takes the infix
> / and turns it into a prefix operator.
> Prelude> let eight_div_by = ((/) 8 )
> Prelude> eight_div_by 4
Yes. A section is just this conversion of an infix operator to a prefix
function, but with one parameter carried along with it. You can supply it
on either side as appropriate; (/ 8) is the same as (\x -> x / 8) which in
turn is the same as (\x -> (/) x 8), whereas (8 /) is (\x -> 8 / x) is (\x
-> (/) 8 x). Note that it must be *inside* the parentheses to be a section;
if it's outside, then it's a normal function (not operator!) parameter.
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners