diff options
author | Adrian Kummerlaender | 2015-02-01 12:57:22 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-02-01 12:57:22 +0100 |
commit | e317b6c9318766eabda53d9dc6e9cdac55aae34b (patch) | |
tree | b4875ba3be499d8c5cb03307496e56c268b4f440 /test.cc | |
parent | a9ec2e4e13670c8084c6baae59d6f3631960e22c (diff) | |
download | TypeAsValue-e317b6c9318766eabda53d9dc6e9cdac55aae34b.tar TypeAsValue-e317b6c9318766eabda53d9dc6e9cdac55aae34b.tar.gz TypeAsValue-e317b6c9318766eabda53d9dc6e9cdac55aae34b.tar.bz2 TypeAsValue-e317b6c9318766eabda53d9dc6e9cdac55aae34b.tar.lz TypeAsValue-e317b6c9318766eabda53d9dc6e9cdac55aae34b.tar.xz TypeAsValue-e317b6c9318766eabda53d9dc6e9cdac55aae34b.tar.zst TypeAsValue-e317b6c9318766eabda53d9dc6e9cdac55aae34b.zip |
Added `TakeWhile` higher order list operation
* as its name implies this function returns the longest initial prefix of a list that satisfies a given _Predicate_
* added appropriate test case
Diffstat (limited to 'test.cc')
-rw-r--r-- | test.cc | 38 |
1 files changed, 37 insertions, 1 deletions
@@ -12,6 +12,7 @@ #include "list/operation/higher/partition.h" #include "list/operation/higher/query.h" #include "list/operation/higher/find.h" +#include "list/operation/higher/take_while.h" #include "list/generator/iota.h" #include "list/generator/make_list.h" #include "list/generator/higher/list_tabulate.h" @@ -683,7 +684,7 @@ static_assert( "(count even? (list 1 3 5)) != 0" ); -//list find +// list find static_assert( std::is_same< @@ -718,6 +719,41 @@ static_assert( "(find even? (list 1 3 5)) != #f" ); +// list take while + +static_assert( + std::is_same< + tav::List<tav::Int<2>, tav::Int<4>>::type, + tav::TakeWhile< + tav::Even, + tav::List<tav::Int<2>, tav::Int<4>, tav::Int<5>, tav::Int<6>>::type + >::type + >::value, + "(take-while even? (list 2 4 5 6)) != (list 2 4)" +); + +static_assert( + std::is_same< + tav::List<tav::Int<2>, tav::Int<4>, tav::Int<6>>::type, + tav::TakeWhile< + tav::Even, + tav::List<tav::Int<2>, tav::Int<4>, tav::Int<6>>::type + >::type + >::value, + "(take-while even? (list 2 4 6)) != (list 2 4 6)" +); + +static_assert( + std::is_same< + void, + tav::TakeWhile< + tav::Odd, + tav::List<tav::Int<2>, tav::Int<4>, tav::Int<5>, tav::Int<6>>::type + >::type + >::value, + "(take-while odd? (list 2 4 5 6)) != void" +); + // function apply static_assert( |