Card shuffles: Difference between revisions

Content added Content deleted
m (Automated syntax highlighting fixup (second round - minor fixes))
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 ) {
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;
my @cards = ^20;
@cards.=&overhand for ^10;
@cards.=&overhand for ^10;
say @cards;
say @cards;
my @cards2 = ^20;
@cards2.=&riffle for ^10;
say @cards2;
my @cards2 = ^20;
say (^20).pick(*);
@cards2.=&riffle for ^10;
</syntaxhighlight>
say @cards2;

say (^20).pick(*);</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). &nbsp; Adding options for short decks, pinochle, schmear, six-handed &nbsp; '''500''', &nbsp; 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). &nbsp; Adding options for short decks, pinochle, schmear, six-handed &nbsp; '''500''', &nbsp; and the like would be prohibitive and muddy up the code and be distracting.