Re: Short Circuit
David Cuny writes:
> (1) The '=' comparison is worthless. You can only compare
> sequences that are
> *exactly* the same in structure, with exactly the same
> lengths, down to the
> last nested subsequence. I challange anyone to find me an
> example where this
> is actually useful, other than for performing obscure tricks
> with bitmaps.
>
> (2) Even if the behavior was useful, you *still* need to
> build a loop to
> scan through the results.
<snip>
OK, here's an example. It's not exactly what you're looking for (it uses
'<' and '>' instead of '='), but:
This function is used in some integer programming code of mine. I'm testing
to see if a solution is made up of integers. And no, I can't use integer(),
since I'm solving using numerical methods, and I have to take a tolerance in
account. Actually, the code is looking at two cases, straight integer
programming, and binary integer programming (all variables must be either 1
or 0), in which case I've set BIN to 1.
function Integer( sequence solution, integer vars)
-- solution = max/min, variable values for proposed solution, objective
function value
-- vars = number of variables
solution = solution[ 2 .. vars + 1 ]
if BIN then
solution = 1 - ( solution < TOL ) - ( solution - 1 > - TOL ) *
( solution - 1 < TOL )
else
solution = remainder(solution,1)
solution = (solution > TOL) * ( solution < 1 - TOL )
end if
return not find(1,solution)
end function
As you can see, not only was the operator very handy, but I used find() to
avoid looping through the sequence. Frankly, it was the flexibility
sequences gave me in this type of application that really sold me on Eu.
|
Not Categorized, Please Help
|
|