Skip to content

Latest commit

 

History

History
16 lines (11 loc) · 440 Bytes

README.md

File metadata and controls

16 lines (11 loc) · 440 Bytes

1st, 3rd and 5th

Write a polymorphic function that returns the first, third and fifth element of a list. Its type must be:

first_third_fifth : 'a list -> ('a * 'a * 'a) option 

If the list is not long enough, the result is None, otherwise it is a triple of values wrapped in the constructor Some.

For example:

first_third_fifth ["cat"; "dog"] = None
first_third_fifth [1; 2; 3; 4; 5; 6] = Some (1, 3, 5)