From 1a491e883ac2d29a444e25d9f85c32722bbccff9 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 29 May 2009 10:06:50 +0000 Subject: [PATCH] more accountNameTreeFrom optimisation experiments, included for easier collaboration --- Ledger/AccountName.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Ledger/AccountName.hs b/Ledger/AccountName.hs index 59eb04540..9ef2d2d95 100644 --- a/Ledger/AccountName.hs +++ b/Ledger/AccountName.hs @@ -122,11 +122,21 @@ fromPaths = foldl' mergeTrees emptyTree . map pathtree -- fromPaths' :: (Ord a) => [[a]] -> Tree a -- fromPaths' = foldl' mergeTrees' emptyTree' . map pathtree' -converttree :: [AccountName] -> Tree' AccountName -> [Tree AccountName] -converttree parents (T m) = [Node (accountNameFromComponents $ parents ++ [a]) (converttree (parents++[a]) b) | (a,b) <- M.toList m] + +-- converttree :: [AccountName] -> Tree' AccountName -> [Tree AccountName] +-- converttree parents (T m) = [Node (accountNameFromComponents $ parents ++ [a]) (converttree (parents++[a]) b) | (a,b) <- M.toList m] + +-- accountNameTreeFrom4 :: [AccountName] -> Tree AccountName +-- accountNameTreeFrom4 accts = Node "top" (converttree [] $ fromPaths $ map accountNameComponents accts) + +converttree :: Tree' AccountName -> [Tree AccountName] +converttree (T m) = [Node a (converttree b) | (a,b) <- M.toList m] + +expandTreeNames :: Tree AccountName -> Tree AccountName +expandTreeNames (Node x ts) = Node x (map (treemap (\n -> accountNameFromComponents [x,n]) . expandTreeNames) ts) accountNameTreeFrom4 :: [AccountName] -> Tree AccountName -accountNameTreeFrom4 accts = Node "top" (converttree [] $ fromPaths $ map accountNameComponents accts) +accountNameTreeFrom4 = Node "top" . map expandTreeNames . converttree . fromPaths . map accountNameComponents -- | Elide an account name to fit in the specified width.