@@ -8,6 +8,8 @@ import Control.Monad.Eff.Console (log, CONSOLE)
88import Data.Array (range , replicate , foldM , unzip , zip , zipWithA , zipWith , intersectBy , intersect , (\\), deleteBy , delete , unionBy , union , nubBy , nub , groupBy , group' , group , span , dropWhile , drop , takeWhile , take , sortBy , sort , catMaybes , mapMaybe , mapWithIndex , filterM , filter , concat , concatMap , reverse , alterAt , modifyAt , updateAt , deleteAt , insertAt , findLastIndex , findIndex , elemLastIndex , elemIndex , (!!), uncons , init , tail , last , head , insertBy , insert , snoc , (:), length , null , singleton , fromFoldable )
99import Data.Foldable (for_ , foldMapDefaultR , class Foldable , all )
1010import Data.Maybe (Maybe (..), isNothing , fromJust )
11+ import Data.NonEmpty ((:|))
12+ import Data.NonEmpty as NE
1113import Data.Tuple (Tuple (..))
1214import Data.Unfoldable (replicateA )
1315
@@ -240,13 +242,13 @@ testArray = do
240242 assert $ spanResult.rest == [4 , 5 , 6 , 7 ]
241243
242244 log " group should group consecutive equal elements into arrays"
243- assert $ group [1 , 2 , 2 , 3 , 3 , 3 , 1 ] == [[ 1 ], [ 2 , 2 ], [ 3 , 3 , 3 ], [ 1 ] ]
245+ assert $ group [1 , 2 , 2 , 3 , 3 , 3 , 1 ] == [NE .singleton 1 , 2 :| [ 2 ], 3 :| [ 3 , 3 ], NE .singleton 1 ]
244246
245247 log " group' should sort then group consecutive equal elements into arrays"
246- assert $ group' [1 , 2 , 2 , 3 , 3 , 3 , 1 ] == [[ 1 , 1 ], [ 2 , 2 ], [ 3 , 3 , 3 ]]
248+ assert $ group' [1 , 2 , 2 , 3 , 3 , 3 , 1 ] == [1 :| [ 1 ], 2 :| [ 2 ], 3 :| [ 3 , 3 ]]
247249
248250 log " groupBy should group consecutive equal elements into arrays based on an equivalence relation"
249- assert $ groupBy (\x y -> odd x && odd y) [1 , 1 , 2 , 2 , 3 , 3 ] == [[ 1 , 1 ], [ 2 ], [ 2 ], [ 3 , 3 ]]
251+ assert $ groupBy (\x y -> odd x && odd y) [1 , 1 , 2 , 2 , 3 , 3 ] == [1 :| [ 1 ], NE .singleton 2 , NE .singleton 2 , 3 :| [ 3 ]]
250252
251253 log " nub should remove duplicate elements from the list, keeping the first occurence"
252254 assert $ nub [1 , 2 , 2 , 3 , 4 , 1 ] == [1 , 2 , 3 , 4 ]
0 commit comments