Go Fish/Julia: Difference between revisions

m
link
mNo edit summary
m (link)
 
(3 intermediate revisions by 2 users not shown)
Line 1:
See [[Go_Fish]]
<lang julia>import Base.show
 
<langsyntaxhighlight lang="julia">import Base.show
 
const sorteddeck = reshape([string(r == 'T' ? "10" : r) * s for r in "23456789TJQKA", s in "♣♦♥♠"], 52)
const maxdecklen = length(sorteddeck)
 
isvaliddeck(a) = (s = Vector{UInt8}(unique(a)); (a == s && all(x -> 0 < x <= 52, s)))
Line 61 ⟶ 62:
d.cards[arr]
end
 
 
function moverank!(rnk, srcdeck, dstdeck)
Line 75:
end
crd = popfirst!(maindeck.cards)
d.cards = sort(push!(d.cards, crd))
if display
println("You drew a ", Deck([crd]))
Line 191:
end
 
gofish()</syntaxhighlight>
</lang>
4,111

edits