Re: Is subscripting a slice useful

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

codepilot Gmail Account wrote:
> 
> Right now subscripting a slice is not allowed.
> I think that this code should print out {97,97,97,97}.
> 
> Daniel
> }}}
<eucode>
> constant asdf={"asdf","asdf","asdf","asdf"}
> ? asdf[1..2][1]
> </eucode>
{{{


It looks what you like to do is get the first character of each element.
This is called "vertical slicing" by some. Its like visualizing the 
original sequence as ...
 {
   { 'a', 's', 'd', 'f' },
   { 'a', 's', 'd', 'f' },
   { 'a', 's', 'd', 'f' },
   { 'a', 's', 'd', 'f' }
  }

then taking just one column.

It would be nice for some applications to be able to use fast vertical
slices, but until that day comes, doing via a function isn't so bad.

Now what would save some unnecessary variables usage would be the 
ability to slice a function return value ...

   XY = getRect(myWindow)[1..2]

the current workaround is not bad, just not optimal ...

   XY = getRect(myWindow)
   XY = XY[1..2]

-- 
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