-
-
Save killerswan/941923 to your computer and use it in GitHub Desktop.
Purely Functional Data Structures - Chris Okasaki
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 suffixes list = | |
let rec loop l acc = | |
match l with | |
| [] -> acc | |
| hd::tl -> loop tl (acc @ [tl]) in | |
loop list [list] | |
let suffixesTR list = | |
let (@+) xs ys = List.rev_append (List.rev xs) ys in | |
let rec loop list1 acc = | |
match list1 with | |
| [] -> acc | |
| x::xs -> loop xs (acc @+ [xs]) in | |
loop list [list] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment