File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 23
23
24
24
(!!) :: forall a. [a] -> Prim.Number -> Maybe a
25
25
26
+ (\\) :: forall a. (Eq a) => [a] -> [a] -> [a]
27
+
26
28
append :: forall a. [a] -> [a] -> [a]
27
29
28
30
catMaybes :: forall a. [Maybe a] -> [a]
31
33
32
34
concatMap :: forall a b. (a -> [b]) -> [a] -> [b]
33
35
36
+ delete :: forall a. (Eq a) => a -> [a] -> [a]
37
+
34
38
deleteAt :: forall a. Prim.Number -> Prim.Number -> [a] -> [a]
35
39
40
+ deleteBy :: forall a. (a -> a -> Prim.Boolean) -> a -> [a] -> [a]
41
+
36
42
drop :: forall a. Prim.Number -> [a] -> [a]
37
43
38
44
elemIndex :: forall a. (Eq a) => a -> [a] -> Prim.Number
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ module Data.Array
23
23
, insertAt
24
24
, deleteAt
25
25
, updateAt
26
+ , deleteBy
27
+ , delete
28
+ , (\\)
26
29
, concatMap
27
30
, filter
28
31
, range
@@ -193,6 +196,24 @@ foreign import updateAt
193
196
\ };\
194
197
\}" :: forall a . Number -> a -> [a ] -> [a ]
195
198
199
+ deleteBy :: forall a . (a -> a -> Boolean ) -> a -> [a ] -> [a ]
200
+ deleteBy _ _ [] = []
201
+ deleteBy eq x ys = case findIndex (eq x) ys of
202
+ i | i < 0 -> ys
203
+ i -> deleteAt i 1 ys
204
+
205
+ delete :: forall a . (Eq a ) => a -> [a ] -> [a ]
206
+ delete = deleteBy (==)
207
+
208
+ infix 5 \\
209
+
210
+ (\\) :: forall a . (Eq a ) => [a ] -> [a ] -> [a ]
211
+ (\\) xs ys = go xs ys
212
+ where
213
+ go [] ys = ys
214
+ go _ [] = []
215
+ go (x:xs) ys = go xs (delete x ys)
216
+
196
217
foreign import concatMap
197
218
" function concatMap (f) {\
198
219
\ return function (arr) {\
You can’t perform that action at this time.
0 commit comments