[Haskell-cafe] Array and Ix for custom Graph ADT
Daniel Fischer
daniel.is.fischer at googlemail.com
Sun Aug 14 00:59:10 CEST 2011
On Sunday 14 August 2011, 00:41:33, Mark Spezzano wrote:
> Hi Antoine,
>
> The first Int field is a unique index, beginning at 1 and increasing by
> 1 for each unique Node.
Then you could use that for indexing, assuming the Ord instance matches.
range (MyNode x _ _ _, MyNode y _ _ _) = [x .. y]
index (MyNode x _ _ _, MyNode y _ _ _) (MyNode z _ _ _)
| x <= z && z <= y = z-x
| otherwise = error ("Index out of range: " ++ show z)
etc.
> The second [Int] field is just a list of random
> numbers associated with that node.
>
> Mark
More information about the Haskell-Cafe
mailing list