Last active
August 29, 2015 14:24
-
-
Save jpfuentes2/473b7e5e9b860ee3a584 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import List | |
import Set | |
import Html exposing (text) | |
type Suit = Hearts | Spades | Clubs | Diamonds | |
type Value = Two | Three | Four | Five | Six | Seven | Eight | Nine | | |
Ten | Jack | Queen | King | Ace | |
type alias Card = (Suit, Value) | |
type alias Deck = List Card | |
suits : List Suit | |
suits = [Hearts, Spades, Clubs, Diamonds] | |
values : List Value | |
values = [Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace] | |
replicate : Int -> a -> List a | |
replicate n a = | |
if n <= 0 then [] else a :: (replicate (n-1) a) | |
-- no applicative :( | |
makeDeck : Deck | |
makeDeck = List.concatMap (\v -> List.map (\s -> (s, v)) suits) values | |
main = | |
makeDeck |> | |
List.filter (\(s,v) -> s == Hearts) |> | |
replicate 1 |> | |
toString |> | |
text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment