Skip to content

Latest commit

 

History

History

rev-list

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Reverse a list

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

val rev : 'a list -> 'a list = <fun>

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]