1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/usr/bin/env stack
{- stack
--nix
--resolver lts-11.15
--install-ghc
runghc
--package random
-}
{-# LANGUAGE TypeSynonymInstances #-}
{-
Problem: Create a string array containing a representation of the 52 cards in a
standard deck, and then a second array that shuffles the 52 cards.
Start with two string arrays of the cards and suits:
Cards: 2, 3, 4, 5, 6, 7, 8, 9, 10, J, K, Q, A
Suits: Clubs, Diamonds, Aces, Spades
-}
import System.Random
import Control.Monad
import Control.Applicative
data Name
= Two
| Three
| Four
| Five
| Six
| Seven
| Eight
| Nine
| Ten
| Jack
| King
| Queen
| Ace
deriving (Show, Enum, Bounded)
names :: [Name]
names = [ Two .. ]
data Suit
= Club
| Diamond
| Heart
| Spade
deriving (Show, Enum)
suits :: [Suit]
suits = [ Club .. ]
allCards :: [(Name, Suit)]
allCards = liftA2 (,) names suits
data CardsGen = CardsGen
deriving (Show)
--instance RandomGen CardsGen where
-- genRange _ = (0, cardsLength)
-- next CardsGen = stdNext (StdGen 0 cardsLength)
-- split = stdSplit (StdGen 0 cardsLength)
suffle :: [cards] -> [cards]
suffle arr = undefined
main :: IO [()]
main = do
sequence $ map (putStrLn.show) allCards
|