Skip to content

Instantly share code, notes, and snippets.

@killerswan
Forked from mneedham/gist:941867
Created April 26, 2011 10:53
Show Gist options
  • Save killerswan/942108 to your computer and use it in GitHub Desktop.
Save killerswan/942108 to your computer and use it in GitHub Desktop.
Purely Functional Data Structures - Chris Okasaki
(* Brian McNamara's approach isn't actually that bad, unless List had an efficient append. But simplify it like so... *)
let suffixesTR3 list =
let rec loop l acc =
match l with
| [] -> acc
| _::xs -> loop xs (xs :: acc) in
List.rev (loop list [list])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment