Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Tip for splitting very long string ?

From: ingo:2b1 at: 16-Apr-2002 21:28

Hi Carl, Am Die, 2002-04-16 um 13.16 schrieb Carl Read: <..>
> I tried to cut out the need for the charset in the following function > but it ends up in an infinate loop when it starts comparing an empty > string with an empty string. Can anyone think of a rule that would > override that? Be interesting to know if this would be faster than > the above. (If it worked...) > > split2: func [ > "This don't work..." > str [string!] > num [integer!] > /local blk s > ][ > blk: copy [] > parse/all str [some[ > s: (s: copy/part s num) s (insert tail blk s) > ]] > blk > ]
<..> you could do it like this: split2: func [ "This don't work... Now it does ;-)" str [string!] num [integer!] /local blk s ][ blk: copy [] parse/all str [some[ s: (s: copy/part s num insert tail blk s) num skip ]] blk ] just 'skip the right number of characters. The 'insert is in the first paren!, because otherwise the last charecters would be added if the string does not contain a multiple of num characters. Kind regards, Ingo