Task

Create a data structure and the associated methods to define and manipulate a deck of   playing cards.

The deck should contain 52 unique cards.

The methods must include the ability to:

   make a new deck
   shuffle (randomize) the deck
   deal from the deck
   print the current contents of a deck 
Each card must have a pip value and a suit value which constitute the unique value of the card.

Related tasks:

 Card shuffles
 Deal cards_for_FreeCell
 War Card_Game
 Poker hand_analyser
 Go Fish


const Diamonds=1, Spades=3, Clubs=0, Hearts=2, Ace=1; // informational
var suits=T(0x1F0D1,0x1F0C1,0x1F0B1,0x1F0A1); //unicode 🃑,🃁,🂱,🂡
 
class Card{
   fcn init(pip,suit){  // or 0..51
      reg p,s;
      if(vm.numArgs==1){ s=pip/13; p=pip%13; } else { p=pip; s=suit }
      var [const] _pip=p, _suit=s;
   }
   fcn toString{
      p:=_pip + (_pip>=11);
      (suits[_suit]+p).toString(8); // int-->UTF-8
   }
}
 
class Deck{  //--> 52 shuffled Cards
   var [const] deck=L();
   fcn init{
      (0).pump(52,deck.clear().write,Card);
      shuffle();
   }
   fcn shuffle{ deck.shuffle() }
   fcn deal(cards=5){ deck.pop(0,cards); }
   fcn toString{ deck.pump(String,"toString"); }
}