Back to Home

Browse Questions

Browse all 96 questions organized by type

Function Implementation

Write Haskell functions using higher-order functions, list comprehensions, and functional programming techniques without explicit recursion.

17 questions

Zip and Concatenate String Lists

A function f2 :: ([String], [String]) -> [String] that zips two string lists together, concatenating each pair.

Difficulty: mediumTopics: higher-order-functions, list-processing

Repeat Characters by Position

A function f3 :: String -> String that repeats each character n times, where n is its position in the string (starting at 1).

Difficulty: mediumTopics: higher-order-functions, list-processing

Count Positive Numbers Divisible by 3

A function f4 :: [Int] -> Int that returns the number of positive numbers divisible by 3.

Difficulty: easyTopics: list-comprehensions, filtering

Product of Integer Pairs

A function f5 :: [(Int, Int)] -> [Int] that takes a list of Int-pairs and returns a list of their products.

Difficulty: easyTopics: list-comprehensions, tuples

Infinite Powers of 2 (Corrected)

Create an infinite list of powers of 2: [1,2,4,8,16,..]

Difficulty: easyTopics: lazy-evaluation, infinite-lists

Partial Sums using scanl (Corrected)

Define a function partialSums :: Num a => [a] -> [a] that returns a list of partial sums using scanl.

Difficulty: mediumTopics: lazy-evaluation, scanl

Interleave Infinite Lists (Corrected)

Define a function interleave :: [a] → [a] → [a] that lazily interleaves two infinite lists.

Difficulty: hardTopics: lazy-evaluation, infinite-lists

Alternating String Letters

A function f :: (String, String) -> String generating a String from two arguments by alternating letters from each argument.

Difficulty: mediumTopics: higher-order-functions, list-processing

First Characters of Non-Empty Strings

A function f1 :: [String] -> [Char] that returns the first character of each non-empty string in a list.

Difficulty: mediumTopics: list-comprehensions, string-processing

Remove Vowels from String

A function f2 :: String -> String that removes all vowels from a string.

Difficulty: mediumTopics: list-comprehensions, string-processing

Count True Values

A function f3 :: [Bool] -> Int that counts how many True values are in a list.

Difficulty: easyTopics: list-comprehensions, filtering

Fibonacci Numbers with Scanl

Define a function fibs :: [Integer] that returns the infinite list of Fibonacci numbers using scanl.

Difficulty: hardTopics: lazy-evaluation, scanl

Powers of Number with Iterate

Define a function powersOf :: Integer -> [Integer] that returns an infinite list of powers of a given number using iterate.

Difficulty: mediumTopics: lazy-evaluation, iterate

Zip and Concatenate String Lists (Fixed)

A function f2 :: ([String], [String]) -> [String] that zips two string lists together, concatenating each pair.

Difficulty: mediumTopics: higher-order-functions, list-processing

Repeat Characters by Position (Fixed)

A function f3 :: String -> String that repeats each character n times, where n is its position in the string (starting at 1).

Difficulty: mediumTopics: higher-order-functions, list-processing

Count Positive Numbers Divisible by 3 (Corrected)

A function f4 :: [Int] -> Int that returns the number of positive numbers divisible by 3.

Difficulty: easyTopics: list-comprehensions, filtering

Product of Integer Pairs (Corrected)

A function f5 :: [(Int, Int)] -> [Int] that takes a list of Int-pairs and returns a list of their products.

Difficulty: easyTopics: list-comprehensions, tuples

Type Inference

Determine the most general types of Haskell expressions, paying attention to type classes and polymorphism.

24 questions

Empty Lists Type

What is the most general type of: [ [], [] ]

Difficulty: easyTopics: type-inference, polymorphism

Lambda with Bool Application

What is the most general type of: \x y -> (x False, y)

Difficulty: hardTopics: type-inference, lambda-expressions

Mixed Tuple Type

What is the most general type of: ([], [False])

Difficulty: mediumTopics: type-inference, tuples

List Constructor Expression

What is the most general type of: [] : []

Difficulty: mediumTopics: type-inference, list-constructors

Map with Bool List

What is the most general type of: \f -> map f [True]

Difficulty: mediumTopics: type-inference, higher-order-functions

Empty List Function

What is the most general type of: \[] -> []

Difficulty: hardTopics: type-inference, pattern-matching

Conditional Bool List

What is the most general type of: \x -> if x then [] else [x]

Difficulty: mediumTopics: type-inference, conditionals

Addition Lambda

What is the most general type of: \(x, y) -> x + y

Difficulty: easyTopics: type-inference, numeric-types

Equality Test Lambda

What is the most general type of: \x -> x == x

Difficulty: easyTopics: type-inference, equality

Map Application Lambda

What is the most general type of: \x y -> map x y

Difficulty: mediumTopics: type-inference, higher-order-functions

Empty Tuple Pair

What is the most general type of: ([], [])

Difficulty: easyTopics: type-inference, tuples

Mixed Triple

What is the most general type of: ([], [], [1])

Difficulty: mediumTopics: type-inference, tuples

Bool Tuple List

What is the most general type of: (False, 99):[]

Difficulty: mediumTopics: type-inference, list-constructors

Numeric Addition Lambda

What is the most general type of: \x y -> (x y) + 7

Difficulty: hardTopics: type-inference, function-application

Function Application List

What is the most general type of: \x y -> [x y]

Difficulty: mediumTopics: type-inference, function-application

Head Function Application

What is the most general type of: \x -> head (x 9)

Difficulty: hardTopics: type-inference, function-application

List Constructor Lambda

What is the most general type of: \x y -> x : y

Difficulty: easyTopics: type-inference, list-constructors

Function Tuple Application

What is the most general type of: \x -> (x, x 4)

Difficulty: hardTopics: type-inference, function-application

ZipWith Application

What is the most general type of: \x y -> zipWith x y y

Difficulty: hardTopics: type-inference, zipWith

List Duplication

What is the most general type of: \x -> [x, x]

Difficulty: easyTopics: type-inference, lists

Tuple Duplication

What is the most general type of: \x -> (x, x)

Difficulty: easyTopics: type-inference, tuples

Function Application to 5

What is the most general type of: \x -> (x 5)

Difficulty: mediumTopics: type-inference, function-application

List Pair

What is the most general type of: \x y -> [x, y]

Difficulty: easyTopics: type-inference, lists

Numeric Pair Operations

What is the most general type of: \x -> \y -> (x + y, x * y)

Difficulty: mediumTopics: type-inference, numeric-types

Type Construction

Construct expressions that match given type signatures, demonstrating understanding of Haskell's type system.

17 questions

Triple Bool Function

Create an expression with type: Bool -> Bool -> Bool -> [Bool]

Difficulty: mediumTopics: type-construction, function-types

Numeric Triple Function

Create an expression with type: Num a => a -> a -> a -> a

Difficulty: easyTopics: type-construction, numeric-types

Pair List Function

Create an expression with type: a -> [(a,a)]

Difficulty: mediumTopics: type-construction, tuples

Mixed Numeric Tuple

Create an expression with type: Num a, Fractional b => a -> b -> Bool -> (a, b, Bool)

Difficulty: hardTopics: type-construction, multiple-type-classes

Function Application Pair

Create an expression with type: (a -> b) -> a -> (a, b)

Difficulty: mediumTopics: type-construction, higher-order-functions

Equality Function

Create an expression with type: Eq a => a -> a -> Bool

Difficulty: easyTopics: type-construction, equality

Maximum from List

Create an expression with type: Ord a => [a] -> a

Difficulty: mediumTopics: type-construction, ordering

List Predicate Function

Create an expression with type: [a] -> (a -> Bool) -> Bool

Difficulty: mediumTopics: type-construction, higher-order-functions

Fractional Average

Create an expression with type: Fractional a => a -> a -> a

Difficulty: easyTopics: type-construction, fractional-types

Function Composition

Create an expression with type: (a -> b) -> (b -> c) -> a -> c

Difficulty: hardTopics: type-construction, function-composition

IO Bool Expression

Create an expression with type: IO Bool

Difficulty: easyTopics: type-construction, io-monad

Show to IO Expression

Create an expression with type: Show a => a -> IO ()

Difficulty: easyTopics: type-construction, show

List Map Expression

Create an expression with type: [a] -> (a -> b) -> [b]

Difficulty: mediumTopics: type-construction, higher-order-functions

Complex Constraint Expression

Create an expression with type: (Fractional a, Eq b, Num b) => (a -> b) -> b -> Bool

Difficulty: hardTopics: type-construction, multiple-constraints

Curried Addition Expression

Create an expression with type: Num a => a -> (a -> a)

Difficulty: mediumTopics: type-construction, currying

Function Pair Application

Create an expression with type: (a -> b, a) -> b

Difficulty: mediumTopics: type-construction, tuples

Boolean Logic Expression

Create an expression with type: Bool -> (Bool -> Bool) -> Bool

Difficulty: mediumTopics: type-construction, boolean-logic

Multiple Choice

Test your knowledge of Haskell concepts, syntax, and functional programming principles through multiple choice questions.

8 questions

Short Answer

Evaluate Haskell expressions and explain concepts with concise answers, covering language fundamentals and computation.

22 questions

Type Classes Definition

What is a type class in Haskell?

Difficulty: mediumTopics: type-classes, interfaces

Eq Class Requirements

What must a type implement to be an instance of the Eq class?

Difficulty: easyTopics: type-classes, equality

Bind Operator Function

What does the >>= operator do?

Difficulty: mediumTopics: monads, io-monad

File Writing in Haskell

How can you write to a file in Haskell?

Difficulty: easyTopics: io-monad, file-operations

Let Expression Evaluation

What is the result of: let x = 1 in let x = 2 in x + x

Difficulty: mediumTopics: let-expressions, variable-shadowing

List Comprehension with Take

What is the result of: take 5 [x*(x+1) | x <- [1..]]

Difficulty: mediumTopics: list-comprehensions, infinite-lists

Foldl Subtraction

What is the result of: foldl (\acc x -> acc - x) 10 [1,2,3]

Difficulty: mediumTopics: foldl, higher-order-functions

Function Composition with Head and Reverse

What is the result of: (head . reverse) [10,20,30,40]

Difficulty: easyTopics: function-composition, head

ZipWith Addition

What is the result of: zipWith (+) [1,2,3] [4,5]

Difficulty: easyTopics: zipWith, addition

All Even Predicate

What is the result of: all even [2,4,6,8]

Difficulty: easyTopics: all, predicates

List Comprehension with Guards

What is the result of: [ (x, y) | x <- [1,2], y <- [1,2], x /= y]

Difficulty: mediumTopics: list-comprehensions, guards

ZipWith String Concatenation

What is the result of: zipWith (++) ["a", "b", "c"] ["1", "2"]

Difficulty: easyTopics: zipWith, string-concatenation

Take with Iterate

What is the result of: take 3 (iterate (*2) 1)

Difficulty: mediumTopics: take, iterate

Function Composition with Not and All

What is the result of: (not . all even) [2,4,6,7]

Difficulty: mediumTopics: function-composition, not

Foldr Subtraction Result

What is the result of: foldr (-) 0 [10,8,6,4,2]

Difficulty: mediumTopics: foldr, subtraction

Map with Let Binding

What is the result of: let f x = x * 2 in map f [1,2,3]

Difficulty: easyTopics: let-expressions, map

Nested Let Expression

What is the result of: let x = 3 in x + (let x = 2 in x * x)

Difficulty: mediumTopics: let-expressions, variable-shadowing

Map Filter Chain

What is the result of: map (*2) (filter (>3) [1..6])

Difficulty: mediumTopics: map, filter

List Comprehension with Guards

What is the result of: [x | x <- [10,9..1], even x, x `mod` 3 /= 0]

Difficulty: mediumTopics: list-comprehensions, guards

Foldl String Accumulation

What is the result of: foldl (\acc x -> acc ++ show x) "" [1,2,3]

Difficulty: mediumTopics: foldl, string-concatenation

Head of Squares Comprehension

What is the result of: head [x^2 | x <- [1..], x^2 > 100]

Difficulty: mediumTopics: list-comprehensions, infinite-lists

Map Filter Even Expression

What does the following expression return: map (*2) (filter even [1..10])

Difficulty: mediumTopics: map, filter

Io Program

Write complete Haskell programs that perform input/output operations using the IO monad and file operations.

6 questions

Concept Explanation

Explain key functional programming and Haskell concepts in your own words, demonstrating deep understanding.

2 questions