Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Playing-cards/Zkl/playing-cards-1.zkl
Normal file
25
Task/Playing-cards/Zkl/playing-cards-1.zkl
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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"); }
|
||||
}
|
||||
4
Task/Playing-cards/Zkl/playing-cards-2.zkl
Normal file
4
Task/Playing-cards/Zkl/playing-cards-2.zkl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
d:=Deck();
|
||||
d.println(d.deck.len());
|
||||
d.deal().println();
|
||||
d.println();
|
||||
Loading…
Add table
Add a link
Reference in a new issue