Playing cards: Difference between revisions

Added Quackery.
(Added Quackery.)
Line 5,538:
 
The remaining cards are a Deck of 2♦ 2♠ 4♦ 4♠ 5♦ 6♦ 8♦ 8♣ j♥ j♠ q♦ a♦</pre>
 
=={{header|Quackery}}==
 
This task is the subject of the chapter Dealing With Quackery in the book The Book of Quackery, which can be found at the GitHub Quackery repository, here: [https://github.com/GordonCharlton/Quackery]. Code presented here is done so with the permission of the author (me).
 
First, a demonstration in the Quackery shell of sufficient of the code to fulfil the requirements of this task:
 
<pre>/O> newpack +jokers 3 riffles 4 players 7 deal
... say "The player's hands..." cr cr
... witheach [ echohand cr ]
... say "Cards left in the pack (the talon)..." cr cr
... echohand
...
The player's hands...
 
eight of hearts
seven of clubs
nine of hearts
two of diamonds
three of diamonds
three of hearts
seven of spades
 
low joker
ace of hearts
ace of clubs
queen of diamonds
nine of clubs
six of spades
six of diamonds
 
ten of diamonds
five of spades
jack of diamonds
two of hearts
two of clubs
five of diamonds
ten of clubs
 
ace of diamonds
ace of spades
eight of clubs
king of diamonds
four of diamonds
ten of hearts
three of clubs
 
Cards left in the pack (the talon)...
 
eight of spades
four of hearts
jack of hearts
four of clubs
nine of spades
ten of spades
two of spades
five of hearts
seven of diamonds
five of clubs
jack of clubs
eight of diamonds
six of hearts
queen of hearts
three of spades
nine of diamonds
six of clubs
queen of clubs
four of spades
seven of hearts
jack of spades
queen of spades
king of hearts
king of spades
king of clubs
high joker
</pre>
 
A listing of the code accompanying the chapter, which does the above and more:
 
<lang Quackery> [ /mod if 1+ ] is /up ( n n --> n )
 
[ [] 52 times [ i^ join ] ] is newpack ( --> [ )
 
[ -13 swap join ] is +lowjoker ( [ --> [ )
 
[ 64 join ] is +highjoker ( [ --> [ )
 
[ +lowjoker +highjoker ] is +jokers ( [ --> [ )
 
[ [ table
$ 'ace' $ 'two' $ 'three'
$ 'four' $ 'five' $ 'six'
$ 'seven' $ 'eight' $ 'nine'
$ 'ten' $ 'jack' $ 'queen'
$ 'king' ] do ] is rank ( n --> $ )
 
[ [ table
$ 'clubs' $ 'diamonds'
$ 'hearts' $ 'spades' ]
do ] is suit ( n --> $ )
 
[ dup -13 = iff
[ drop $ 'low joker' ] done
dup 64 = iff
[ drop $ 'high joker' ] done
13 /mod rank
$ ' of ' join
swap suit join ] is card ( n --> $ )
 
[ [] swap
witheach
[ card join
carriage join ] ] is hand ( [ --> $ )
 
[ card echo$ ] is echocard ( n --> )
 
[ hand echo$ ] is echohand ( [ --> )
 
[ > ] is bysuit ( n n --> b )
 
[ 13 /mod 4 * + ] is rankfirst ( n --> n )
 
[ rankfirst
swap rankfirst < ] is byrank ( n n --> b )
 
[ dup [] != while
dup size random split
swap join ] is cut ( [ --> [ )
 
[ dup [] != while
dup size 2 * 3 /up
random split
dup size dup iff
[ random split
dip swap join ]
else drop join ] is scarne ( [ --> [ )
 
[ [] nested swap of ] is players ( n --> [ )
 
[ temp put
over size * times
[ over [] = iff
[ 1 split swap join ]
else
[ swap temp share split
swap rot behead
rot join
nested join ] ]
temp release ] is dealby ( [ [ n n --> [ [ )
 
[ 1 dealby ] is deal ( [ [ n --> [ [ )
 
[ 1 swap dealby ] is dealeach ( [ [ n --> [ [ )
 
[ over size deal ] is dealall ( [ [ --> [ [ )
 
[ [] swap
[ behead 1 split
dip [ swap dip join ]
dup [] = iff
drop
else
[ nested join ]
dup [] = until ]
drop swap join ] is undeal ( [ [ --> [ )
 
[ over size over size
tuck /mod
rot over -
dip [ over 1+ swap of ]
rot swap of join
swap []
2swap
witheach
[ split unrot nested join
swap ]
unrot witheach
[ dip behead join
nested join ] ] is divvy ( [ [ --> [ [ )
 
[ newpack
4 players divvy
witheach
[ 1 split 7 split
nip join join ]
+highjoker ] is euchrepack ( --> [ )
 
[ [] swap witheach join
swap join ] is gather ( [ [ --> [ )
 
[ 2 players divvy undeal ] is faro-out ( [ --> [ )
 
[ 2 players divvy
1 split swap join undeal ] is faro-in ( [ --> [ )
 
[ unrot times
[ over i bit & iff
faro-in else faro-out ]
nip ] is faro ( [ n n --> [ )
 
[ players dealall gather ] is piles ( [ n --> [ )
 
[ players dealall
shuffle gather ] is mixpiles ( [ --> [ )
 
[ stack 5 ] is riffskill ( --> [ )
 
[ [] swap
dup size 2 /up split
2 random if swap
[ dup [] != while
behead nested
dip rot join unrot
riffskill share 1+ random
1 != if swap
again ] drop join ] is riffle ( [ --> [ )
 
[ times riffle ] is riffles ( [ n --> [ )</lang>
 
=={{header|R}}==
1,462

edits