-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03PipingFunctions.fs
More file actions
28 lines (20 loc) · 803 Bytes
/
Copy path03PipingFunctions.fs
File metadata and controls
28 lines (20 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// code from https://docs.microsoft.com/en-us/learn/modules/fsharp-functions/, you should go through the tutorial
module fSharpExamples.Piping
printfn "03PipingFunctions"
// simple example of functions and piping
let myList = [4; 3; 1]
let myListLetters = ["a"; "b"; "c"]
let sort (list: int list) = List.sort list
let print (list)= List.iter(fun x-> printfn $"item {x}") list
let listSortPrint = myList |> sort |> print
// typing of int list stops this
// let listSortPrint2 = myListLetters |> sort |> print
open Cards.Shuffle
cards |> shuffle |> take 3 |> printAll
open Cards.Draw
printfn "Deck: %A Hand: %A" deckAfter handAfter
// function composition example
// let add2 a = a + 2
// let multiply3 a = a * 3
// let addAndMultiply = add2 >> multiply3
// printfn "%i" (addAndMultiply 2) // 12