El martes, 17 de febrero de 2015, 10:47:08 (UTC-6), Stefan Karpinski 
escribió:
>
> IOBuffer is what you're looking for:
>
> buf = IOBuffer()
> for i = 1:100
>     println(buf, i)
> end
> takebuf_string(buf) # => returns everything that's been written to buf.
>
> The takebuf_string function really needs a new name.
>

Could that function just be called `string`?
The current behaviour of string applied to an IOBuffer does not seem useful:

julia> i = IOBuffer()
IOBuffer(data=Uint8[...], readable=true, writable=true, seekable=true, 
append=false, size=0, maxsize=Inf, ptr=1, mark=-1)

julia> string(i)
"IOBuffer(data=Uint8[...], readable=true, writable=true, seekable=true, 
append=false, size=0, maxsize=Inf, ptr=1, mark=-1)"
 

>
> On Tue, Feb 17, 2015 at 9:06 AM, Maurice Diamantini <
> maurice.d...@gmail.com <javascript:>> wrote:
>
>> Hi,
>>
>> In Ruby, String is mutable which allows to build large strings like this:
>>     txt = ""
>>     for ...
>>         txt << "yet another line\n"
>>     end
>>     # do something with txt
>>
>> The Julia the (bad) way I use is to do:
>>     txt = ""
>>     for ...
>>         txt *=  "yet another line\n"
>>     end
>>     # do something with txt
>>
>> Which is very slow for a big string (because it build a new more and more 
>> string at each iteration).
>>
>> So is there another way to do it (in standard Julia)?
>> Or is there another type which could be used (something like a Buffer 
>> type or Array type)?
>>
>> Thank,
>> -- Maurice
>>
>
>

Reply via email to