[m-dev.] diff: Array reorganisation

Fergus Henderson fjh at cs.mu.oz.au
Thu Jul 24 17:57:08 AEST 1997


Andrew Bromage, you wrote:
> 
> The implementation of bt_array (formerly array) has been changed to use
> a slightly more efficient implementation.

It worries me seeing new code and no test cases.
So some tests for bt_array.m (and array.m, for that matter)
would be a good idea.

I have a few comments below about the new code.
But otherwise it looks fine.

> % :- module ra_list.
> % :- interface.
> 
> % :- type ra_list(T).

What's an ra_list(T) supposed to represent?

> % :- implementation.
> 
> :- type ra_list(T) --->
> 		nil
> 	;	cons(int, ra_list_bintree(T), ra_list(T)).
> 
> :- type ra_list_bintree(T) --->
> 		leaf(T)
> 	;	node(T, ra_list_bintree(T), ra_list_bintree(T)).

Does this data structure have any invariant?

> 		List = cons(1+Size1+Size2, node(X, T1, T2), Rest)

s/+/ + /g

> :- pragma inline(ra_list_update/4).
> 
> ra_list_lookup(I, List, X) :-

I suspect that that `pragma inline' is not having the desired effect.
(Ditto for one other occurrence, I think.)

> 		( I =< Size2 ->
> 			ra_list_bintree_lookup(Size2, T1, I-1, X)
> 		;
> 			ra_list_bintree_lookup(Size2, T2, I-1-Size2, X)
> 		)

s/-/ - /g

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list