Skip to content

Instantly share code, notes, and snippets.

@simonmichael
Created May 25, 2009 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonmichael/117319 to your computer and use it in GitHub Desktop.
Save simonmichael/117319 to your computer and use it in GitHub Desktop.
-- | From a list of account names, select those which are direct
-- subaccounts of the given account name.
subAccountNamesFrom ∷ [AccountName] → AccountName → [AccountName]
subAccountNamesFrom accts a = filter (`isSubAccountNameOf` a) accts
accountNameTreeFrom accts =
Node "top" $ unfoldForest (λa → (a, subs a)) $ topAccountNames accts
where
subs = subAccountNamesFrom allaccts
allaccts = expandAccountNames accts
-- subs' a = subsmap ! a
-- subsmap :: Map AccountName [AccountName]
-- subsmap = Data.Map.fromList [(a, subAccountNamesFrom allaccts a) | a <- allaccts]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment