From 372ce4229edbedf3cb007f4ef117058a777cedcb Mon Sep 17 00:00:00 2001 From: wes Date: Mon, 3 Jul 2017 00:42:43 -0400 Subject: [PATCH] clean up code --- suffixes.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/suffixes.hs b/suffixes.hs index 3731253..5955793 100644 --- a/suffixes.hs +++ b/suffixes.hs @@ -17,11 +17,13 @@ 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) - | otherwise = TBranch root (map compress children) +compress (TBranch root (child:[])) = + let compressed = compress child + in TBranch + (root++(getRoot compressed)) + (getChildren compressed) + +compress (TBranch root children) = TBranch root (map compress children) notEmpty [] = False notEmpty _ = True