Skip to content

Instantly share code, notes, and snippets.

@philtomson
Created May 7, 2011 06:55
Show Gist options
  • Save philtomson/960272 to your computer and use it in GitHub Desktop.
Save philtomson/960272 to your computer and use it in GitHub Desktop.
reverse_words in a string (OCaml)
let reverse_words str =
let slst = Str.split (Str.regexp_string " ") str in
List.fold_left (fun accum i -> accum ^ " " ^ i) " " (List.rev slst) ;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment