Created
April 28, 2019 07:49
-
-
Save rexcfnghk/054ba5fb93136db41b69607eae228d0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add :: a -> [a] -> [a] | |
add x xs = x : xs | |
-- it is more common to write as | |
-- add = (:) | |
remove :: (Eq a) => a -> [a] -> [a] | |
remove _ [] = [] | |
remove t (x:xs) = if t == x then remove t xs else remove t (x:xs) | |
-- you can also write it as a fold | |
-- remove t = foldr (\x xs -> if x == t then xs else x:xs) [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment