Press CTRL+C or CMD+C to copy the selected text and close this dialog.
Tweet
0 people like it. Like the snippet!
Write a function last : 'a list -> 'a option that returns the last element of a list.
1: 2: 3: 4: 5: 6: 7:
let rec last = function | [ h ] -> Some h | h :: t -> last t | [] -> None last [ "a" ; "b" ; "c" ; "d" ] last ([ ] : int list)