1. error?

Ok, if 
decimalcount = 1
(the debug screen says it is 1)
then shouldn't this line crash?:

   resultnum = resultnum[1..decimalcount-1] & "." & 
resultnum[decimalcount..length(resultnum)]

since it is the same as:
resultnum[1..0] 
?

Kat

new topic     » topic index » view message » categorize

2. Re: error?

--0-1993595551-1035513381=:35387


Actuall no, in Euphoria this is a perfectly valid statement.  The docs are a wee
bit hard to understand on this point, but it works out like this:
slice[ # .. (anything greater than #) ] = a sequence
slice[ # .. # ] = a sequence length 1

slice[ # .. #-1 ] = a sequence length 0

slice[ # .. (anything less than #-1) ] = error


Ok, if 
decimalcount = 1
(the debug screen says it is 1)
then shouldn't this line crash?:

resultnum = resultnum[1..decimalcount-1] & "." & 
resultnum[decimalcount..length(resultnum)]

since it is the same as:
resultnum[1..0] 
?

Kat






---------------------------------
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
--0-1993595551-1035513381=:35387
Content-Type: text/html; charset=us-ascii

<P>Actuall no, in Euphoria this is a perfectly valid statement.&nbsp; The docs
are a wee bit hard to understand on this point, but it works out like this:
<P>slice[ # .. (anything greater than #) ] = a sequence
<P>slice[ # ..&nbsp;# ] = a sequence length 1</P>
<P>slice[ # ..&nbsp;#-1 ] = a sequence length 0</P>
<P>slice[ # ..&nbsp;(anything less than #-1)&nbsp;] = error</P>
<P>&nbsp;<B><I>Kat &lt;kat at kogeijin.com&gt;</I></B> wrote:
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px
solid">============ The Euphoria Mailing List ============ <BR><BR>Ok, if
<BR>decimalcount = 1<BR>(the debug screen says it is 1)<BR>then shouldn't this
line crash?:<BR><BR>resultnum = resultnum[1..decimalcount-1] &amp; "." &amp;
<BR>resultnum[decimalcount..length(resultnum)]<BR><BR>since it is the same
as:<BR>resultnum[1..0]
<BR>?<BR><BR>Kat<BR><BR>==^================================================================<BR>This
email was sent to: EuNexus at yahoo.com<BR><BR>EASY UNSUBSCRIBE click here:
http://topica.com/u/?b1dd66.b3deX6.RXVOZXh1<BR>Or send an email to:
EUforum-unsubscribe at topica.com<BR><BR>T O P I C A -- Register now to manage
your
mail!<BR>http://www.topica.com/partner/tag02/register<BR>==^================================================================<BR></BLOCKQUOTE><p><br><hr
size=1>Do you Yahoo!?<br>
<a href="http://webhosting.yahoo.com/ ">Y! Web Hosting</a> - Let the expert host
your web site
--0-1993595551-1035513381=:35387--

new topic     » goto parent     » topic index » view message » categorize

3. Re: error?

Don Phillips <EuNexus at yahoo.com> wrote:

> Actuall no, in Euphoria this is a perfectly valid statement.  The docs
> are a wee bit hard to understand on this point,

See refman_2.htm, 2.2.6 'Slicing of Sequences':
"x[3..2] is also allowed. It evaluates to the length-0 sequence {}."

> but it works out like this:
> slice[ # .. (anything greater than #) ] = a sequence
> slice[ # .. # ] = a sequence length 1
>
> slice[ # .. #-1 ] = a sequence length 0
>
> slice[ # .. (anything less than #-1) ] = error
>
>
> Ok, if
> decimalcount = 1
> (the debug screen says it is 1)
> then shouldn't this line crash?:
>
> resultnum = resultnum[1..decimalcount-1] & "." &
> resultnum[decimalcount..length(resultnum)]
>
> since it is the same as:
> resultnum[1..0]
> ?
>
> Kat

Regards,
   Juergen

new topic     » goto parent     » topic index » view message » categorize

4. Re: error?

On  0, Kat <kat at kogeijin.com> wrote:
> 
> Ok, if 
> decimalcount = 1
> (the debug screen says it is 1)
> then shouldn't this line crash?:
> 
>    resultnum = resultnum[1..decimalcount-1] & "." & 
> resultnum[decimalcount..length(resultnum)]
> 
> since it is the same as:
> resultnum[1..0] 
> ?
> 
> Kat
> 

No.

resultnum[1..0] is the empty sequence {}

   resultnum = resultnum[1..decimalcount-1] & "." & 
resultnum[decimalcount..length(resultnum)]

is the same as

   resultnum = resultnum[1..0] & "." & 
resultnum[1..length(resultnum)]

jbrown

Linux User:190064
Linux Machine:84163


--

new topic     » goto parent     » topic index » view message » categorize

5. Re: error?

On 25 Oct 2002, at 23:32, jbrown105 at speedymail.org wrote:

> 
> On  0, Kat <kat at kogeijin.com> wrote:
> > 
> > Ok, if 
> > decimalcount = 1
> > (the debug screen says it is 1)
> > then shouldn't this line crash?:
> > 
> >    resultnum = resultnum[1..decimalcount-1] & "." & 
> > resultnum[decimalcount..length(resultnum)]
> > 
> > since it is the same as:
> > resultnum[1..0] 
> > ?
> > 
> > Kat
> > 
> 
> No.
> 
> resultnum[1..0] is the empty sequence {}

I can't help but consider that non-standard to Eu's way. It's one atom long, it 
should be one atom returned. Or since Rob doesn't want to return reversed 
sequences if we do 

s = s[length(s)..1]

then s[1..0] should crash as a reversed sequence of as a "upper index is 
less than 1" error. Reliable crashing is as important as reliable non-crashing, 
isn't it?

Kat

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu