[Haskell-beginners] Re: Closure

Daniel Bastos dbastos+0 at toledo.com
Sat Aug 15 13:04:33 EDT 2009


In article <1B14D870-7355-4EFD-B0C6-026109AB4F87 at ece.cmu.edu>,
Brandon S. Allbery KF8NH wrote:

> In C you have to declare it.  

The word would be `define'?

> In Haskell you can just do it on the fly:
>
> > map (add 3) [1..10]

I see. Just like we can create an integer on the fly in C, in Haskell
we can create functions on the fly. I guess that's quite a difference.

> or indeed
>
> > map (+3) [1..10]
>
> (The above is actually a "section", a closure created from an infix  
> function.  The difference is that I can specify either side of the  
> operator, whereas to specify arguments other than the first for a  
> regular function I must either coerce it into infix with `` or use the  
> "flip" function to rearrange arguments.)

And is this mere syntax sugar?



More information about the Beginners mailing list