[Haskell-cafe] Array and Ix for custom Graph ADT

Mark Spezzano mark.spezzano at chariot.net.au
Sun Aug 14 02:18:25 CEST 2011


Solved it with your help :)

Thanks for your assistance!

Mark Spezzano

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)
> 
> etc.
> 
>> The second [Int] field is just a list of random
>> numbers associated with that node.
>> 
>> Mark
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 




More information about the Haskell-Cafe mailing list