From 8e4e3466694e5bef43f1308296a76086a7db453d Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 17 Feb 2015 18:55:08 +0100 Subject: Expressed `Take` and `Drop` in terms of new `Section` operation * unifies the common functionality between `Take` and `Drop` * renamed `basic.h` to `length.h` as it only contains the `Length` implementation --- test.cc | 132 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'test.cc') diff --git a/test.cc b/test.cc index 074d711..6560795 100644 --- a/test.cc +++ b/test.cc @@ -359,155 +359,155 @@ static_assert( "(list 1 2) != (cons 1 (cons 2 void))" ); -// list length +// list take static_assert( std::is_same< - tav::Size<1>, - tav::Length< - tav::List> + tav::List>, + tav::Take< + tav::Size<1>, + tav::List, tav::Int<2>> > >::value, - "(length (list 1)) != 1" + "(take 1 (list 1 2)) != (list 1)" ); static_assert( std::is_same< - tav::Size<2>, - tav::Length< + tav::List, tav::Int<2>>, + tav::Take< + tav::Size<2>, tav::List, tav::Int<2>> > >::value, - "(length (list 1 2)) != 2" + "(take 2 (list 1 2)) != (list 1 2)" ); -// list nth - static_assert( std::is_same< - tav::Int<1>, - tav::Nth< - tav::Size<0>, - tav::List> + tav::List, tav::Int<2>>, + tav::Take< + tav::Size<3>, + tav::List, tav::Int<2>> > >::value, - "(nth 0 (list 1)) != 1" + "(take 3 (list 1 2)) != (list 1 2)" ); +// list drop + static_assert( std::is_same< - tav::Int<1>, - tav::Nth< - tav::Size<0>, + tav::List>, + tav::Drop< + tav::Size<1>, tav::List, tav::Int<2>> > >::value, - "(nth 0 (list 1 2)) != 1" + "(drop 1 (list 1 2)) != (list 2)" ); static_assert( std::is_same< - tav::Int<2>, - tav::Nth< - tav::Size<1>, + void, + tav::Drop< + tav::Size<2>, tav::List, tav::Int<2>> > >::value, - "(nth 1 (list 1 2)) != 2" + "(drop 2 (list 1 2)) != void" ); static_assert( std::is_same< - tav::Int<1>, - tav::First, tav::Int<2>, tav::Int<3>>> + void, + tav::Drop< + tav::Size<3>, + tav::List, tav::Int<2>> + > >::value, - "(first (list 1 2 3)) != 1" + "(drop 3 (list 1 2)) != void" ); +// list length + static_assert( std::is_same< - tav::Int<2>, - tav::Second, tav::Int<2>, tav::Int<3>>> + tav::Size<1>, + tav::Length< + tav::List> + > >::value, - "(second (list 1 2 3)) != 2" + "(length (list 1)) != 1" ); static_assert( std::is_same< - tav::Int<3>, - tav::Third, tav::Int<2>, tav::Int<3>>> + tav::Size<2>, + tav::Length< + tav::List, tav::Int<2>> + > >::value, - "(third (list 1 2 3)) != 3" + "(length (list 1 2)) != 2" ); -// list take +// list nth static_assert( std::is_same< - tav::List>, - tav::Take< - tav::Size<1>, - tav::List, tav::Int<2>> + tav::Int<1>, + tav::Nth< + tav::Size<0>, + tav::List> > >::value, - "(take 1 (list 1 2)) != (list 1)" + "(nth 0 (list 1)) != 1" ); static_assert( std::is_same< - tav::List, tav::Int<2>>, - tav::Take< - tav::Size<2>, + tav::Int<1>, + tav::Nth< + tav::Size<0>, tav::List, tav::Int<2>> > >::value, - "(take 2 (list 1 2)) != (list 1 2)" + "(nth 0 (list 1 2)) != 1" ); static_assert( std::is_same< - tav::List, tav::Int<2>>, - tav::Take< - tav::Size<3>, + tav::Int<2>, + tav::Nth< + tav::Size<1>, tav::List, tav::Int<2>> > >::value, - "(take 3 (list 1 2)) != (list 1 2)" + "(nth 1 (list 1 2)) != 2" ); -// list drop - static_assert( std::is_same< - tav::List>, - tav::Drop< - tav::Size<1>, - tav::List, tav::Int<2>> - > + tav::Int<1>, + tav::First, tav::Int<2>, tav::Int<3>>> >::value, - "(drop 1 (list 1 2)) != (list 2)" + "(first (list 1 2 3)) != 1" ); static_assert( std::is_same< - void, - tav::Drop< - tav::Size<2>, - tav::List, tav::Int<2>> - > + tav::Int<2>, + tav::Second, tav::Int<2>, tav::Int<3>>> >::value, - "(drop 2 (list 1 2)) != void" + "(second (list 1 2 3)) != 2" ); static_assert( std::is_same< - void, - tav::Drop< - tav::Size<3>, - tav::List, tav::Int<2>> - > + tav::Int<3>, + tav::Third, tav::Int<2>, tav::Int<3>>> >::value, - "(drop 3 (list 1 2)) != void" + "(third (list 1 2 3)) != 3" ); // list append -- cgit v1.2.3