Skip to content

Instantly share code, notes, and snippets.

@djhaskin987
Created December 18, 2013 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djhaskin987/8016110 to your computer and use it in GitHub Desktop.
Save djhaskin987/8016110 to your computer and use it in GitHub Desktop.
Chris Okasaki's "Purely Functional Data Structures", Chapter 2 Excercises
(* Excercise 2.1
* We proceed by induction.
* If 'lst' is an empty list, we simply return lst itself.
* If 'lst' is a non-empty list, we store the pointer to the tail of the list,
* plus any pointers stored by a recursive call to suffixes.
* []
*)
let rec suffixes lst =
match lst with
[] -> lst
| _ -> let tail = (List.tl lst) in
tail :: (suffixes tail);;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment