From b09cdb69fa795b0760bb6d9af276914c8e7278a1 Mon Sep 17 00:00:00 2001 From: wes Date: Mon, 3 Jul 2017 00:26:40 -0400 Subject: [PATCH] add explanation --- suffixes.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/suffixes.hs b/suffixes.hs index 41f4e80..3731253 100644 --- a/suffixes.hs +++ b/suffixes.hs @@ -4,6 +4,11 @@ import qualified Data.List as L import qualified Data.Function as F import Control.Monad +{- + - Construct a suffix tree of a given word + - See: http://www.geeksforgeeks.org/pattern-searching-set-8-suffix-tree-introduction/ + -} + data Trie = TBranch { getRoot :: String, getChildren :: [Trie] @@ -14,7 +19,8 @@ data Trie = TBranch { compress t@(TBranch root []) = t compress (TBranch root children) | length children == 1 = - let compressed = (compress $ head children) in TBranch (root++(getRoot compressed)) (getChildren compressed) + let compressed = (compress $ head children) + in TBranch (root++(getRoot compressed)) (getChildren compressed) | otherwise = TBranch root (map compress children) notEmpty [] = False