PureScript Edition
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 :: forall a b c d. (a -> b -> c -> d) -> Array a -> Array b -> Array c -> Array d
For convenience, MCPrelude
defines a data Triple
with Show
instance, e.g.:
> Triple 42 "hello" 3.141
(42,"hello",3.141)
Here is example output to check your allCombs3
function.
allCombs3 Triple [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)]