Re: left, right? head, tail? which one?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Kat wrote:
> 
> 
> > > }}}
<eucode>
> > > sequence s
> > > s = "ABC"
> > > puts(1, s[1..30])
> > > </eucode>
{{{

> > > 
> > > That needs to err out, as it does.
> > 
> > And I agree here.
> 
> I don't. So s[4..30] don't exist, they just shouldn't be printed out.
> Otherwise,
> you haveto do:
> 
> }}}
<eucode>
> if length(s) 
>   then -- so line 5 doesn't error
>     if length(s) > 30 
>       then puts(1,s[1..30]
> (5)   else puts(1,s[1..length(s)]
>     end if
>   else puts(1,"")
> end if
> </eucode>
{{{

> 
> And i vote for left/right, AND head/tail. Whichever is provided, i'll likely
> alias it to the word i prefer for that operation.
> 
> Kat

Line 5 would not error out if you did it this way:

if length(s) > 30 then
    puts(1, s[1..30])
else puts(1, s) -- old line 5. I was going to use s[1..$] but that would
    have been redundant.
end if


And if you are unsure whether s is a sequence then wrap it with if sequence(s).

--
A complex system that works is invariably found to have evolved from a simple
system that works.
--John Gall's 15th law of Systemantics.

"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare

j.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu