CS计算机代考程序代写 fac :: Int -> Int

fac :: Int -> Int
fac 0 = 1
fac n = n * fac (n-1)

product’ :: Num a => [a] -> a
product’ [] = 1
product’ (n:ns) = n * product’ ns

fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n-2) + fib (n-1)

evens :: [a] -> [a]
evens [] = []
evens (x:xs) = x : odds xs

odds :: [a] -> [a]
odds [] = []
odds (_:xs) = evens xs

qsort :: Ord a => [a] -> [a]
qsort [] = []
qsort (x:xs) = qsort smaller ++ [x] ++ qsort larger
where
smaller = [a | a <- xs, a <= x] larger = [b | b <- xs, b > x]