Sorry, but please don't send any more accumulator generators for
the time being. I don't have time to check them.
If you want to submit an example of the accumulator generator written in
a new language, please read this page first.
Most of the code I've been sent doesn't work, either because
the author misread the spec, or because you can't really write it in the
language in question.
Before you submit an example, make sure foo
E.g. if after the example, you added the following code
(in a made-up language):
- Takes, and returns functions that take, exactly one argument.
- Works for any numeric type-- i.e. can take both ints and floats
and returns functions that can take both ints and floats.
(It is not enough simply to convert all input to floats. An
accumulator that has only seen integers must return integers.)
- Generates functions that return the sum of every number ever
passed to them, not just the most recent.
- Returns a real function, meaning something that you can use
wherever you could use a function you had defined in the ordinary
way in the text of your program.
- Doesn't store the accumulated value or the returned functions in
a way that could cause them to be inadvertantly modified by other
x = foo(1);
It should print 8.3.
I currently believe that you can't
write this program in ML and Ocaml (no polymorphism), Tcl (the functions returned by
foo have to be named, and there is no sure way to avoid name clashes),
or K (doesn't support closures).
I can't tell yet if you can write the program in Forth.
I've had several Forth submissions and I'm still trying to puzzle out whether they're correct.