examplePair :: (Double, Bool) examplePair = (3.14, False) exampleTriple :: (Bool, Int, String) exampleTriple = (False, 42, "Answer") exampleFunction :: (Bool, Int, String) -> Bool exampleFunction (b,n,s) = not b && length s < n
AÂ
[A]Â
AÂ
[Integer]Â
IntegerÂ
[A]Â
AÂ
[A]Â
[Integer]Â
summary :: [String] -> String summary [] = "Nothing" summary [x] = "Just "++x summary [x,y] = x++" and "++y summary _ = "Several things"
-- doubles [3,6,10] = [6,12,20]
doubles :: [Integer] -> [Integer]
doubles [] = (...)
doubles (x:xs) = (...)
-- doubles [3,6,10] = [6,12,20] doubles :: [Integer] -> [Integer] doubles [] = [] doubles (x:xs) = 2*x : doubles xs
-- map f [x1,x2,...,xn] = [f x1,f x2,...,f cn]
map f [] = ...
map f (x:xs) = ...
-- map f [x1,x2,...,xn] = [f x1,f x2,...,f cn]
map f [] = []
map f (x:xs) = f x : map f xs
filter :: (a -> Bool) -> [a] -> [a] filter p [] = [] filter p (x:xs) | p x = x : filter p xs | otherwise = filter p xs
[2*n | n <- [10..12]]
[20,22,24]
[3*n | n<- [10..12], even n]
map (3*) (filter even [10..12])
pythag n = [(x,y,z) | x <- [1..n], y <- [x..n], z <- [y..n], x^2 + y^2 == z^2]