Re: Reading a file into a "sequence"
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 18, 2004
- 557 views
Derek Parnell wrote: > > John F Dutcher wrote: > > > > You guys do a heck of a job... > > The sub routine is a nice piece of work.... > > This is returned in "ex.err" when called with the input below & > > the code lines below: > > > > "sequence lengths are not the same (4 != 0)" Actually, the error message you get is really about a problem when creating that temporary sequence I talked about earlier. The problem is caused by the '=' symbol having three distinct semantic roles in Euphoria. (1) ASSIGNMENT: To copy the value of the thing to the right of it to the thing on the left of it. (2) EQUALITY TEST: To see if the thing on the left has the same value as the thing on the right. (3) SEQUENCE OPERATION EQUALITY FUNCTION: Return a sequence such that each element reflects the result of an equality test on the respective elements in the right hand and left hand sequences. Which operation is actually performed depends on the context that the '=' symbol is found in by the interpreter. RDS has decided that role (3) is the appropriate one to use in the context of an IF statement when one of the expressions in the conditional expression is a sequence. Most of the rest of us would expect role(2) to be performed, but oh well, we can't all be right, can we. Anyhow, when Euphoria sees your "Fields = {}" it tries to perform role(3). But, in order to do that operation, the sequences on either side of the '=' symbol must be the same length. In your case, you have 'Fields' which contains four elements (fields) and '{}' which contains zero elements. Thus the error message. If however, 'Fields' had have been an empty sequence, Euphoria would have created a temporary (empty) sequence and then you would have got the error message "true/false condition must be an ATOM". -- Derek Parnell Melbourne, Australia