Created
August 4, 2019 08:20
-
-
Save naoto-ogawa/9b95a38c1cf2f1e7c1173346c7f43d35 to your computer and use it in GitHub Desktop.
Suffix Arary (inefficient)
This file contains 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
import Data.List | |
suffixArray :: [Char] -> [Int] | |
suffixArray xs = sortBy (\x y -> compare (drop x xs) (drop y xs) ) [0..(length xs - 1)] | |
{- | |
> suffixArray "abracadabra" | |
[10,7,0,3,5,8,1,4,6,9,2] | |
> suffixArray "banana" | |
[5,3,1,0,4,2] | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment