tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,21 @@
(defrecord Card [pip suit]
Object
(toString [this] (str pip " of " suit)))
(defprotocol pDeck
(deal [this n])
(shuffle [this])
(newDeck [this])
(print [this]))
(deftype Deck [cards]
pDeck
(deal [this n] [(take n cards) (Deck. (drop n cards))])
(shuffle [this] (Deck. (shuffle cards)))
(newDeck [this] (Deck. (for [suit ["Clubs" "Hearts" "Spades" "Diamonds"]
pip ["2" "3" "4" "5" "6" "7" "8" "9" "10" "Jack" "Queen" "King" "Ace"]]
(Card. pip suit))))
(print [this] (dorun (map (comp println str) cards)) this))
(defn new-deck []
(.newDeck (Deck. nil)))