Year 2 compilers coureswork

simple_LOCAL_24791.c 184B

1234567891011121314151617
  1. int whammy(int a) {
  2. int x = a;
  3. return x + 5;
  4. }
  5. function twice(function f) {
  6. int g(int x) { return f(f(x)); }
  7. return g;
  8. }
  9. int main() {
  10. x = twice(whammy);
  11. return x(2);
  12. }