thumbnail

What Does This Haskell Function Do? - Click Quiz

You are given the definitions of 10 different Haskell functions. Try to match each one with what it does.
Try the whole series here
Save time by using Keyboard Shortcuts
Quiz by akjlddkjslfsd
Rate:
Last updated: December 6, 2023
You have not attempted this quiz yet.
First submittedDecember 6, 2023
Times taken9
Average score60.0%
Report this quizReport
4:00
0
 guessed
10 remaining
The quiz is paused. You have remaining.
Scoring
You scored / = %
This beats or equals % of test takers also scored 100%
The average score is
Your high score is
Your fastest time is
Keep scrolling down for answers and more stats ...
f :: Int -> Int
f 0 = 1
f n = n * f (n-1)
f :: Int -> [Int]
f x = [y | y <- [1..x], x `mod` y == 0]
f :: String -> String
f [] = []
f (x:xs) | isUpper x = x : f xs
| otherwise = f xs
f :: [Int] -> Int
f [] = 0
f (x:xs) | even x = x + f xs
| otherwise = f xs
f :: Int -> Int
f 1 = 1
f 2 = 1
f n = f (n-1) + f (n-2)
f :: Eq a => [a] -> a -> Int
f [] _ = 0
f (x:xs) y | y == x = 1 + f xs y
| otherwise = f xs y
f :: Int -> Int -> Maybe Int
f _ 0 = Nothing
f x y = Just (x `div` y)
f :: [Int] -> Int
f [] = 0
f (x:xs) | odd x = x + f xs
| otherwise = f xs
f :: [Int] -> [Int]
f = map (*10)
f :: Int -> String
f 0 = "0"
f 1 = "1"
f n = f (n `div` 2) ++ f (n `mod` 2)
Computes all the factors of an integer
Computes any number in the Fibonacci sequence
Computes the factorial of a number
Computes the sum of all even numbers in a list of integers
Computes the sum of all odd numbers in a list of integers
Counts the number of occurrences of a value in a list
Discards all chars in a string that aren't uppercase letters
Multiplies every element in a list of integers by 10
Performs integer division, with a check for division by zero
Returns the binary representation of a number
No comments yet