Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 376 Bytes

README.md

File metadata and controls

20 lines (16 loc) · 376 Bytes

Reverse a list

Write a function to reverse the the elements of a list, with the following type:

rev : 'a list -> 'a list

For example:

rev [1;2;3;4;5] ;;
- : int list = [5; 4; 3; 2; 1]

Hint: recall the operator @ that concatenates two lists:

[1;2;3] @ [4;5] 
- : int list = [1; 2; 3; 4; 5]

Bonus: make rev tail-recursive.