dmhacker / temple

Church numerals using only C++ templates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

temple


church numerals + template metaprogramming = temple


Church numerals in lambda calculus are a representation of the natural numbers using only functions. More specifically, the nth natural number is represented as an n-fold application of a function f to an argument x. For example, the 4th Church numeral is equal to:

f (f (f (f x)))

Using only C++11 templates, it's possible to construct and use Church numerals! Interestingly, all numeric operations are implemented without using explicit recursion - this is accomplished by taking advantage of the properties of Church numerals.

All implementation details can be found in include/temple. Tests are in the tests directory. Temple itself has no external dependencies; however, some tests use the metal metaprogramming library.

About

Church numerals using only C++ templates


Languages

Language:C++ 99.8%Language:CMake 0.2%