lib.dropEnd: init

Naming borrowed from Haskell
- `base`: [`dropWhileEnd`]
- `extra`, `mono-traversable`, ...: [`dropEnd`]

[`dropEnd`]: https://hackage.haskell.org/package/mono-traversable-1.0.21.0/docs/Data-Sequences.html#v:dropEnd
[`dropWhileEnd`]: https://hackage.haskell.org/package/base-4.21.0.0/docs/Data-List.html#v:dropWhileEnd
This commit is contained in:
Robert Hensing
2025-01-03 12:03:48 +01:00
parent c96e907825
commit 782a0e6581
3 changed files with 56 additions and 2 deletions

View File

@@ -866,6 +866,18 @@ runTests {
(drop 1 [ ] == [ ])
];
testDropEnd = let inherit (lib) dropEnd; in testAllTrue [
(dropEnd 0 [ 1 2 3 ] == [ 1 2 3 ])
(dropEnd 1 [ 1 2 3 ] == [ 1 2 ])
(dropEnd 2 [ 1 2 3 ] == [ 1 ])
(dropEnd 3 [ 1 2 3 ] == [ ])
(dropEnd 4 [ 1 2 3 ] == [ ])
(dropEnd 0 [ ] == [ ])
(dropEnd 1 [ ] == [ ])
(dropEnd (-1) [ 1 2 3 ] == [ 1 2 3 ])
(dropEnd (-1) [ ] == [ ])
];
testListHasPrefixExample1 = {
expr = lists.hasPrefix [ 1 2 ] [ 1 2 3 4 ];
expected = true;