From 7574e3836eec13e6f632b811e6bf001f2e3d2a1d Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 18 Jan 2015 13:58:36 +0100 Subject: Implemented higher order function `fold` * applies a given _function_ to each _Cons_ starting with a initial value * added appropriate test case --- test.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test.cc') diff --git a/test.cc b/test.cc index f60adbd..e642b3a 100644 --- a/test.cc +++ b/test.cc @@ -5,6 +5,7 @@ #include "conditional/if.h" #include "list/cons.h" #include "list/list.h" +#include "list/operation/higher/fold.h" class TypeAsValueTest : public ::testing::Test { }; @@ -83,6 +84,11 @@ TEST_F(TypeAsValueTest, ListConcatenate) { EXPECT_EQ(2, ( tav::Head>::type, tav::List>::type>::type>>::value )); } +TEST_F(TypeAsValueTest, ListFold) { + // (fold + 0 (list 1 2 3)) + EXPECT_EQ(6, ( tav::Fold, tav::List, tav::Int<2>, tav::Int<3>>::type>::type::value )); +} + int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); -- cgit v1.2.3