Skip to content

Instantly share code, notes, and snippets.

@philtomson
Created May 7, 2011 05:34
Show Gist options
  • Save philtomson/960227 to your computer and use it in GitHub Desktop.
Save philtomson/960227 to your computer and use it in GitHub Desktop.
string reverse in ocaml
let string_rev str =
let rec aux idx = match idx with
0 -> Char.escaped (str.[0])
| _ -> (Char.escaped str.[idx]) ^ (aux (idx-1)) in
aux ((String.length str)-1) ;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment