@@ -644,6 +644,21 @@ module Data.Array where
644 take _ [] = []
644 take _ [] = []
645 take n (x:xs) = x : take (n - 1) xs
645 take n (x:xs) = x : take (n - 1) xs
647+ nub :: forall a. (Eq a) => [a] -> [a]
650+ nubBy :: forall a. (a -> a -> Boolean) -> [a] -> [a]
652+ nubBy (==) (x:xs) = x : nubBy (==) (filter (\y -> not (x == y)) xs)
654+ elem :: forall a. (Eq a) => a -> [a] -> Boolean
655+ elem a (a' : as) | a == a' = true
656+ elem a (_ : as) = a `elem` as
659+ notElem :: forall a. (Eq a) => a -> [a] -> Boolean
660+ notElem a as = not (a `elem` as)
647 instance showArray :: (Show a) => Show [a] where
662 instance showArray :: (Show a) => Show [a] where
648 show xs = "[" ++ joinWith (map show xs) "," ++ "]"
663 show xs = "[" ++ joinWith (map show xs) "," ++ "]"