Skip to content

Instantly share code, notes, and snippets.

@tfc
Created December 23, 2016 14:04
Show Gist options
  • Save tfc/b8f29fad8bc0aa4f69ef5aeef5fcb75f to your computer and use it in GitHub Desktop.
Save tfc/b8f29fad8bc0aa4f69ef5aeef5fcb75f to your computer and use it in GitHub Desktop.
#include <iostream>
int main() {
auto List ([](auto ...params) {
return [=](auto f) {
return f(params...);
};
});
auto Tail ([=](auto f) {
return f([=](auto p, auto ...rest) {
return List(rest...);
});
});
auto ListLength([](auto list) {
return list([](auto ...params) { return sizeof...(params); });
});
std::cout << ListLength(Tail(List(1, 2, "abcde", 4))) << '\n'; // 3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment