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 /src/list | |
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 'src/list')
-rw-r--r-- | src/list/operation/higher/query.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/list/operation/higher/query.h b/src/list/operation/higher/query.h index 29f65dc..c6eabc7 100644 --- a/src/list/operation/higher/query.h +++ b/src/list/operation/higher/query.h @@ -3,6 +3,7 @@ #include "fold.h" #include "misc.h" +#include "operation/math.h" #include "operation/logic.h" namespace tav { @@ -35,6 +36,16 @@ using None = Not< typename Any<Function, List>::type >; +template < + template<typename> class Function, + typename List +> +using Count = Fold< + Add, + tav::Size<0>, + typename Map<Function, List>::type +>; + } #endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_QUERY_H_ |