Playing cards: Difference between revisions

Updated D entry
(→‎{{header|Go}}: Redo the Go solution as a reusable package with a slightly different API.)
(Updated D entry)
Line 739:
alias Card = Tuple!(Pip, Suit);
 
Card[]auto newDeck() /*pure nothrow*/ @safe @nogc {
return cartesianProduct([EnumMembers!Pip], [EnumMembers!Suit]);
.array;
}
 
alias shuffleDeck = randomShuffle;
 
Card dealCard(ref Card[] deck) pure nothrow @safe @nogc {
immutable card = deck.back;
deck.popBack;
Line 757 ⟶ 756:
 
void main() {
auto d = newDeck.array;
d.show;
d.shuffleDeck;