Playing cards: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: Mark incorrect. Ace & 10 omitted from pack.)
(→‎{{header|J}}: use unicode symbols rather than text)
Line 730: Line 730:


NB. Class objects
NB. Class objects
Ranks=: > ;:'Ace Two Three Four Five Six Seven Eight Nine Ten Jack Queen King'
Ranks=: _2 ]\ 7 u:' A 2 3 4 5 6 7 8 910 J Q K'
Suits=: > ;:'Spades Hearts Diamonds Clubs'
Suits=: 7 u:'♦♣♥♠'
DeckPrototype=: (] #: i.@:*/)Ranks ,&# Suits
DeckPrototype=: (] #: i.@:*/)Ranks ,&# Suits


Line 741: Line 741:
destroy=: codestroy
destroy=: codestroy


sayCards=: ({&Ranks@{., ' of ', {&Suits@{:)"1
sayCards=: ({&Ranks@{. , {&Suits@{:)"1


shuffle=: monad define
shuffle=: monad define
Line 775: Line 775:
1
1
sayCards 2 dealCards__pc 5 NB. deal two hands of five cards
sayCards 2 dealCards__pc 5 NB. deal two hands of five cards
8♥
Nine of Hearts
5♠
Three of Clubs
3♥
Seven of Clubs
J♠
Ten of Hearts
2♥
Three of Diamonds


4♣
Seven of Diamonds
8♣
Nine of Spades
7♠
King of Diamonds
6♠
Queen of Hearts
2♠
Six of Clubs
$TheDeck__pc NB. deck size has been reduced by the ten cards dealt
$TheDeck__pc NB. deck size has been reduced by the ten cards dealt
42 2
42 2