diff options
author | Adrian Kummerlaender | 2015-01-23 20:32:48 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-01-23 20:32:48 +0100 |
commit | 8432906bf9be6f16aafdb23aaed34f1247404329 (patch) | |
tree | 230acd5c97b668ce47d34a0ae1a445cf93c91af3 /src/list/generator/iota.h | |
parent | 0cbc85dd74103ec5c7b2ac5802721ccf051d8454 (diff) | |
download | TypeAsValue-8432906bf9be6f16aafdb23aaed34f1247404329.tar TypeAsValue-8432906bf9be6f16aafdb23aaed34f1247404329.tar.gz TypeAsValue-8432906bf9be6f16aafdb23aaed34f1247404329.tar.bz2 TypeAsValue-8432906bf9be6f16aafdb23aaed34f1247404329.tar.lz TypeAsValue-8432906bf9be6f16aafdb23aaed34f1247404329.tar.xz TypeAsValue-8432906bf9be6f16aafdb23aaed34f1247404329.tar.zst TypeAsValue-8432906bf9be6f16aafdb23aaed34f1247404329.zip |
Implemented `ListTabulate` in terms of `Iota` and `Map`
* added `Square` function to math operations header to facilitate a simple test case
* added appropriate test case
Diffstat (limited to 'src/list/generator/iota.h')
-rw-r--r-- | src/list/generator/iota.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/list/generator/iota.h b/src/list/generator/iota.h new file mode 100644 index 0000000..54f0f40 --- /dev/null +++ b/src/list/generator/iota.h @@ -0,0 +1,34 @@ +#ifndef TYPEASVALUE_SRC_LIST_GENERATOR_IOTA_H_ +#define TYPEASVALUE_SRC_LIST_GENERATOR_IOTA_H_ + +#include "operation/math.h" + +namespace tav { + +template < + typename Count, + typename Initial, + typename Step +> +struct Iota { + typedef Cons< + Initial, + typename Iota< + Substract<Count, Size<1>>, + Add<Initial, Step>, + Step + >::type + > type; +}; + +template < + typename Initial, + typename Step +> +struct Iota<Size<1>, Initial, Step> { + typedef Cons<Initial, void> type; +}; + +} + +#endif // TYPEASVALUE_SRC_LIST_GENERATOR_IOTA_H_ |