Card shuffles: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Automated syntax highlighting fixup (second round - minor fixes)) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: Undo bizarre single space indent that somebody found necessary to do. Remove obsolete use v6.0;) |
||
Line 1,978: | Line 1,978: | ||
(formerly Perl 6) |
(formerly Perl 6) |
||
<syntaxhighlight lang="raku" line> |
<syntaxhighlight lang="raku" line>sub overhand ( @cards ) { |
||
use v6; |
|||
sub overhand ( @cards ) { |
|||
my @splits = roll 10, ^( @cards.elems div 5 )+1; |
my @splits = roll 10, ^( @cards.elems div 5 )+1; |
||
@cards.rotor( @splits ,:partial ).reverse.flat |
@cards.rotor( @splits ,:partial ).reverse.flat |
||
} |
|||
sub riffle ( @pile is copy ) { |
|||
my @pile2 = @pile.splice: @pile.elems div 2 ; |
my @pile2 = @pile.splice: @pile.elems div 2 ; |
||
Line 1,993: | Line 1,990: | ||
@pile2.rotor( (1 .. 3).roll(9), :partial ), |
@pile2.rotor( (1 .. 3).roll(9), :partial ), |
||
).flat |
).flat |
||
} |
|||
my @cards = ^20; |
|||
@cards.=&overhand for ^10; |
|||
say @cards; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
</syntaxhighlight> |
|||
⚫ | |||
⚫ | |||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
A little extra effort was put into the '''create''' subroutine to build any sort of deck, even a multiple deck as in canasta and samba (with/without jokers). Adding options for short decks, pinochle, schmear, six-handed '''500''', and the like would be prohibitive and muddy up the code and be distracting. |
A little extra effort was put into the '''create''' subroutine to build any sort of deck, even a multiple deck as in canasta and samba (with/without jokers). Adding options for short decks, pinochle, schmear, six-handed '''500''', and the like would be prohibitive and muddy up the code and be distracting. |