From 46e174935b122c0da4b51532a7f683a512eeaf65 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 15 Feb 2015 14:07:50 +0100 Subject: Moved class-based implementations into `detail` namespace * while class templates enable e.g. hiding implementation details they also require evaluation via `Eval` ** this clutters up the actual logic and is now hidden behind aliae that perform the evaluation --- example/prime/prime.cc | 12 +- src/conditional/cond.h | 19 +- src/conditional/if.h | 4 +- src/function/apply.h | 8 +- src/function/detail/apply.h | 8 +- src/list/cons.h | 26 ++- src/list/generator/iota.h | 17 +- src/list/generator/make_list.h | 16 +- src/list/list.h | 11 +- src/list/operation/append.h | 14 +- src/list/operation/basic.h | 15 +- src/list/operation/delete_nth.h | 4 +- src/list/operation/drop.h | 9 + src/list/operation/higher/drop_while.h | 14 +- src/list/operation/higher/filter.h | 18 +- src/list/operation/higher/find.h | 14 +- src/list/operation/higher/fold.h | 15 +- src/list/operation/higher/map.h | 12 +- src/list/operation/higher/partition.h | 5 +- src/list/operation/higher/query.h | 12 +- src/list/operation/higher/remove.h | 34 ++++ src/list/operation/higher/sort.h | 34 ++-- src/list/operation/higher/take_while.h | 18 +- src/list/operation/nth.h | 26 ++- src/list/operation/reverse.h | 13 +- src/list/operation/take.h | 13 +- src/pair.h | 2 +- src/runtime/list/for_each.h | 2 + test.cc | 355 +++++++++++++++++---------------- 29 files changed, 467 insertions(+), 283 deletions(-) create mode 100644 src/list/operation/higher/remove.h diff --git a/example/prime/prime.cc b/example/prime/prime.cc index b826a72..cd119d8 100644 --- a/example/prime/prime.cc +++ b/example/prime/prime.cc @@ -5,13 +5,13 @@ #include "function/apply.h" #include "list/list.h" -#include "list/operation/higher/filter.h" #include "list/generator/iota.h" +#include "list/operation/higher/remove.h" #include "runtime/list/for_each.h" // (define candidates (iota 1000 2 1)) -using candidates = tav::Eval, tav::Int<2>, tav::Int<1>>>; +using candidates = tav::Iota, tav::Int<2>, tav::Int<1>>; // (define (isMultipleOf candidate base) (= (modulo candidate base) 0)) template < @@ -42,15 +42,15 @@ using removeMultiplesOf = tav::Remove< // (car candidates))))))) template struct Sieve { - typedef tav::Eval, tav::Eval, tav::Head - >> + > >> - >> type; + > type; }; template <> diff --git a/src/conditional/cond.h b/src/conditional/cond.h index 2d6a415..f6b7965 100644 --- a/src/conditional/cond.h +++ b/src/conditional/cond.h @@ -8,22 +8,29 @@ namespace tav { +namespace detail { + template class Cond { private: template - using predicate = IsTrue>>>; + using predicate = IsTrue>; public: - typedef Eval> - >> - >> type; + tav::List + > + > type; }; } +template +using Cond = Eval>; + +} + #endif // TYPEASVALUE_SRC_CONDITIONAL_COND_H_ diff --git a/src/conditional/if.h b/src/conditional/if.h index b99f399..9be1a50 100644 --- a/src/conditional/if.h +++ b/src/conditional/if.h @@ -10,11 +10,11 @@ template < typename TrueBranch, typename FalseBranch > -using If = std::conditional< +using If = Eval; +>>; } diff --git a/src/function/apply.h b/src/function/apply.h index f4de292..591fa8a 100644 --- a/src/function/apply.h +++ b/src/function/apply.h @@ -19,22 +19,22 @@ template < > struct Apply : Cond< Pair< - GreaterThan>, Size<2>>, + GreaterThan, Size<2>>, detail::apply_variadic >, Pair< - IsEqualValue>, Size<2>>, + IsEqualValue, Size<2>>, detail::apply_pair >, Pair< - IsEqualValue>, Size<1>>, + IsEqualValue, Size<1>>, detail::apply_single >, Pair< Boolean, detail::apply_none > ->::type { }; +> { }; } diff --git a/src/function/detail/apply.h b/src/function/detail/apply.h index da347f7..8d4ef6d 100644 --- a/src/function/detail/apply.h +++ b/src/function/detail/apply.h @@ -13,7 +13,7 @@ namespace detail { struct placeholder_tag { }; template -using is_placeholder = tav::Boolean< +using is_placeholder = Boolean< std::is_base_of::value >; @@ -33,13 +33,13 @@ template < int Index > struct resolve_placeholder> { - typedef Eval, Partials>> type; + typedef tav::Nth, Partials> type; }; template using count_placeholders = Count< is_placeholder, - Eval> + tav::List >; template < @@ -58,7 +58,7 @@ struct apply_variadic { template using function = Function< Eval>, + tav::List, Arguments >>... >; diff --git a/src/list/cons.h b/src/list/cons.h index 8efca67..95783b2 100644 --- a/src/list/cons.h +++ b/src/list/cons.h @@ -5,18 +5,12 @@ namespace tav { -template < - typename CAR, - typename CDR -> -struct Cons { - typedef Pair type; -}; +namespace detail { template struct Car { static_assert( - Eval>::value, + IsPair::value, "Pair type required" ); @@ -26,7 +20,7 @@ struct Car { template struct Cdr { static_assert( - Eval>::value, + IsPair::value, "Pair type required" ); @@ -35,4 +29,18 @@ struct Cdr { } +template < + typename CAR, + typename CDR +> +using Cons = Pair; + +template +using Car = Eval>; + +template +using Cdr = Eval>; + +} + #endif // TYPEASVALUE_SRC_LIST_CONS_H_ diff --git a/src/list/generator/iota.h b/src/list/generator/iota.h index 56ebeca..73b7cc8 100644 --- a/src/list/generator/iota.h +++ b/src/list/generator/iota.h @@ -5,20 +5,22 @@ namespace tav { +namespace detail { + template < typename Count, typename Initial, typename Step > struct Iota { - typedef Eval>, Add, Step >> - >> type; + > type; }; template < @@ -26,9 +28,18 @@ template < typename Step > struct Iota, Initial, Step> { - typedef Eval> type; + typedef Cons type; }; } +template < + typename Count, + typename Initial, + typename Step +> +using Iota = Eval>; + +} + #endif // TYPEASVALUE_SRC_LIST_GENERATOR_IOTA_H_ diff --git a/src/list/generator/make_list.h b/src/list/generator/make_list.h index d927905..863dce2 100644 --- a/src/list/generator/make_list.h +++ b/src/list/generator/make_list.h @@ -6,25 +6,35 @@ namespace tav { +namespace detail { + template < typename Count, typename Element > struct MakeList { - typedef Eval>, Element >> - >> type; + > type; }; template struct MakeList, Element> { - typedef Eval> type; + typedef Cons type; }; } +template < + typename Count, + typename Element +> +using MakeList = Eval>; + +} + #endif // TYPEASVALUE_SRC_LIST_GENERATOR_MAKE_LIST_H_ diff --git a/src/list/list.h b/src/list/list.h index e369739..c9e6a9e 100644 --- a/src/list/list.h +++ b/src/list/list.h @@ -5,6 +5,8 @@ namespace tav { +namespace detail { + template < typename Head, typename... Tail @@ -36,6 +38,11 @@ struct List { typedef void type; }; +} + +template +using List = Eval>; + template < typename Type, Type... Values @@ -45,10 +52,10 @@ using ListOfType = List< >; template -using Head = Eval>; +using Head = Car; template -using Tail = Eval>; +using Tail = Cdr; } diff --git a/src/list/operation/append.h b/src/list/operation/append.h index 28c9adf..2dcd184 100644 --- a/src/list/operation/append.h +++ b/src/list/operation/append.h @@ -3,18 +3,20 @@ namespace tav { +namespace detail { + template < typename Primary, typename Secondary > struct Append { - typedef Eval, Eval, Secondary >> - >> type; + > type; }; template @@ -24,4 +26,12 @@ struct Append { } +template < + typename Primary, + typename Secondary +> +using Append = Eval>; + +} + #endif // TYPEASVALUE_SRC_LIST_OPERATION_APPEND_H_ diff --git a/src/list/operation/basic.h b/src/list/operation/basic.h index 5f9a3f9..a299938 100644 --- a/src/list/operation/basic.h +++ b/src/list/operation/basic.h @@ -6,21 +6,24 @@ namespace tav { -template +namespace detail { + +template class Length { private: template using accumulate = Add, Accumulated>; public: - typedef Eval, - Cons - >> type; + typedef tav::Fold, List> type; }; } +template +using Length = Eval>; + +} + #endif // TYPEASVALUE_SRC_LIST_OPERATION_BASIC_H_ diff --git a/src/list/operation/delete_nth.h b/src/list/operation/delete_nth.h index 6127ade..18e52bf 100644 --- a/src/list/operation/delete_nth.h +++ b/src/list/operation/delete_nth.h @@ -12,8 +12,8 @@ template < typename List > using DeleteNth = Append< - Eval>, - Eval>, List>> + Take, + Drop>, List> >; } diff --git a/src/list/operation/drop.h b/src/list/operation/drop.h index c61983b..c7745d7 100644 --- a/src/list/operation/drop.h +++ b/src/list/operation/drop.h @@ -5,6 +5,8 @@ namespace tav { +namespace detail { + template < typename Count, typename Current @@ -31,6 +33,13 @@ struct Drop, void> { typedef void type; }; +} + +template < + typename Count, + typename Current +> +using Drop = Eval>; } 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 class Predicate, typename Current > struct DropWhile { - typedef Eval>>, Eval>>, Current - >> type; + > type; }; template < @@ -26,4 +28,12 @@ struct DropWhile { } +template < + template class Predicate, + typename Current +> +using DropWhile = Eval>; + +} + #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 class Predicate, typename List @@ -18,28 +20,22 @@ class Filter { > using predicate_wrapper = If< Eval>, - Eval>, + Cons, Previous >; public: - typedef Eval> type; + typedef tav::Fold type; }; +} + template < template class Predicate, typename List > -class Remove { - private: - template - using predicate_negator = Not>; - - public: - typedef Eval> type; - -}; +using Filter = Eval>; } 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 class Predicate, typename Current > struct Find { - typedef Eval>>, Head, Eval>> - >> type; + > type; }; template < @@ -27,4 +29,12 @@ struct Find { } +template < + template class Predicate, + typename List +> +using Find = Eval>; + +} + #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 class Function, typename Initial, typename Current > struct Fold { - typedef Eval, Eval>> - >> type; + > type; }; template < @@ -25,4 +27,13 @@ struct Fold { } +template < + template class Function, + typename Initial, + typename Current +> +using Fold = Eval>; + +} + #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 class Function, typename List @@ -21,10 +23,18 @@ class Map { >; public: - typedef Eval> type; + using type = tav::Fold; }; } +template < + template class Function, + typename List +> +using Map = Eval>; + +} + #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>, - Eval> + Filter, + Remove >; } 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, - Eval> + Map >; template < @@ -25,16 +25,14 @@ template < using All = Fold< And, Boolean, - Eval> + Map >; template < template class Predicate, typename List > -using None = Not< - Eval> ->; +using None = Not>; template < template class Predicate, @@ -42,8 +40,8 @@ template < > using Count = Fold< Add, - tav::Size<0>, - Eval> + Size<0>, + Map >; } 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 class Predicate, + typename List +> +class Remove { + private: + template + using predicate_negator = Not>; + + public: + typedef tav::Filter type; + +}; + +} + +template < + template class Predicate, + typename List +> +using Remove = Eval>; + +} + +#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 class Comparator, typename Sequence > class Sort { private: - using index = Divide>, Size<2>>; - using pivot = Eval>; + using index = Divide, Size<2>>; + using pivot = tav::Nth; - using partitions = Eval::template function, - Eval> - >>; + DeleteNth + >; - using lhs = Eval>; - using rhs = Eval>; + using lhs = tav::Car; + using rhs = tav::Cdr; public: - typedef Eval>, - Eval>, + tav::List, Eval> - >> - >> type; + > + >; }; template class Comparator> @@ -42,4 +44,12 @@ struct Sort { } +template < + template class Comparator, + typename Sequence +> +using Sort = Eval>; + +} + #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 class Predicate, typename Current > struct TakeWhile { - typedef Eval>>, - Eval, Eval>> - >>, + >, void - >> type; + > type; }; template < @@ -29,4 +31,12 @@ struct TakeWhile { } +template < + template class Predicate, + typename Current +> +using TakeWhile = Eval>; + +} + #endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_TAKE_WHILE_H_ diff --git a/src/list/operation/nth.h b/src/list/operation/nth.h index 08e60cc..5a604f4 100644 --- a/src/list/operation/nth.h +++ b/src/list/operation/nth.h @@ -5,20 +5,22 @@ namespace tav { +namespace detail { + template < typename Index, - typename Pair + typename List > struct Nth { typedef Eval>, - Tail + Tail >> type; }; -template -struct Nth, Pair> { - typedef Head type; +template +struct Nth, List> { + typedef Head type; }; template @@ -31,14 +33,22 @@ struct Nth, void> { typedef void type; }; +} + +template < + typename Index, + typename List +> +using Nth = Eval>; + template -using First = Eval, List>>; +using First = Nth, List>; template -using Second = Eval, List>>; +using Second = Nth, List>; template -using Third = Eval, List>>; +using Third = Nth, List>; } diff --git a/src/list/operation/reverse.h b/src/list/operation/reverse.h index d4b2be9..aabba92 100644 --- a/src/list/operation/reverse.h +++ b/src/list/operation/reverse.h @@ -6,6 +6,8 @@ namespace tav { +namespace detail { + template class Reverse { private: @@ -13,16 +15,21 @@ class Reverse { typename Current, typename Previous > - using reversed_append = Append< + using reversed_append = tav::Append< Previous, - Eval> + tav::List >; public: - typedef Eval> type; + typedef tav::Fold type; }; } +template +using Reverse = Eval>; + +} + #endif // TYPEASVALUE_SRC_LIST_OPERATION_REVERSE_H_ diff --git a/src/list/operation/take.h b/src/list/operation/take.h index fdff123..effba33 100644 --- a/src/list/operation/take.h +++ b/src/list/operation/take.h @@ -5,18 +5,20 @@ namespace tav { +namespace detail { + template < typename Count, typename Current > struct Take { - typedef Eval, Eval>, Tail >> - >> type; + > type; }; template @@ -34,6 +36,13 @@ struct Take, void> { typedef void type; }; +} + +template < + typename Count, + typename Current +> +using Take = Eval>; } diff --git a/src/pair.h b/src/pair.h index 20bef4e..8234382 100644 --- a/src/pair.h +++ b/src/pair.h @@ -19,7 +19,7 @@ struct Pair : detail::pair_tag { }; template -using IsPair = std::is_base_of; +using IsPair = Eval>; } diff --git a/src/runtime/list/for_each.h b/src/runtime/list/for_each.h index b7496a8..a7dc2a8 100644 --- a/src/runtime/list/for_each.h +++ b/src/runtime/list/for_each.h @@ -7,6 +7,7 @@ #include "list/list.h" namespace tav { + namespace runtime { template < @@ -28,6 +29,7 @@ void for_each(const Function& function) { } } + } #endif // TYPEASVALUE_SRC_RUNTIME_LIST_FOR_EACH_H_ diff --git a/test.cc b/test.cc index 39d5349..efe48f3 100644 --- a/test.cc +++ b/test.cc @@ -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/remove.h" #include "list/operation/higher/partition.h" #include "list/operation/higher/query.h" #include "list/operation/higher/find.h" @@ -64,7 +65,7 @@ static_assert( static_assert( std::is_same< tav::Int<3>, - tav::Add, tav::Int<2>>::type + tav::Add, tav::Int<2>> >::value, "(+ 1 2) != 3" ); @@ -72,7 +73,7 @@ static_assert( static_assert( std::is_same< tav::Int<4>, - tav::Substract, tav::Int<6>>::type + tav::Substract, tav::Int<6>> >::value, "(- 10 6) != 4" ); @@ -80,7 +81,7 @@ static_assert( static_assert( std::is_same< tav::Int<42>, - tav::Multiply, tav::Int<21>>::type + tav::Multiply, tav::Int<21>> >::value, "(* 2 21) != 42" ); @@ -88,7 +89,7 @@ static_assert( static_assert( std::is_same< tav::Int<5>, - tav::Divide, tav::Int<2>>::type + tav::Divide, tav::Int<2>> >::value, "(/ 10 2) != 42" ); @@ -96,7 +97,7 @@ static_assert( static_assert( std::is_same< tav::Int<1>, - tav::Modulo, tav::Int<3>>::type + tav::Modulo, tav::Int<3>> >::value, "(modulo 10 3) != 1" ); @@ -104,7 +105,7 @@ static_assert( static_assert( std::is_same< tav::Int<4096>, - tav::Square>::type + tav::Square> >::value, "(square 64) != 4096" ); @@ -112,7 +113,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::Odd>::type + tav::Odd> >::value, "(odd? 1) != #t" ); @@ -120,7 +121,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::Odd>::type + tav::Odd> >::value, "(odd? 2) != #f" ); @@ -128,7 +129,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::GreaterThan, tav::Int<1>>::type + tav::GreaterThan, tav::Int<1>> >::value, "(> 2 1) != #f" ); @@ -136,7 +137,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::GreaterThan, tav::Int<2>>::type + tav::GreaterThan, tav::Int<2>> >::value, "(> 1 2) != #f" ); @@ -144,7 +145,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::LowerThan, tav::Int<2>>::type + tav::LowerThan, tav::Int<2>> >::value, "(< 1 2) != #t" ); @@ -152,7 +153,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::LowerThan, tav::Int<1>>::type + tav::LowerThan, tav::Int<1>> >::value, "(< 2 1) != #f" ); @@ -162,7 +163,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::And, tav::Boolean>::type + tav::And, tav::Boolean> >::value, "(and #t #t) != #t" ); @@ -170,7 +171,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::And, tav::Boolean>::type + tav::And, tav::Boolean> >::value, "(and #f #t) != #f" ); @@ -178,7 +179,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::Or, tav::Boolean>::type + tav::Or, tav::Boolean> >::value, "(or #t #t) != #t" ); @@ -186,7 +187,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::Or, tav::Boolean>::type + tav::Or, tav::Boolean> >::value, "(or #f #t) != #t" ); @@ -194,7 +195,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::Or, tav::Boolean>::type + tav::Or, tav::Boolean> >::value, "(or #f #f) != #f" ); @@ -202,7 +203,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::Xor, tav::Boolean>::type + tav::Xor, tav::Boolean> >::value, "(xor #f #t) != #t" ); @@ -210,7 +211,7 @@ static_assert( static_assert( std::is_same< tav::Boolean, - tav::Xor, tav::Boolean>::type + tav::Xor, tav::Boolean> >::value, "(xor #t #t) != #f" ); @@ -220,7 +221,7 @@ static_assert( static_assert( std::is_same< tav::Int<1>, - tav::If, tav::Int<1>, tav::Int<2>>::type + tav::If, tav::Int<1>, tav::Int<2>> >::value, "(if #t 1 2) != 1" ); @@ -228,7 +229,7 @@ static_assert( static_assert( std::is_same< tav::Int<2>, - tav::If, tav::Int<1>, tav::Int<2>>::type + tav::If, tav::Int<1>, tav::Int<2>> >::value, "(if #f 1 2) != 2" ); @@ -240,7 +241,7 @@ static_assert( tav::Pair, tav::Int<2>>, tav::Int<1>>, tav::Pair, tav::Int<2>>, tav::Int<2>>, tav::Pair, tav::Int<2>>, tav::Int<3>> - >::type + > >::value, "(cond ((= 1 2) 1) ((= 2 2) 2) ((= 3 2) 3)) != 2" ); @@ -253,7 +254,7 @@ static_assert( tav::Pair, tav::Int<3>>, tav::Int< 2>>, tav::Pair, tav::Int<4>>, tav::Int< 3>>, tav::Pair, tav::Int<-1>> - >::type + > >::value, "(cond ((= 1 2) 1) ((= 2 3) 2) ((= 3 4) 3) (else -1)) != -1" ); @@ -264,8 +265,8 @@ static_assert( std::is_same< tav::Int<1>, tav::Car< - tav::Cons, void>::type - >::type + tav::Cons, void> + > >::value, "(car (cons 1 void)) != 1" ); @@ -274,8 +275,8 @@ static_assert( std::is_same< tav::Int<1>, tav::Car< - tav::Cons, tav::Int<2>>::type - >::type + tav::Cons, tav::Int<2>> + > >::value, "(car (cons 1 2)) != 1" ); @@ -284,8 +285,8 @@ static_assert( std::is_same< tav::Int<2>, tav::Cdr< - tav::Cons, tav::Int<2>>::type - >::type + tav::Cons, tav::Int<2>> + > >::value, "(cdr (cons 1 2)) != 2" ); @@ -295,9 +296,9 @@ static_assert( tav::Int<2>, tav::Car< tav::Cdr< - tav::Cons, tav::Cons, tav::Int<3>>::type>::type - >::type - >::type + tav::Cons, tav::Cons, tav::Int<3>>> + > + > >::value, "(car (cdr (cons 1 (cons 2 3)))) != 2" ); @@ -307,7 +308,7 @@ static_assert( static_assert( std::is_same< tav::Pair, void>, - tav::List>::type + tav::List> >::value, "(list 1) != '(1)" ); @@ -315,7 +316,7 @@ static_assert( static_assert( std::is_same< tav::Pair, tav::Pair, void>>, - tav::List, tav::Int<2>>::type + tav::List, tav::Int<2>> >::value, "(list 1 2) != '(1 . 2)" ); @@ -323,7 +324,7 @@ static_assert( static_assert( std::is_same< tav::Pair, tav::Pair, void>>, - tav::List, void, tav::Int<2>, void>::type + tav::List, void, tav::Int<2>, void> >::value, "(list void 1 void 2 void) != '(1 . 2)" ); @@ -332,7 +333,7 @@ static_assert( std::is_same< tav::Int<1>, tav::Head< - tav::List, tav::Int<2>, tav::Int<3>>::type + tav::List, tav::Int<2>, tav::Int<3>> > >::value, "(head (list 1 2 3) != 1" @@ -342,7 +343,7 @@ static_assert( std::is_same< tav::Pair, tav::Pair, void>>, tav::Tail< - tav::List, tav::Int<2>, tav::Int<3>>::type + tav::List, tav::Int<2>, tav::Int<3>> > >::value, "(tail (list 1 2 3) != '(2 . 3)" @@ -353,7 +354,7 @@ static_assert( static_assert( std::is_same< tav::Pair, void>, - tav::ListOfType::type + tav::ListOfType >::value, "(list 1) != (cons 1 void)" ); @@ -361,7 +362,7 @@ static_assert( static_assert( std::is_same< tav::Pair, tav::Pair, void>>, - tav::ListOfType::type + tav::ListOfType >::value, "(list 1 2) != (cons 1 (cons 2 void))" ); @@ -372,8 +373,8 @@ static_assert( std::is_same< tav::Size<1>, tav::Length< - tav::List>::type - >::type + tav::List> + > >::value, "(length (list 1)) != 1" ); @@ -382,8 +383,8 @@ static_assert( std::is_same< tav::Size<2>, tav::Length< - tav::List, tav::Int<2>>::type - >::type + tav::List, tav::Int<2>> + > >::value, "(length (list 1 2)) != 2" ); @@ -395,8 +396,8 @@ static_assert( tav::Int<1>, tav::Nth< tav::Size<0>, - tav::List>::type - >::type + tav::List> + > >::value, "(nth 0 (list 1)) != 1" ); @@ -406,8 +407,8 @@ static_assert( tav::Int<1>, tav::Nth< tav::Size<0>, - tav::List, tav::Int<2>>::type - >::type + tav::List, tav::Int<2>> + > >::value, "(nth 0 (list 1 2)) != 1" ); @@ -417,8 +418,8 @@ static_assert( tav::Int<2>, tav::Nth< tav::Size<1>, - tav::List, tav::Int<2>>::type - >::type + tav::List, tav::Int<2>> + > >::value, "(nth 1 (list 1 2)) != 2" ); @@ -426,7 +427,7 @@ static_assert( static_assert( std::is_same< tav::Int<1>, - tav::First, tav::Int<2>, tav::Int<3>>::type> + tav::First, tav::Int<2>, tav::Int<3>>> >::value, "(first (list 1 2 3)) != 1" ); @@ -434,7 +435,7 @@ static_assert( static_assert( std::is_same< tav::Int<2>, - tav::Second, tav::Int<2>, tav::Int<3>>::type> + tav::Second, tav::Int<2>, tav::Int<3>>> >::value, "(second (list 1 2 3)) != 2" ); @@ -442,7 +443,7 @@ static_assert( static_assert( std::is_same< tav::Int<3>, - tav::Third, tav::Int<2>, tav::Int<3>>::type> + tav::Third, tav::Int<2>, tav::Int<3>>> >::value, "(third (list 1 2 3)) != 3" ); @@ -451,33 +452,33 @@ static_assert( static_assert( std::is_same< - tav::List>::type, + tav::List>, tav::Take< tav::Size<1>, - tav::List, tav::Int<2>>::type - >::type + tav::List, tav::Int<2>> + > >::value, "(take 1 (list 1 2)) != (list 1)" ); static_assert( std::is_same< - tav::List, tav::Int<2>>::type, + tav::List, tav::Int<2>>, tav::Take< tav::Size<2>, - tav::List, tav::Int<2>>::type - >::type + tav::List, tav::Int<2>> + > >::value, "(take 2 (list 1 2)) != (list 1 2)" ); static_assert( std::is_same< - tav::List, tav::Int<2>>::type, + tav::List, tav::Int<2>>, tav::Take< tav::Size<3>, - tav::List, tav::Int<2>>::type - >::type + tav::List, tav::Int<2>> + > >::value, "(take 3 (list 1 2)) != (list 1 2)" ); @@ -486,11 +487,11 @@ static_assert( static_assert( std::is_same< - tav::List>::type, + tav::List>, tav::Drop< tav::Size<1>, - tav::List, tav::Int<2>>::type - >::type + tav::List, tav::Int<2>> + > >::value, "(drop 1 (list 1 2)) != (list 2)" ); @@ -500,8 +501,8 @@ static_assert( void, tav::Drop< tav::Size<2>, - tav::List, tav::Int<2>>::type - >::type + tav::List, tav::Int<2>> + > >::value, "(drop 2 (list 1 2)) != void" ); @@ -511,8 +512,8 @@ static_assert( void, tav::Drop< tav::Size<3>, - tav::List, tav::Int<2>>::type - >::type + tav::List, tav::Int<2>> + > >::value, "(drop 3 (list 1 2)) != void" ); @@ -521,22 +522,22 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<2>>::type, + tav::List, tav::Int<2>>, tav::Append< - tav::List>::type, - tav::List>::type - >::type + tav::List>, + tav::List> + > >::value, "(append (list 1) (list 2)) != (list 1 2)" ); static_assert( std::is_same< - tav::List, tav::Int<2>, tav::Int<3>, tav::Int<4>>::type, + tav::List, tav::Int<2>, tav::Int<3>, tav::Int<4>>, tav::Append< - tav::List, tav::Int<2>>::type, - tav::List, tav::Int<4>>::type - >::type + tav::List, tav::Int<2>>, + tav::List, tav::Int<4>> + > >::value, "(append (list 1 2) (list 3 4)) != (list 1 2 3 4)" ); @@ -549,8 +550,8 @@ static_assert( tav::Fold< tav::Add, tav::Int<0>, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(fold + 0 (list 1 2 3)) != 6" ); @@ -562,11 +563,11 @@ using quadruple = tav::Multiply, Element>; static_assert( std::is_same< - tav::List, tav::Int<8>, tav::Int<12>>::type, + tav::List, tav::Int<8>, tav::Int<12>>, tav::Map< quadruple, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(map quadruple (list 1 2 3)) != (list 4 8 12)" ); @@ -575,11 +576,11 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<3>>::type, + tav::List, tav::Int<3>>, tav::Filter< tav::Odd, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(filter odd? (list 1 2 3)) != (list 1 3)" ); @@ -588,11 +589,11 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<3>>::type, + tav::List, tav::Int<3>>, tav::Remove< tav::Even, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(remove even? (list 1 2 3)) != (list 1 3)" ); @@ -601,22 +602,22 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<3>>::type, + tav::List, tav::Int<3>>, tav::Delete< tav::Int<2>, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(delete 2 (list 1 2 3)) != (list 1 3)" ); static_assert( std::is_same< - tav::List, tav::Int<2>, tav::Int<3>>::type, + tav::List, tav::Int<2>, tav::Int<3>>, tav::Delete< tav::Int<4>, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(delete 4 (list 1 2 3)) != (list 1 2 3)" ); @@ -625,11 +626,11 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<3>>::type, + tav::List, tav::Int<3>>, tav::DeleteNth< tav::Size<1>, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(delete-nth 1 (list 1 2 3)) != (list 1 3)" ); @@ -639,13 +640,13 @@ static_assert( static_assert( std::is_same< tav::Pair< - tav::List, tav::Int<3>>::type, - tav::List>::type + tav::List, tav::Int<3>>, + tav::List> >, tav::Partition< tav::Odd, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(partition odd? (list 1 2 3)) != [(list 1 3) (list 2)]" ); @@ -654,10 +655,10 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<2>, tav::Int<1>>::type, + tav::List, tav::Int<2>, tav::Int<1>>, tav::Reverse< - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(reverse (list 1 2 3)) != (list 3 2 1)" ); @@ -669,8 +670,8 @@ static_assert( tav::Boolean, tav::Any< tav::Odd, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(any odd? (list 1 2 3)) != #t" ); @@ -680,8 +681,8 @@ static_assert( tav::Boolean, tav::Any< tav::Odd, - tav::List, tav::Int<4>, tav::Int<6>>::type - >::type + tav::List, tav::Int<4>, tav::Int<6>> + > >::value, "(any odd? (list 2 4 6)) != #f" ); @@ -691,8 +692,8 @@ static_assert( tav::Boolean, tav::All< tav::Even, - tav::List, tav::Int<4>, tav::Int<6>>::type - >::type + tav::List, tav::Int<4>, tav::Int<6>> + > >::value, "(all even? (list 2 4 6)) != #t" ); @@ -702,8 +703,8 @@ static_assert( tav::Boolean, tav::All< tav::Odd, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(all odd? (list 1 2 3)) != #f" ); @@ -713,8 +714,8 @@ static_assert( tav::Boolean, tav::None< tav::Even, - tav::List, tav::Int<3>, tav::Int<5>>::type - >::type + tav::List, tav::Int<3>, tav::Int<5>> + > >::value, "(none even? (list 1 3 5)) != #t" ); @@ -724,8 +725,8 @@ static_assert( tav::Boolean, tav::None< tav::Even, - tav::List, tav::Int<3>, tav::Int<5>>::type - >::type + tav::List, tav::Int<3>, tav::Int<5>> + > >::value, "(none even? (list 2 3 5)) != #f" ); @@ -737,8 +738,8 @@ static_assert( tav::Boolean, tav::Contains< tav::Int<2>, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(contains 2 (list 1 2 3)) != #t" ); @@ -748,8 +749,8 @@ static_assert( tav::Boolean, tav::Contains< tav::Int<0>, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(contains 0 (list 1 2 3)) != #f" ); @@ -758,14 +759,14 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<2>, tav::Int<3>, tav::Int<4>, tav::Int<5>, tav::Int<6>>::type, + tav::List, tav::Int<2>, tav::Int<3>, tav::Int<4>, tav::Int<5>, tav::Int<6>>, tav::Concatenate< tav::List< - tav::List, tav::Int<2>>::type, - tav::List>::type, - tav::List, tav::Int<5>, tav::Int<6>>::type - >::type - >::type + tav::List, tav::Int<2>>, + tav::List>, + tav::List, tav::Int<5>, tav::Int<6>> + > + > >::value, "(concatenate (list (list 1 2) (list 3) (list 4 5 6))) != (list 1 2 3 4 5 6)" ); @@ -774,48 +775,48 @@ static_assert( static_assert( std::is_same< - tav::List>::type, + tav::List>, tav::Iota< tav::Size<1>, tav::Int<1>, tav::Int<1> - >::type + > >::value, "(iota 1 1 1) != (list 1)" ); static_assert( std::is_same< - tav::List, tav::Int<2>, tav::Int<3>>::type, + tav::List, tav::Int<2>, tav::Int<3>>, tav::Iota< tav::Size<3>, tav::Int<1>, tav::Int<1> - >::type + > >::value, "(iota 3 1 1) != (list 1 2 3)" ); static_assert( std::is_same< - tav::List, tav::Int<2>, tav::Int<4>, tav::Int<6>, tav::Int<8>>::type, + tav::List, tav::Int<2>, tav::Int<4>, tav::Int<6>, tav::Int<8>>, tav::Iota< tav::Size<5>, tav::Int<0>, tav::Int<2> - >::type + > >::value, "(iota 5 0 2) != (list 0 2 4 6 8)" ); static_assert( std::is_same< - tav::List, tav::Int<4>, tav::Int<3>, tav::Int<2>, tav::Int<1>>::type, + tav::List, tav::Int<4>, tav::Int<3>, tav::Int<2>, tav::Int<1>>, tav::Iota< tav::Size<5>, tav::Int<5>, tav::Int<-1> - >::type + > >::value, "(iota 5 5 -1) != (list 5 4 3 2 1)" ); @@ -824,16 +825,16 @@ static_assert( static_assert( std::is_same< - tav::List>::type, - tav::MakeList, tav::Int<42>>::type + tav::List>, + tav::MakeList, tav::Int<42>> >::value, "(make-list 1 42) != (list 42)" ); static_assert( std::is_same< - tav::List, tav::Int<42>, tav::Int<42>>::type, - tav::MakeList, tav::Int<42>>::type + tav::List, tav::Int<42>, tav::Int<42>>, + tav::MakeList, tav::Int<42>> >::value, "(make-list 3 42) != (list 42 42 42)" ); @@ -842,11 +843,11 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Size<1>, tav::Size<4>, tav::Size<9>>::type, + tav::List, tav::Size<1>, tav::Size<4>, tav::Size<9>>, tav::ListTabulate< tav::Size<4>, tav::Square - >::type + > >::value, "(list-tabulate 4 square) != (list 0 1 4 9)" ); @@ -858,8 +859,8 @@ static_assert( tav::Size<2>, tav::Count< tav::Odd, - tav::List, tav::Int<2>, tav::Int<3>>::type - >::type + tav::List, tav::Int<2>, tav::Int<3>> + > >::value, "(count odd? (list 1 2 3)) != 2" ); @@ -869,8 +870,8 @@ static_assert( tav::Size<0>, tav::Count< tav::Even, - tav::List, tav::Int<3>, tav::Int<5>>::type - >::type + tav::List, tav::Int<3>, tav::Int<5>> + > >::value, "(count even? (list 1 3 5)) != 0" ); @@ -882,8 +883,8 @@ static_assert( tav::Int<4>, tav::Find< tav::Even, - tav::List, tav::Int<3>, tav::Int<4>, tav::Int<6>>::type - >::type + tav::List, tav::Int<3>, tav::Int<4>, tav::Int<6>> + > >::value, "(find even? (list 1 3 4 6)) != 4" ); @@ -893,8 +894,8 @@ static_assert( tav::Int<6>, tav::Find< tav::Even, - tav::List, tav::Int<3>, tav::Int<5>, tav::Int<6>>::type - >::type + tav::List, tav::Int<3>, tav::Int<5>, tav::Int<6>> + > >::value, "(find even? (list 1 3 5 6)) != 6" ); @@ -904,8 +905,8 @@ static_assert( tav::Boolean, tav::Find< tav::Even, - tav::List, tav::Int<3>, tav::Int<5>>::type - >::type + tav::List, tav::Int<3>, tav::Int<5>> + > >::value, "(find even? (list 1 3 5)) != #f" ); @@ -914,22 +915,22 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<4>>::type, + tav::List, tav::Int<4>>, tav::TakeWhile< tav::Even, - tav::List, tav::Int<4>, tav::Int<5>, tav::Int<6>>::type - >::type + tav::List, tav::Int<4>, tav::Int<5>, tav::Int<6>> + > >::value, "(take-while even? (list 2 4 5 6)) != (list 2 4)" ); static_assert( std::is_same< - tav::List, tav::Int<4>, tav::Int<6>>::type, + tav::List, tav::Int<4>, tav::Int<6>>, tav::TakeWhile< tav::Even, - tav::List, tav::Int<4>, tav::Int<6>>::type - >::type + tav::List, tav::Int<4>, tav::Int<6>> + > >::value, "(take-while even? (list 2 4 6)) != (list 2 4 6)" ); @@ -939,8 +940,8 @@ static_assert( void, tav::TakeWhile< tav::Odd, - tav::List, tav::Int<4>, tav::Int<5>, tav::Int<6>>::type - >::type + tav::List, tav::Int<4>, tav::Int<5>, tav::Int<6>> + > >::value, "(take-while odd? (list 2 4 5 6)) != void" ); @@ -949,22 +950,22 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<6>>::type, + tav::List, tav::Int<6>>, tav::DropWhile< tav::Even, - tav::List, tav::Int<4>, tav::Int<5>, tav::Int<6>>::type - >::type + tav::List, tav::Int<4>, tav::Int<5>, tav::Int<6>> + > >::value, "(drop-while even? (list 2 4 5 6)) != (list 5 6)" ); static_assert( std::is_same< - tav::List, tav::Int<4>, tav::Int<6>>::type, + tav::List, tav::Int<4>, tav::Int<6>>, tav::DropWhile< tav::Odd, - tav::List, tav::Int<4>, tav::Int<6>>::type - >::type + tav::List, tav::Int<4>, tav::Int<6>> + > >::value, "(drop-while odd? (list 2 4 6)) != (list 2 4 6)" ); @@ -974,8 +975,8 @@ static_assert( void, tav::DropWhile< tav::Even, - tav::List, tav::Int<4>, tav::Int<6>>::type - >::type + tav::List, tav::Int<4>, tav::Int<6>> + > >::value, "(drop-while even? (list 2 4 6)) != void" ); @@ -984,33 +985,33 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<2>, tav::Int<3>>::type, + tav::List, tav::Int<2>, tav::Int<3>>, tav::Sort< tav::GreaterThan, - tav::List, tav::Int<2>, tav::Int<1>>::type - >::type + tav::List, tav::Int<2>, tav::Int<1>> + > >::value, "(sort > (list 3 2 1)) != (list 1 2 3)" ); static_assert( std::is_same< - tav::List, tav::Int<2>, tav::Int<1>>::type, + tav::List, tav::Int<2>, tav::Int<1>>, tav::Sort< tav::LowerThan, - tav::List, tav::Int<3>, tav::Int<2>>::type - >::type + tav::List, tav::Int<3>, tav::Int<2>> + > >::value, "(sort < (list 1 3 2)) != (list 3 2 1)" ); static_assert( std::is_same< - tav::Iota, tav::Int<1>, tav::Int<1>>::type, + tav::Iota, tav::Int<1>, tav::Int<1>>, tav::Sort< tav::GreaterThan, - tav::Iota, tav::Int<42>, tav::Int<-1>>::type - >::type + tav::Iota, tav::Int<42>, tav::Int<-1>> + > >::value, "(sort > (iota 42 42 -1)) != (iota 42 1 1)" ); @@ -1033,15 +1034,15 @@ static_assert( static_assert( std::is_same< - tav::List, tav::Int<12>, tav::Int<14>>::type, + tav::List, tav::Int<12>, tav::Int<14>>, tav::Map< tav::Apply< tav::Add, tav::_0, tav::Int<10> >::function, - tav::List, tav::Int<2>, tav::Int<4>>::type - >::type + tav::List, tav::Int<2>, tav::Int<4>> + > >::value, "(map (lambda (x) (+ x 10)) (list 0 2 4)) != (list 10 12 14)" ); -- cgit v1.2.3