From 6291f3ce10aa8ebffa895f21c4ccb91b7349c66a Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 30 Jan 2015 19:31:30 +0100 Subject: Implemented `Remove` and `Partition` higher order list functions * `Remove` is a basic `Filter` alias that negates its predicate * `Partition` builds on both `Remove` and `Filter` to return both the elements satisfying a predicate and those which don't --- test.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test.cc') diff --git a/test.cc b/test.cc index e7817f0..9168038 100644 --- a/test.cc +++ b/test.cc @@ -9,6 +9,7 @@ #include "list/operation/contains.h" #include "list/operation/higher/map.h" #include "list/operation/higher/filter.h" +#include "list/operation/higher/partition.h" #include "list/operation/higher/query.h" #include "list/generator/iota.h" #include "list/generator/make_list.h" @@ -427,6 +428,35 @@ static_assert( "(filter odd? (list 1 2 3)) != (list 1 3)" ); +// list remove + +static_assert( + std::is_same< + tav::List, tav::Int<3>>::type, + tav::Remove< + tav::Even, + tav::List, tav::Int<2>, tav::Int<3>>::type + >::type + >::value, + "(remove even? (list 1 2 3)) != (list 1 3)" +); + +// list partition + +static_assert( + std::is_same< + tav::Cons< + tav::List, tav::Int<3>>::type, + tav::List>::type + >, + tav::Partition< + tav::Odd, + tav::List, tav::Int<2>, tav::Int<3>>::type + >::type + >::value, + "(partition odd? (list 1 2 3)) != [(list 1 3) (list 2)]" +); + // list reverse static_assert( -- cgit v1.2.3