Paul Graham is collecting canonical accumulator generators at
http://www.paulgraham.com/accgen.html , and has Dylan, E, JavaScript,
various dialects Lisp, Lua, Rebol, Ruby, Perl, Python and Smalltalk.
As others have implied, the only correct answer to this is
it's the wrong question. One of
Paul Graham is collecting canonical accumulator generators at
http://www.paulgraham.com/accgen.html , and has Dylan, E, JavaScript,
various dialects Lisp, Lua, Rebol, Ruby, Perl, Python and Smalltalk.
Could the serious Haskellers comment on this attempt of mine?
foo n = do
n' - newIORef n
I am thinking one of the following...
(the first needs a type signature due to the monomorphism restriction..
i think.)
foo :: Num a = a - a - a
foo = (+)
foo n = (n +)
foo n i = n + i
On Fri, Jun 14, 2002 at 08:29:55AM +1000, Dominic Cooney wrote:
Paul Graham is collecting canonical
Dominic Cooney wrote:
foo n = do
n' - newIORef n
return (\i - do { modifyIORef n' (i+); readIORef n' })
I'm not sure such a solution should be submitted without
a MASSIVE CAVEAT - that this is not pure haskell style.
(I'm also not sure that it is really a legal answer since
I don't