Press CTRL+C or CMD+C to copy the selected text and close this dialog.
Tweet
0 people like it. Like the snippet!
Find the last but one (last and penultimate) elements of a list. (easy)
1: 2: 3: 4: 5: 6: 7: 8:
let rec last2 = function | nl :: l :: [] -> Some ( nl , l ) | h :: t -> last2 t | [] -> None last2 [ "a" ; "b" ; "c" ; "d" ] last2 [ "a" ] last2 ([ ] : int list)