The Monad Challenges

A set of challenges for jump starting your understanding of monads.

Outline

Set 1: Random Numbers

Set 2: Failing Computations

Set 3: Combinations

Set 4: Common Abstraction

Set 5: Do Notation

This project is maintained by mightybyte

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Combinations of three things

Our allCombs function is more general but it still only lets us generate combinations of two things. Now implement an allCombs3 function that generates combinations of 3 things. Don’t try to do anything fancy yet. Just use the most straightforward approach you can think of.

allCombs3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]

Here is example output to check your function.

allCombs3 (,,) [1,2] [3,4] [5,6] == [(1,3,5),(1,3,6),(1,4,5),(1,4,6),(2,3,5),(2,3,6),(2,4,5),(2,4,6)]

Previous Page - Next Page