카타 8급 A function within a function

1 C++[ | ]

C++
Copy
using namespace std;
function<int (void)> always(int x) {
  return [x] { return x; };
}
C++
Copy
using namespace std;
function<int (void)> always(int x) {
  return [x]() { return x; };
}
C++
Copy
using namespace std;
function<int (void)> always(int x) {
  return [=] { return x; };
}
C++
Copy
using namespace std;
function<int (void)> always(int x) {
  return [=]() { return x; };
}

2 JavaScript[ | ]

JavaScript
Copy
function always(n) {
  return function() {
    return n;
  }
}
JavaScript
Copy
function always (n) {
  return () => n;
}