@@ -5,7 +5,7 @@ import Data.List.NonEmpty as NEL
55import Control.Monad.Eff (Eff )
66import Control.Monad.Eff.Console (CONSOLE , log )
77import Data.Foldable (foldMap , foldl )
8- import Data.List (List (..), (..), stripPrefix , Pattern (..), length , range , foldM , unzip , zip , zipWithA , zipWith , intersectBy , intersect , (\\), deleteBy , delete , unionBy , union , nubBy , nub , groupBy , group' , group , partition , span , dropWhile , drop , takeWhile , take , sortBy , sort , catMaybes , mapMaybe , filterM , filter , concat , concatMap , reverse , alterAt , modifyAt , updateAt , deleteAt , insertAt , findLastIndex , findIndex , elemLastIndex , elemIndex , (!!), uncons , unsnoc , init , tail , last , head , insertBy , insert , snoc , null , singleton , fromFoldable , transpose , mapWithIndex , (:))
8+ import Data.List (List (..), (..), stripPrefix , Pattern (..), length , range , foldM , unzip , zip , zipWithA , zipWith , intersectBy , intersect , (\\), deleteBy , delete , unionBy , union , nubBy , nub , groupBy , group' , group , partition , span , dropWhile , drop , dropEnd , takeWhile , take , takeEnd , sortBy , sort , catMaybes , mapMaybe , filterM , filter , concat , concatMap , reverse , alterAt , modifyAt , updateAt , deleteAt , insertAt , findLastIndex , findIndex , elemLastIndex , elemIndex , (!!), uncons , unsnoc , init , tail , last , head , insertBy , insert , snoc , null , singleton , fromFoldable , transpose , mapWithIndex , (:))
99import Data.Maybe (Maybe (..), isNothing , fromJust )
1010import Data.Monoid.Additive (Additive (..))
1111import Data.NonEmpty ((:|))
@@ -226,16 +226,26 @@ testList = do
226226 assert $ (take 2 (l [1 , 2 , 3 ])) == l [1 , 2 ]
227227 assert $ (take 1 nil) == nil
228228
229+ log " takeEnd should keep the specified number of items from the end of an list, discarding the rest"
230+ assert $ (takeEnd 1 (l [1 , 2 , 3 ])) == l [3 ]
231+ assert $ (takeEnd 2 (l [1 , 2 , 3 ])) == l [2 , 3 ]
232+ assert $ (takeEnd 1 nil) == nil
233+
229234 log " takeWhile should keep all values that match a predicate from the front of an list"
230235 assert $ (takeWhile (_ /= 2 ) (l [1 , 2 , 3 ])) == l [1 ]
231236 assert $ (takeWhile (_ /= 3 ) (l [1 , 2 , 3 ])) == l [1 , 2 ]
232237 assert $ (takeWhile (_ /= 1 ) nil) == nil
233238
234- log " drop should remove the specified number of items from the front of an list"
239+ log " dropE should remove the specified number of items from the front of an list"
235240 assert $ (drop 1 (l [1 , 2 , 3 ])) == l [2 , 3 ]
236241 assert $ (drop 2 (l [1 , 2 , 3 ])) == l [3 ]
237242 assert $ (drop 1 nil) == nil
238243
244+ log " dropEnd should remove the specified number of items from the end of an list"
245+ assert $ (dropEnd 1 (l [1 , 2 , 3 ])) == l [1 , 2 ]
246+ assert $ (dropEnd 2 (l [1 , 2 , 3 ])) == l [1 ]
247+ assert $ (dropEnd 1 nil) == nil
248+
239249 log " dropWhile should remove all values that match a predicate from the front of an list"
240250 assert $ (dropWhile (_ /= 1 ) (l [1 , 2 , 3 ])) == l [1 , 2 , 3 ]
241251 assert $ (dropWhile (_ /= 2 ) (l [1 , 2 , 3 ])) == l [2 , 3 ]
0 commit comments