@@ -5,7 +5,7 @@ import Prelude
5
5
import Control.Monad.Eff (Eff )
6
6
import Control.Monad.Eff.Console (log , CONSOLE )
7
7
8
- import Data.Array (range , 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 , 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 )
8
+ import Data.Array (range , 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 )
9
9
import Data.Foldable (for_ , foldMapDefaultR , class Foldable , all )
10
10
import Data.Maybe (Maybe (..), isNothing , fromJust )
11
11
import Data.Tuple (Tuple (..))
@@ -201,6 +201,9 @@ testArray = do
201
201
log " catMaybe should take an array of Maybe values and throw out Nothings"
202
202
assert $ catMaybes [Nothing , Just 2 , Nothing , Just 4 ] == [2 , 4 ]
203
203
204
+ log " mapWithIndex applies a function with an index for every element"
205
+ assert $ mapWithIndex (\i x -> x - i) [9 ,8 ,7 ,6 ,5 ] == [9 ,7 ,5 ,3 ,1 ]
206
+
204
207
log " sort should reorder a list into ascending order based on the result of compare"
205
208
assert $ sort [1 , 3 , 2 , 5 , 6 , 4 ] == [1 , 2 , 3 , 4 , 5 , 6 ]
206
209
0 commit comments