
Greetings, For my own edification I have written a few functions for creating a tree from a list of 'associations'. An association is defined as data Assoc = Assoc { label :: String , assocId :: Int , assocPid :: Int } deriving ( Show ) where assocId is an int that uniquely identifies a node, and assocPid is the id of that node's parent. The idea is to feed an array of these associations into a function and get a Data.Tree Assoc out. So I have code that does the job ... ... but it's not very good. I thought the problem might be solved with a fold, but that proved difficult due to the Assocs not being in a suitable insertion order. Perhaps the routines can be improved such that the array order doesn't matter. Any advice, or better versions would be appreciated. thanks, Jeff PS: AssocTree.hs should be attached.
participants (1)
-
Jeff Lasslett