diff options
author | Adrian Kummerlaender | 2015-01-30 19:31:30 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-01-30 19:31:30 +0100 |
commit | 6291f3ce10aa8ebffa895f21c4ccb91b7349c66a (patch) | |
tree | f2fc654693e7c28fe749a7e11a98c22e1c693837 /test.cc | |
parent | e176dbe160eff01d172a11e7a191f756d4c87712 (diff) | |
download | TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar.gz TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar.bz2 TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar.lz TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar.xz TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.tar.zst TypeAsValue-6291f3ce10aa8ebffa895f21c4ccb91b7349c66a.zip |
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
Diffstat (limited to 'test.cc')
-rw-r--r-- | test.cc | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -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<1>, tav::Int<3>>::type, + tav::Remove< + tav::Even, + tav::List<tav::Int<1>, 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<1>, tav::Int<3>>::type, + tav::List<tav::Int<2>>::type + >, + tav::Partition< + tav::Odd, + tav::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>::type + >::type + >::value, + "(partition odd? (list 1 2 3)) != [(list 1 3) (list 2)]" +); + // list reverse static_assert( |