List Matching first element of "many"

Updated the pattern matching for lists to show how to get head of a list when you don't care how many other elements are in the list.
This commit is contained in:
Jeff Parent 2019-04-14 01:41:21 -05:00 committed by GitHub
parent 2dde374091
commit d9b80337ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -194,7 +194,7 @@ module ListExamples =
| [] -> printfn "the list is empty"
| [first] -> printfn "the list has one element %A " first
| [first; second] -> printfn "list is %A and %A" first second
| _ -> printfn "the list has more than two elements"
| first :: _ -> printfn "the list has more than two elements, first element %A" first
listMatcher [1; 2; 3; 4]
listMatcher [1; 2]