[Aldor-l] Set

Ralf Hemmecke ralf at hemmecke.de
Thu Oct 5 01:19:54 EDT 2006


Hello,

Is there an argument against providing two functions

set(l: List T): %    == per l;
coerce(x: %): List T == rep x;

directly in the Set implementation of libaldor?

I agree that the function 'set' is potentially dangerous, so maybe it 
should be called 'set!' to indicate that the programmer should be 
careful to provide only lists without duplicate elements as arguments to 
the function.

I'd like to avoid needless copying of data for cases where I know from 
some other sources that the input list cannot have duplicate elements.

Currently, in

a: List L := [1,2,3];
s: Set  L := [l for l in a];
b: List L := [l for l in s];

a and b are not equal, though a = reverse b. Unfortunately, it is 
nowhere written in the specification that the latter would always be 
true, so I cannot use it. And a=b would be better anyway, since for some 
reason, I would like to preserve the order of elements while passing 
through Set.

Ralf



More information about the Aldor-l mailing list