[Haskell-cafe] Array and Ix for custom Graph ADT
mark.spezzano at chariot.net.au
Sun Aug 14 02:18:25 CEST 2011
Solved it with your help :)
Thanks for your assistance!
On 14/08/2011, at 8:29 AM, Daniel Fischer wrote:
> 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)
>> The second [Int] field is just a list of random
>> numbers associated with that node.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe