A set of challenges for jump starting your understanding of monads.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
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)]