[REBOL] Re: How to compose a string with a specific separator
From: lmecir::mbox::vol::cz at: 13-Jul-2007 17:46
Carlos Lorenz napsal(a):
> Hi ppl
>
> a: [1 2 3]
>
>> parse a [any [blk: skip (unless empty? next blk [insert next blk ","])
>> skip
>> ] ]
>>
>> == [ 1 "," 2 "," 3" ]
>>
>>
>
> Whenever I read things like that I feel like I miss a lot about the power of
> REBOL parse dialect.
>
> I=B4ll leave a suggestion to the gurus on parsing: please write some "parsing
> for dummies" tutorial. It would be of great help!
>
The above code is O(n ** 2) slow. A reasonable algorithm should be much
faster. Example:
parse a [(result: copy []) any [copy element skip (append result
element append result ",")] (clear back tail result)]
-L