[DGD] Comparison of mappings

Colin Ross c.ross at cantab.net
Thu Feb 19 15:50:31 CET 2004


> Felix A. Croes wrote:
> 
> This is a somewhat odd definition of equal, since it considers
> ({ 0, 0, 1 }) and ({ 1, 1, 0 }) to be the same.
> 

Ah yes, oops.  I was only thinking about arrays as sets at the
time.  So to compare two arrays, you would need to loop round the
elements then? 

> 
> Suppose that array_equal() works on arrays.  Then for mappings you
> can use,
> 
>     int map_equal(mapping map1, mapping map2)
>     {
> 	return array_equal(map_indices(map1), map_indices(map2)) &&
> 	       array_equal(map_values(map1), map_values(map2));
>     }
> 

Yup, that'd work :).  Why do I never see these things...

Thanks,

Colin
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list