Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- //Functional Programming and You! 🌈
- //L6 2021
- //code from talk given in April
- let deck = [
- "Six of Swords";
- "The Empress";
- "The Hanged Man";
- "Page of Cups";
- "The Lovers";
- "Justice";
- "Three of Swords";
- "Five of Pentacles";
- "The Sun";
- "Temperance";
- "Death"
- ]
- let rec shuffle (startingDeck : string list) (tempDeck : string list) (resultDeck : string list) : string list =
- let seed = Random()
- let sdLength = startingDeck.Length
- let currentCard = seed.Next(0,tempDeck.Length)
- match resultDeck.Length = startingDeck.Length with
- | true ->
- resultDeck
- | false ->
- let newDeck = resultDeck @ [tempDeck.Item(currentCard)]
- let currentDeck = List.except [tempDeck.Item(currentCard)] tempDeck
- shuffle startingDeck tempDeck newDeck
- let addTheMoon x =
- x @ ["The Moon"]
- let newDeck = addTheMoon deck
- let shuffledDeck = shuffle deck deck []
- printfn "%A" deck
- printfn "%A" newDeck
- printfn "%A" shuffledDeck
- printfn "%A" (addTheMoon shuffledDeck)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement