More probles with arrays

Zuurbier, E. - AMSXE Erik.Zuurbier@klm.nl
Tue, 22 Feb 2000 09:05:28 +0100


Pablo,

> problems. If I define the VEBTree data type like this:
> 
> :: VEBTree u = EmptyVEB u
>                    | OneVEB u u
> 	       | TwoVEB u u u
> 	       | ManyVEB u u u .{VEBTree u} (VEBTree u)
> 
> Then this dumb piece of code produces the following error message:
> 
> insertWasEmpty (ManyVEB ru f l det res) i = 
>   let
>      a = i / ru
>      w = select det (toInt a)
>      w1 = id w
>      det1 = update det (toInt a) w1
> in (ManyVEB ru f l det1 res, False)
> 
> "argument 1 of select ({})" attribute at the indicated 
> position cannot be
> coerced: {^ VEBTree a} |...
> Why it's necessary to perform this kind of coercion? Maybe 
> because the array
> isn't unique?

The array is unique, but if you check the code above, you'll see that
there are two references to det, namely in the select-statement and
in the update-statement. That is a violation of uniqueness. 

I think the beginning of the solution should be that you replace the
select-statement in your code by

(w,det`) = uselect det (toInt a)

and replace det in the update-statement by det`.

This way, each version of the array has only one reference to it,
which is required for uniqueness.

Regards Erik Zuurbier