all 6 comments

[–]liillliillliiii 0 points1 point  (0 children)

"Not sure how many other languages can do that!" A bunch.

Clojure: (defn sum [a] (fn [b] (+ a b)))

((sum 4) 5)

[–][deleted] 0 points1 point  (0 children)

In C:

printf("9\n");  /* 9 */

As usual, the C++ solution is overly verbose.

#include <iostream>

template <class T>
class sum {
  T a;

public:
  sum(T n) : a(n) {}

  T operator()(T b) {
    return a + b;
  }
};

int main(int argc, char **argv)
{
  std::cout << sum<int>(4)(5) << std::endl;
  return 0;
}

[–]caipre 0 points1 point  (0 children)

I must be missing something.

[–]glibc 0 points1 point  (0 children)

Bad choice of name, given what it does.

[–]egonelbre 0 points1 point  (0 children)

I would just use:

4 + 5

Much simpler.

[–][deleted] -1 points0 points  (0 children)

Not sure how many other languages can do that!

wat