CS 3500 Lecture 2: Function Definitions Pt. 1
Document Summary
Definitions of functions in haskell pt. 1 fst :: (a,b) -> a fst (x,y) = x. Ii. snd :: (a,b) -> b snd (x,y) = y. Iii. curry converts an uncurried function to a curried function: curry :: ((a, b) -> c) -> a -> b -> c curry f x y = f (x, y) | otherwise = until p f (f x) Vi. error stops execution and displays an error message: error :: string -> a error = primerror. Map: map :: (a -> b) -> [a] -> [b] map f [] = [] map f (x:xs) = f x : map f xs. Filter: filters unwanted elements out of a list of elements in haskell. 10/22/2017: filter :: (a -> bool) -> [a] -> [a] filter p [] = [] filter p (x:xs) | p x = x : filter p xs.