Anonymous user
Playing cards: Difference between revisions
→version 2: changed whitespace and comments, uses simpler variable names, optimized the dealing & shuffling.
m (→{{header|Julia}}: just added a small bit of polish) |
(→version 2: changed whitespace and comments, uses simpler variable names, optimized the dealing & shuffling.) |
||
Line 3,470:
===version 2===
<lang rexx>/*REXX pgm shows
call deal 5, 4 /* ◄═════════════════════════════════ 5 cards, 4 hands*/
say; say; say right('[north]' hand.1,50)
say; say '[west]' hand.4 right('[east]' hand.2,60)
say; say right('[south]' hand.3,50)
say; say; say; say 'remainder of deck: '
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────BUILD subroutine────────────────────*/
if
else suits=
end
return _
/*──────────────────────────────────SHUFFLE subroutine──────────────────*/
do shuffler=1 for #cards /*shuffle all the cards in deck. */
_=delword(_,
end /*shuffler*/
return y
/*──────────────────────────────────DEAL subroutine─────────────────────*/
do
do player=1 for hands
hand.player=hand.player
end /*player*/
end /*
return</lang>
'''output'''
<pre>
box of
shuffled deck:
[north]
[west]
[south]
remainder of deck: 10♠ K♣ 7♠ 3♦ 5♥ 6♦ J♦ A♠ 6♠ 8♠ 10♣ 8♣ 10♥ J♠ Q♥ 2♣ 6♥ A♦ 4♦ 2♦ 8♥ 3♥ 4♣ A♣ J♣ 2♠ 5♦ 8♦ 9♦ 9♣ 9♥ 4♥
</pre>
|