Lets say i am attempting to implement some sort of poker program in f#. Firstly is this the correct use of the type system, massive newbie here.
type Suit =
| Hearts
| Diamonds
| Spades
| Clubs
type Card = {
Suit:Suit
Rank:int
}
type Hand = {
Cards:List<Card>
}
Anyway suppose i want a function to return me a randomised list of the possible holding cards. I guess there would be two functions which i would chain together, however i am having a hard time implementing them without creating a loads of objects. each of the functions in the list module will return a new list and the let keyword makes impossible to change value of the reference. what is the functional way of achieving this then. So far i have this
let generateCards = {
let ranks = [ 1..52 ]...
}
let shuffle cards = {
}
let cards = shuffle generateCards