@@ -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 , 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 )
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 , find , 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 (..))
@@ -128,6 +128,10 @@ testArray = do
128
128
assert $ (elemLastIndex 1 [1 , 2 , 1 ]) == Just 2
129
129
assert $ (elemLastIndex 4 [1 , 2 , 1 ]) == Nothing
130
130
131
+ log " find should return the item that a predicate returns true for in an array"
132
+ assert $ (find (_ /= " foo" ) [" foo" , " bar" , " baz" ]) == Just " bar"
133
+ assert $ (find (_ == " qux" ) [" foo" , " bar" , " baz" ]) == Nothing
134
+
131
135
log " findIndex should return the index of an item that a predicate returns true for in an array"
132
136
assert $ (findIndex (_ /= 1 ) [1 , 2 , 1 ]) == Just 1
133
137
assert $ (findIndex (_ == 3 ) [1 , 2 , 1 ]) == Nothing
0 commit comments