diff options
author | Adrian Kummerlaender | 2015-01-25 17:15:59 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-01-25 17:15:59 +0100 |
commit | 4f2aa4218ec63107b4624e576ff391c2019690a1 (patch) | |
tree | 50315075a26d822e6ebfbd1fe23a81a33ebcf47e /test.cc | |
parent | 8b0d1c5296c22ce28fd0c8f9b251308b7bbf3090 (diff) | |
download | TypeAsValue-4f2aa4218ec63107b4624e576ff391c2019690a1.tar TypeAsValue-4f2aa4218ec63107b4624e576ff391c2019690a1.tar.gz TypeAsValue-4f2aa4218ec63107b4624e576ff391c2019690a1.tar.bz2 TypeAsValue-4f2aa4218ec63107b4624e576ff391c2019690a1.tar.lz TypeAsValue-4f2aa4218ec63107b4624e576ff391c2019690a1.tar.xz TypeAsValue-4f2aa4218ec63107b4624e576ff391c2019690a1.tar.zst TypeAsValue-4f2aa4218ec63107b4624e576ff391c2019690a1.zip |
Implemented `Count` in terms of `Fold` and `Map`
* as its name implies this function counts the amount of elements satisfying a given _function_
* added appropriate test case
Diffstat (limited to 'test.cc')
-rw-r--r-- | test.cc | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -607,3 +607,27 @@ static_assert( >::value, "(list-tabulate 4 square) != (list 0 1 4 9)" ); + +// list count + +static_assert( + std::is_same< + tav::Size<2>, + tav::Count< + tav::Odd, + tav::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>::type + >::type + >::value, + "(count odd? (list 1 2 3)) != 2" +); + +static_assert( + std::is_same< + tav::Size<0>, + tav::Count< + tav::Even, + tav::List<tav::Int<1>, tav::Int<3>, tav::Int<5>>::type + >::type + >::value, + "(count even? (list 1 3 5)) != 0" +); |