diff options
author | Adrian Kummerlaender | 2015-02-17 18:55:08 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-02-17 18:55:08 +0100 |
commit | 8e4e3466694e5bef43f1308296a76086a7db453d (patch) | |
tree | 84049e2604341a0326e99d31cbed898fe5448d2d /test.cc | |
parent | f81cd736e00c28cf24412a4099bae08ff2e6c493 (diff) | |
download | TypeAsValue-8e4e3466694e5bef43f1308296a76086a7db453d.tar TypeAsValue-8e4e3466694e5bef43f1308296a76086a7db453d.tar.gz TypeAsValue-8e4e3466694e5bef43f1308296a76086a7db453d.tar.bz2 TypeAsValue-8e4e3466694e5bef43f1308296a76086a7db453d.tar.lz TypeAsValue-8e4e3466694e5bef43f1308296a76086a7db453d.tar.xz TypeAsValue-8e4e3466694e5bef43f1308296a76086a7db453d.tar.zst TypeAsValue-8e4e3466694e5bef43f1308296a76086a7db453d.zip |
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
Diffstat (limited to 'test.cc')
-rw-r--r-- | test.cc | 132 |
1 files changed, 66 insertions, 66 deletions
@@ -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::Int<1>> + tav::List<tav::Int<1>>, + tav::Take< + tav::Size<1>, + tav::List<tav::Int<1>, 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<1>, tav::Int<2>>, + tav::Take< + tav::Size<2>, tav::List<tav::Int<1>, 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::Int<1>> + tav::List<tav::Int<1>, tav::Int<2>>, + tav::Take< + tav::Size<3>, + tav::List<tav::Int<1>, 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::Int<2>>, + tav::Drop< + tav::Size<1>, tav::List<tav::Int<1>, 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<1>, 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::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>> + void, + tav::Drop< + tav::Size<3>, + tav::List<tav::Int<1>, 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::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>> + tav::Size<1>, + tav::Length< + tav::List<tav::Int<1>> + > >::value, - "(second (list 1 2 3)) != 2" + "(length (list 1)) != 1" ); static_assert( std::is_same< - tav::Int<3>, - tav::Third<tav::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>> + tav::Size<2>, + tav::Length< + tav::List<tav::Int<1>, 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::Int<1>>, - tav::Take< - tav::Size<1>, - tav::List<tav::Int<1>, tav::Int<2>> + tav::Int<1>, + tav::Nth< + tav::Size<0>, + tav::List<tav::Int<1>> > >::value, - "(take 1 (list 1 2)) != (list 1)" + "(nth 0 (list 1)) != 1" ); static_assert( std::is_same< - tav::List<tav::Int<1>, tav::Int<2>>, - tav::Take< - tav::Size<2>, + tav::Int<1>, + tav::Nth< + tav::Size<0>, tav::List<tav::Int<1>, 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<1>, tav::Int<2>>, - tav::Take< - tav::Size<3>, + tav::Int<2>, + tav::Nth< + tav::Size<1>, tav::List<tav::Int<1>, 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::Int<2>>, - tav::Drop< - tav::Size<1>, - tav::List<tav::Int<1>, tav::Int<2>> - > + tav::Int<1>, + tav::First<tav::List<tav::Int<1>, 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<1>, tav::Int<2>> - > + tav::Int<2>, + tav::Second<tav::List<tav::Int<1>, 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<1>, tav::Int<2>> - > + tav::Int<3>, + tav::Third<tav::List<tav::Int<1>, tav::Int<2>, tav::Int<3>>> >::value, - "(drop 3 (list 1 2)) != void" + "(third (list 1 2 3)) != 3" ); // list append |