mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
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:
parent
2dde374091
commit
d9b80337ba
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user