RE: Sequence Slicing (Was RE: Tough ciphers?)
- Posted by Derek Parnell <ddparnell at bigpond.com> Mar 14, 2002
- 432 views
Coders often have to slice off the head of a sequence after find()ing some specific item, so that the next find() is able to locate the next occurrence of the item. Life would be SO MUCH easier if there was a findfrom() routine in which we could specify the starting index. This would eliminate a whole class of slicing operations. eg. s = "a,i,ab,am,an,as,at,abe,..." t = ',' x = findfrom(1, t, s ) while x != 0 do ... x = findfrom(x + 1, t, s) end while ------ Derek. -----Original Message----- From: Robert Craig [mailto:rds at RapidEuphoria.com] Sent: Friday, 15 March 2002 4:47 To: EUforum Subject: Re: Sequence Slicing (Was RE: Tough ciphers?) C.K. Lester writes: > Anybody got any tips, tricks, or hints about faster slicing of > sequences? > > They are of the pattern > > x = x[a+1..length(x)] > > so, I'm assigning a slice of x back to x. > Should I assign it to another variable instead? In some cases it will be faster if you assign it to itself. Given the right conditions (single reference count, fairly large slice), it will not copy anything. It will simply adjust the start and end pointers of the sequence. > What can I do to make a significant difference, if anything? Obviously you are doing this slice statement many times inside some kind of loop. You'd have to ask yourself if that's really necessary. I don't think we can help you without knowing how this fits into your overall algorithm. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com