Re: A way to do sequence slicing with variables in braces

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

John F Dutcher wrote:
> 
> 
> The manual has a paragraph on sequence slicing...I've done a lot
> of it in a short time: i.e   sequence[1..9]  etc.
> 
> Is there an acceptable format that replaces the '1' and the '9' above
> with integer variables so that a loop can be formed that increments
> the variable equivalents of '1' and '9' to pick up various 'slices'
> of 'sequence' ???

Sure. Try this ...

 integer first
 integer last
 sequence name
 sequence fname
 sequence sname

 name = "Derek Parnell"
 first = 1
 last = 5
 fname = name[first .. last]
 first = 7
 last = length(name)
 sname = name[first .. last]

 for i = 1 to length(name)-1 do
   puts(1, name[i .. i+1] & '\n')
 end for

-- 
Derek Parnell
Melbourne, Australia

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

Search



Quick Links

User menu

Not signed in.

Misc Menu