
On Aug 15, 2009, at 12:07 , Daniel Bastos wrote:
This makes sense. Because, even in a language like C, a similar effect can be achieved, no? For example
int plus(int x, int y) { return x + y; }
int plus3(int y) { plus(3, y); }
So, what I can't do in C, besides almost everything I can't do, is to do this nicely like I do in Haskell. But we don't call this a closure. In fact, we say C does not allow for closures. So what am I missing?
In C you have to declare it. In Haskell you can just do it on the fly:
map (add 3) [1..10]
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.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH