Last active
February 18, 2018 01:45
-
-
Save loliGothicK/070d812d9601849b0fafe566a879b30a to your computer and use it in GitHub Desktop.
ラムダ式で再帰する方法のメモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
// factorial | |
static_assert( | |
[impl=[](auto fac, unsigned n) { | |
if (!n) return 1u; | |
return n * fac(fac, n - 1); | |
}](unsigned n){ | |
return impl(impl, n); | |
}(4) | |
== 24 | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment