@@ -5,7 +5,7 @@ import Data.List.NonEmpty as NEL
5
5
import Control.Monad.Eff (Eff )
6
6
import Control.Monad.Eff.Console (CONSOLE , log )
7
7
import 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 , (:))
9
9
import Data.Maybe (Maybe (..), isNothing , fromJust )
10
10
import Data.Monoid.Additive (Additive (..))
11
11
import Data.NonEmpty ((:|))
@@ -226,16 +226,26 @@ testList = do
226
226
assert $ (take 2 (l [1 , 2 , 3 ])) == l [1 , 2 ]
227
227
assert $ (take 1 nil) == nil
228
228
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
+
229
234
log " takeWhile should keep all values that match a predicate from the front of an list"
230
235
assert $ (takeWhile (_ /= 2 ) (l [1 , 2 , 3 ])) == l [1 ]
231
236
assert $ (takeWhile (_ /= 3 ) (l [1 , 2 , 3 ])) == l [1 , 2 ]
232
237
assert $ (takeWhile (_ /= 1 ) nil) == nil
233
238
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"
235
240
assert $ (drop 1 (l [1 , 2 , 3 ])) == l [2 , 3 ]
236
241
assert $ (drop 2 (l [1 , 2 , 3 ])) == l [3 ]
237
242
assert $ (drop 1 nil) == nil
238
243
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
+
239
249
log " dropWhile should remove all values that match a predicate from the front of an list"
240
250
assert $ (dropWhile (_ /= 1 ) (l [1 , 2 , 3 ])) == l [1 , 2 , 3 ]
241
251
assert $ (dropWhile (_ /= 2 ) (l [1 , 2 , 3 ])) == l [2 , 3 ]
0 commit comments