Skip to content

Instantly share code, notes, and snippets.

@jpfuentes2
Last active August 29, 2015 14:24
Show Gist options
  • Save jpfuentes2/473b7e5e9b860ee3a584 to your computer and use it in GitHub Desktop.
Save jpfuentes2/473b7e5e9b860ee3a584 to your computer and use it in GitHub Desktop.
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