aboutsummaryrefslogtreecommitdiff
path: root/src/list
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-01-23 19:22:01 +0100
committerAdrian Kummerlaender2015-01-23 19:22:01 +0100
commit0cbc85dd74103ec5c7b2ac5802721ccf051d8454 (patch)
treeffd4d2d9f176457438117520422fa67318e9f2ff /src/list
parentb1d2d745156a27df6f7d4e47227b8fdc70e8678b (diff)
downloadTypeAsValue-0cbc85dd74103ec5c7b2ac5802721ccf051d8454.tar
TypeAsValue-0cbc85dd74103ec5c7b2ac5802721ccf051d8454.tar.gz
TypeAsValue-0cbc85dd74103ec5c7b2ac5802721ccf051d8454.tar.bz2
TypeAsValue-0cbc85dd74103ec5c7b2ac5802721ccf051d8454.tar.lz
TypeAsValue-0cbc85dd74103ec5c7b2ac5802721ccf051d8454.tar.xz
TypeAsValue-0cbc85dd74103ec5c7b2ac5802721ccf051d8454.tar.zst
TypeAsValue-0cbc85dd74103ec5c7b2ac5802721ccf051d8454.zip
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
Diffstat (limited to 'src/list')
-rw-r--r--src/list/iota.h34
1 files changed, 34 insertions, 0 deletions
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<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_IOTA_H_