From 0cbc85dd74103ec5c7b2ac5802721ccf051d8454 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 23 Jan 2015 19:22:01 +0100 Subject: Implemented `Iota` list constructor * recursively generates a list of `Count` elements starting at `Initial` and consecutively adding `Step` ** as most functionality of this library this function was modeled after its _Scheme_ equivalent `iota` ** it may be used as the foundation of a set of higher order list generators including e.g. `list-tabulate` * added appropriate test cases --- src/list/iota.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/list/iota.h (limited to 'src') diff --git a/src/list/iota.h b/src/list/iota.h new file mode 100644 index 0000000..9a8d22d --- /dev/null +++ b/src/list/iota.h @@ -0,0 +1,34 @@ +#ifndef TYPEASVALUE_SRC_LIST_IOTA_H_ +#define TYPEASVALUE_SRC_LIST_IOTA_H_ + +#include "operation/math.h" + +namespace tav { + +template < + typename Count, + typename Initial, + typename Step +> +struct Iota { + typedef Cons< + Initial, + typename Iota< + Substract>, + Add, + Step + >::type + > type; +}; + +template < + typename Initial, + typename Step +> +struct Iota, Initial, Step> { + typedef Cons type; +}; + +} + +#endif // TYPEASVALUE_SRC_LIST_IOTA_H_ -- cgit v1.2.3