aboutsummaryrefslogtreecommitdiff
path: root/src/list/operation/higher
diff options
context:
space:
mode:
Diffstat (limited to 'src/list/operation/higher')
-rw-r--r--src/list/operation/higher/drop_while.h14
-rw-r--r--src/list/operation/higher/filter.h18
-rw-r--r--src/list/operation/higher/find.h14
-rw-r--r--src/list/operation/higher/fold.h15
-rw-r--r--src/list/operation/higher/map.h12
-rw-r--r--src/list/operation/higher/partition.h5
-rw-r--r--src/list/operation/higher/query.h12
-rw-r--r--src/list/operation/higher/remove.h34
-rw-r--r--src/list/operation/higher/sort.h34
-rw-r--r--src/list/operation/higher/take_while.h18
10 files changed, 133 insertions, 43 deletions
diff --git a/src/list/operation/higher/drop_while.h b/src/list/operation/higher/drop_while.h
index 8ba2664..021698f 100644
--- a/src/list/operation/higher/drop_while.h
+++ b/src/list/operation/higher/drop_while.h
@@ -5,16 +5,18 @@
namespace tav {
+namespace detail {
+
template <
template<typename> class Predicate,
typename Current
>
struct DropWhile {
- typedef Eval<If<
+ typedef If<
Eval<Predicate<Head<Current>>>,
Eval<DropWhile<Predicate, Tail<Current>>>,
Current
- >> type;
+ > type;
};
template <
@@ -26,4 +28,12 @@ struct DropWhile<Predicate, void> {
}
+template <
+ template<typename> class Predicate,
+ typename Current
+>
+using DropWhile = Eval<detail::DropWhile<Predicate, Current>>;
+
+}
+
#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_DROP_WHILE_H_
diff --git a/src/list/operation/higher/filter.h b/src/list/operation/higher/filter.h
index 3588400..17d49c2 100644
--- a/src/list/operation/higher/filter.h
+++ b/src/list/operation/higher/filter.h
@@ -6,6 +6,8 @@
namespace tav {
+namespace detail {
+
template <
template<typename> class Predicate,
typename List
@@ -18,28 +20,22 @@ class Filter {
>
using predicate_wrapper = If<
Eval<Predicate<Current>>,
- Eval<Cons<Current, Previous>>,
+ Cons<Current, Previous>,
Previous
>;
public:
- typedef Eval<Fold<predicate_wrapper, void, List>> type;
+ typedef tav::Fold<predicate_wrapper, void, List> type;
};
+}
+
template <
template<typename> class Predicate,
typename List
>
-class Remove {
- private:
- template <typename Element>
- using predicate_negator = Not<Predicate<Element>>;
-
- public:
- typedef Eval<Filter<predicate_negator, List>> type;
-
-};
+using Filter = Eval<detail::Filter<Predicate, List>>;
}
diff --git a/src/list/operation/higher/find.h b/src/list/operation/higher/find.h
index abc3199..48533b7 100644
--- a/src/list/operation/higher/find.h
+++ b/src/list/operation/higher/find.h
@@ -6,16 +6,18 @@
namespace tav {
+namespace detail {
+
template <
template<typename> class Predicate,
typename Current
>
struct Find {
- typedef Eval<If<
+ typedef If<
Eval<Predicate<Head<Current>>>,
Head<Current>,
Eval<Find<Predicate, Tail<Current>>>
- >> type;
+ > type;
};
template <
@@ -27,4 +29,12 @@ struct Find<Predicate, void> {
}
+template <
+ template<typename> class Predicate,
+ typename List
+>
+using Find = Eval<detail::Find<Predicate, List>>;
+
+}
+
#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FIND_H_
diff --git a/src/list/operation/higher/fold.h b/src/list/operation/higher/fold.h
index 3ed0a42..7364fe5 100644
--- a/src/list/operation/higher/fold.h
+++ b/src/list/operation/higher/fold.h
@@ -3,16 +3,18 @@
namespace tav {
+namespace detail {
+
template <
template<typename, typename> class Function,
typename Initial,
typename Current
>
struct Fold {
- typedef Eval<Function<
+ typedef Function<
Head<Current>,
Eval<Fold<Function, Initial, Tail<Current>>>
- >> type;
+ > type;
};
template <
@@ -25,4 +27,13 @@ struct Fold<Function, Initial, void> {
}
+template <
+ template<typename, typename> class Function,
+ typename Initial,
+ typename Current
+>
+using Fold = Eval<detail::Fold<Function, Initial, Current>>;
+
+}
+
#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FOLD_H_
diff --git a/src/list/operation/higher/map.h b/src/list/operation/higher/map.h
index ac214b7..cc30355 100644
--- a/src/list/operation/higher/map.h
+++ b/src/list/operation/higher/map.h
@@ -5,6 +5,8 @@
namespace tav {
+namespace detail {
+
template <
template<typename> class Function,
typename List
@@ -21,10 +23,18 @@ class Map {
>;
public:
- typedef Eval<Fold<function_wrapper, void, List>> type;
+ using type = tav::Fold<function_wrapper, void, List>;
};
}
+template <
+ template<typename> class Function,
+ typename List
+>
+using Map = Eval<detail::Map<Function, List>>;
+
+}
+
#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_MAP_H_
diff --git a/src/list/operation/higher/partition.h b/src/list/operation/higher/partition.h
index eedeb91..ee49fcc 100644
--- a/src/list/operation/higher/partition.h
+++ b/src/list/operation/higher/partition.h
@@ -2,6 +2,7 @@
#define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_PARTITION_H_
#include "filter.h"
+#include "remove.h"
namespace tav {
@@ -10,8 +11,8 @@ template <
typename Elements
>
using Partition = Cons<
- Eval<Filter<Predicate, Elements>>,
- Eval<Remove<Predicate, Elements>>
+ Filter<Predicate, Elements>,
+ Remove<Predicate, Elements>
>;
}
diff --git a/src/list/operation/higher/query.h b/src/list/operation/higher/query.h
index 1d00267..c6c73f4 100644
--- a/src/list/operation/higher/query.h
+++ b/src/list/operation/higher/query.h
@@ -15,7 +15,7 @@ template <
using Any = Fold<
Or,
Boolean<false>,
- Eval<Map<Predicate, List>>
+ Map<Predicate, List>
>;
template <
@@ -25,16 +25,14 @@ template <
using All = Fold<
And,
Boolean<true>,
- Eval<Map<Predicate, List>>
+ Map<Predicate, List>
>;
template <
template<typename> class Predicate,
typename List
>
-using None = Not<
- Eval<Any<Predicate, List>>
->;
+using None = Not<Any<Predicate, List>>;
template <
template<typename> class Predicate,
@@ -42,8 +40,8 @@ template <
>
using Count = Fold<
Add,
- tav::Size<0>,
- Eval<Map<Predicate, List>>
+ Size<0>,
+ Map<Predicate, List>
>;
}
diff --git a/src/list/operation/higher/remove.h b/src/list/operation/higher/remove.h
new file mode 100644
index 0000000..e67e962
--- /dev/null
+++ b/src/list/operation/higher/remove.h
@@ -0,0 +1,34 @@
+#ifndef TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_REMOVE_H_
+#define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_REMOVE_H_
+
+#include "filter.h"
+
+namespace tav {
+
+namespace detail {
+
+template <
+ template<typename> class Predicate,
+ typename List
+>
+class Remove {
+ private:
+ template <typename Element>
+ using predicate_negator = Not<Predicate<Element>>;
+
+ public:
+ typedef tav::Filter<predicate_negator, List> type;
+
+};
+
+}
+
+template <
+ template<typename> class Predicate,
+ typename List
+>
+using Remove = Eval<detail::Remove<Predicate, List>>;
+
+}
+
+#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_REMOVE_H_
diff --git a/src/list/operation/higher/sort.h b/src/list/operation/higher/sort.h
index cf86e9b..2976e06 100644
--- a/src/list/operation/higher/sort.h
+++ b/src/list/operation/higher/sort.h
@@ -8,31 +8,33 @@
namespace tav {
+namespace detail {
+
template <
template<typename, typename> class Comparator,
typename Sequence
>
class Sort {
private:
- using index = Divide<Eval<Length<Sequence>>, Size<2>>;
- using pivot = Eval<Nth<index, Sequence>>;
+ using index = Divide<tav::Length<Sequence>, Size<2>>;
+ using pivot = tav::Nth<index, Sequence>;
- using partitions = Eval<Partition<
+ using partitions = Partition<
Apply<Comparator, pivot, _0>::template function,
- Eval<DeleteNth<index, Sequence>>
- >>;
+ DeleteNth<index, Sequence>
+ >;
- using lhs = Eval<Car<partitions>>;
- using rhs = Eval<Cdr<partitions>>;
+ using lhs = tav::Car<partitions>;
+ using rhs = tav::Cdr<partitions>;
public:
- typedef Eval<Concatenate<
- Eval<List<
+ using type = Concatenate<
+ tav::List<
Eval<Sort<Comparator, lhs>>,
- Eval<List<pivot>>,
+ tav::List<pivot>,
Eval<Sort<Comparator, rhs>>
- >>
- >> type;
+ >
+ >;
};
template <template<typename, typename> class Comparator>
@@ -42,4 +44,12 @@ struct Sort<Comparator, void> {
}
+template <
+ template<typename, typename> class Comparator,
+ typename Sequence
+>
+using Sort = Eval<detail::Sort<Comparator, Sequence>>;
+
+}
+
#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_SORT_H_
diff --git a/src/list/operation/higher/take_while.h b/src/list/operation/higher/take_while.h
index 8e61c45..dec5551 100644
--- a/src/list/operation/higher/take_while.h
+++ b/src/list/operation/higher/take_while.h
@@ -5,19 +5,21 @@
namespace tav {
+namespace detail {
+
template <
template<typename> class Predicate,
typename Current
>
struct TakeWhile {
- typedef Eval<If<
+ typedef If<
Eval<Predicate<Head<Current>>>,
- Eval<Cons<
+ Cons<
Head<Current>,
Eval<TakeWhile<Predicate, Tail<Current>>>
- >>,
+ >,
void
- >> type;
+ > type;
};
template <
@@ -29,4 +31,12 @@ struct TakeWhile<Predicate, void> {
}
+template <
+ template<typename> class Predicate,
+ typename Current
+>
+using TakeWhile = Eval<detail::TakeWhile<Predicate, Current>>;
+
+}
+
#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_TAKE_WHILE_H_