FCards - Defining Cards

01. A card

To create any program we need to be able to define some values

Define values with names using the let keyword

e.g. let x = 1

Exercise:

Define the cards in a standard deck, including the four suits and the number 2 up to Ace.

We can define a a couple of simple string values likeā€¦

let Spades_2 = "Spades 2"
let Spades_3 = "Spades 3"

See an answer

let Spades_2 = "Spades 2"
let Spades_3 = "Spades 3"
let Spades_4 = "Spades 4"
let Spades_5 = "Spades 5"
let Spades_6 = "Spades 6"
let Spades_7 = "Spades 7"
let Spades_8 = "Spades 8"
let Spades_9 = "Spades 9"
let Spades_10 = "Spades 10"
let Spades_Jack = "Spades Jack"
let Spades_Queen = "Spades Queen"
let Spades_King = "Spades King"
let Spades_Ace = "Spades Ace"
let Clubs_2 = "Clubs 2"
let Clubs_3 = "Clubs 3"
let Clubs_4 = "Clubs 4"
let Clubs_5 = "Clubs 5"
let Clubs_6 = "Clubs 6"
let Clubs_7 = "Clubs 7"
let Clubs_8 = "Clubs 8"
let Clubs_9 = "Clubs 9"
let Clubs_10 = "Clubs 10"
let Clubs_Jack = "Clubs Jack"
let Clubs_Queen = "Clubs Queen"
let Clubs_King = "Clubs King"
let Clubs_Ace = "Clubs Ace"
let Diamonds_2 = "Diamonds 2"
let Diamonds_3 = "Diamonds 3"
let Diamonds_4 = "Diamonds 4"
let Diamonds_5 = "Diamonds 5"
let Diamonds_6 = "Diamonds 6"
let Diamonds_7 = "Diamonds 7"
let Diamonds_8 = "Diamonds 8"
let Diamonds_9 = "Diamonds 9"
let Diamonds_10 = "Diamonds 10"
let Diamonds_Jack = "Diamonds Jack"
let Diamonds_Queen = "Diamonds Queen"
let Diamonds_King = "Diamonds King"
let Diamonds_Ace = "Diamonds Ace"
let Hearts_2 = "Hearts 2"
let Hearts_3 = "Hearts 3"
let Hearts_4 = "Hearts 4"
let Hearts_5 = "Hearts 5"
let Hearts_6 = "Hearts 6"
let Hearts_7 = "Hearts 7"
let Hearts_8 = "Hearts 8"
let Hearts_9 = "Hearts 9"
let Hearts_10 = "Hearts 10"
let Hearts_Jack = "Hearts Jack"
let Hearts_Queen = "Hearts Queen"
let Hearts_King = "Hearts King"
let Hearts_Ace = "Hearts Ace"

Running your code

You can run any code sample fairly simply using the F# interactive tool fsi.

On your command line (assuming you have the dotnet cli installed)

  1. type dotnet fsi
  2. copy and paste the code sample into the prompt that appears
  3. and voila!

TIP: the FSI uses double semi-colons (;;) to finish and execute code. You may need to type ;; and enter after pasting to execute the code sample.

Code so far

let Spades_2 = "Spades 2"
let Spades_3 = "Spades 3"
let Spades_4 = "Spades 4"
let Spades_5 = "Spades 5"
let Spades_6 = "Spades 6"
let Spades_7 = "Spades 7"
let Spades_8 = "Spades 8"
let Spades_9 = "Spades 9"
let Spades_10 = "Spades 10"
let Spades_Jack = "Spades Jack"
let Spades_Queen = "Spades Queen"
let Spades_King = "Spades King"
let Spades_Ace = "Spades Ace"
let Clubs_2 = "Clubs 2"
let Clubs_3 = "Clubs 3"
let Clubs_4 = "Clubs 4"
let Clubs_5 = "Clubs 5"
let Clubs_6 = "Clubs 6"
let Clubs_7 = "Clubs 7"
let Clubs_8 = "Clubs 8"
let Clubs_9 = "Clubs 9"
let Clubs_10 = "Clubs 10"
let Clubs_Jack = "Clubs Jack"
let Clubs_Queen = "Clubs Queen"
let Clubs_King = "Clubs King"
let Clubs_Ace = "Clubs Ace"
let Diamonds_2 = "Diamonds 2"
let Diamonds_3 = "Diamonds 3"
let Diamonds_4 = "Diamonds 4"
let Diamonds_5 = "Diamonds 5"
let Diamonds_6 = "Diamonds 6"
let Diamonds_7 = "Diamonds 7"
let Diamonds_8 = "Diamonds 8"
let Diamonds_9 = "Diamonds 9"
let Diamonds_10 = "Diamonds 10"
let Diamonds_Jack = "Diamonds Jack"
let Diamonds_Queen = "Diamonds Queen"
let Diamonds_King = "Diamonds King"
let Diamonds_Ace = "Diamonds Ace"
let Hearts_2 = "Hearts 2"
let Hearts_3 = "Hearts 3"
let Hearts_4 = "Hearts 4"
let Hearts_5 = "Hearts 5"
let Hearts_6 = "Hearts 6"
let Hearts_7 = "Hearts 7"
let Hearts_8 = "Hearts 8"
let Hearts_9 = "Hearts 9"
let Hearts_10 = "Hearts 10"
let Hearts_Jack = "Hearts Jack"
let Hearts_Queen = "Hearts Queen"
let Hearts_King = "Hearts King"
let Hearts_Ace = "Hearts Ace"