Write a function foo that takes a number n and returns a function that takes a number i, and returns n incremented by i.
My submission, in Scheme
(define (foo num)
(lambda (x) (+ x num)))
Name:
Anonymous2010-07-19 4:48
Here's an "improved" C version, guaranteed to be portable across different Linux architectures. It's also very easy to change the function to perform arbitrary computations. With minimal modification it can also run on OS X. No worries about the NX bit, either. It does leak memory, though... like all good C programs should.