Created
June 8, 2017 20:17
-
-
Save pdonadeo/c2f93594ee126f6cfd692d04f973f3a3 to your computer and use it in GitHub Desktop.
Example of reversing a list in OCaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec rev ?(acc = []) xs = | |
match xs with | |
| hd::tl -> rev ~acc:(hd::acc) tl | |
| [] -> acc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment