1. Re: [If/then and sequences...]
On Wed, 30 Aug 2000, Derek wrote, among other things...
>
> Of course in Euphoria this statement doesn't make sense because its
> ambiguous at best. Does the coder what to know "is any age 12?", "does every
> age in the set = 12?", "does the entire set consist of one age and is that
> age = 12?". Mixing data types in a comparison (atoms v sequences), I
> suspect, would not normally be a common requirement. In other languages,
> these symbols (=><) are 'comparison' operators - that is they are used to
> ask questions about how one operand *compares* with another operand - Robert
> has chosen to make the same symbols mean 'comparison' operators with atoms
> and mean logical functions with sequences. In other words, in some
> situations they return a boolean result (YES/NO) and in others they return a
> sequence (of booleans - but still a sequence).
...<snip>..
> What is not obvious, unless one is aware of
> Euphoria's non-traditional use of '<=' and '>=', is that this function
> returns a sequence of booleans that map onto the original sequence to show
> which elements meet the criteria. With your example data above, this would
> return {0,0,0,0,0,0,0,0,1}. Now, if consistency were an overriding design
> criteria in Euphoria, the find() function could be used to return a sequence
> of hits! Such that find(1, IsTeenager({9,14,44,15,21,90}) would return
> {2,4} - the two(!) positions that are teenagers.
Euphoria certainly falls short when it comes to consistency.
Why, indeed, doesn't "find" find more than the first occurrence of a pattern?
If it did as you suggested, returning a sequence of "hits", that one feature
alone would have saved me a tremendous amount of work in the last program
I wrote.
Why can't you slice sequences vertically, as well as horizontally?
board = {{x, o, x},
{x, x, o},
{x o, o}}
board[2] = {x, x, o}, ....
what about board[2,5,8]?
How about extracting the NAME field from 5000 customer
files, so they can be put into a listbox?
Gotta write a loop. Where's the Euphoria sequence operator for this
common functioni, which we might call a "vertical slice"?
Come to think of it, why doesn't if = work with sequences?
sequence a,b
a = {1,2,3}
b = {1,2,3}
Even I can see right away that a _is_ equal to b!
Ok, so a = b returns {1,1,1}
"if" is smart enough to say "true / false condition must be an atom, and
Euphoria already has an "if sequence" test, so instead of returning an
error, why not just do a check for a sequence consisting of all 1's, and
act on the truth or falsity of that result?
Likewise, when a = {1,2,3} and b = {1,2,3,4} , Euphoria says "sequence
lengths are not the same" and even goes on to tell us the lengths of the
two sequences "3 !- 4" Well, DUH! why not just return FALSE?
These are just a few things that get in the way of using Euphoria,
especially for large programs.
Maybe if we discuss them here in enough depth, Rob will come out
with a new Euphoria 2001 version which implements some of the ideas.
Millennia Euphoria?
==
Regards,
Irv