I'm working on a function that will take two six-sided dice and return every possibility of pairs in a list of tuples.
So, I'd like my program to return something like:
[(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),
(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),
(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),
(4,1),(4,2),(4,3),(4,4),(4,5),(4,6),
(5,1),(5,2),(5,3),(5,4),(5,5),(5,6),
(6,1),(6,2),(6,3),(6,4),(6,5),(6,6)]
I think my head might be in the right general area, but I'm having a little trouble executing it, since I am new to Haskell. Here's what I have:
rolls :: [(Integer, Integer)]
fstDice = [1, 2, 3, 4, 5, 6]
sndDice = [1, 2, 3, 4, 5, 6]
rolls
| zip fstDice sndDice
| drop 1 sndDice
| otherwise = rolls
I know that last part is very wrong, trust me. I was using zip
to put the two dice together, then my thought was to drop the head
off of the second dice, and repeat that process until sndDice
is empty and until all the pairs are found.
I'm not sure if this idea is wrong, or if it's just my incorrect amateur execution.
(And for the record, I know this doesn't compile! I'm not sure what to do about the error either.)