Re: Comparing Sequences
Lewis Townsend wrote:
> I use '=' on sequences rather often and
> not just for graphics.
With all these warnings that lots of code would break, I decided to take an
entirely unscientific sampling of some Euphoria code. First, since you said
you use '=' on sequence "rather often", I decided to take a look at your
submissions to see what I was missing:
BALEN
FNS
LAGUI
LEWISART
LOOP
Of these, the construct occurs twice. In BALEN/GAMES.E/make_screen:
dude2 = (dude = 0)
this appears to build a mask of a bitmap. In FNS/FNS.EX/fall:
s = rand (2)
i = (((s=1) * -1) + (s=2))
which appears to intialize a sequence to random values.
Slightly emboldened, I took a look at include files that come with Euphoria:
DLL.E
FILE.E
GET.E
GRAPHICS.E
IMAGE.E
MACHINE.E
MISC.E
MOUSE.E
MSGBOX.E
SAFE.E
SORT.E
WILDCARD.E
Of these, the idom only appears in WILDCARD.E, in lower and upper. Robert
has already submitted these as an example of the '=' operation on sequences:
-- wildcard.e
global function lower(object x)
-- convert atom or sequence to lower case
return x + (x >= 'A' and x <= 'Z') * TO_LOWER
end function
global function upper(object x)
-- convert atom or sequence to upper case
return x - (x >= 'a' and x <= 'z') * TO_LOWER
end function
I agree with Robert's conclusion that code would break if he implemented my
suggestions. However, after looking through the code, I'm now even less
convinced that using '=' on sequences is a significant idiom in Euphoria.
-- David Cuny
|
Not Categorized, Please Help
|
|