Mark H Weaver skribis:
> Indeed, the implementation of 'string-join' was very bad: about O(n^2)
[...]
> Before:
>
> scheme@(guile-user)> ,time (define s (string-join (make-list 1 "test")
> "-"))
> ;; 0.998800s real time, 0.996677s run time. 0.984885s spent in GC.
> scheme@(guile-user)> ,t
Nala Ginrut writes:
> string-join is a common thing for text processing(include web develop).
> However, our powerful 'format' is not so efficient. I do think it's
> necessary to we spend some time on it.
As Mark says, format is a not very nice piece of code to read, or to
modify, so if you want
() Nala Ginrut
() Mon, 01 Apr 2013 12:00:01 +0800
(define (str* str n)
(format #f "~{~a~}" (make-list n str)))
(define (str* str n)
(string-join (make-list n str) ""))
Here's another implementation, using SRFI 13 ‘xsubstring’:
(define (str* str n)
(xsubstring str 0 (* n (stri
On Mon, 2013-04-01 at 04:36 -0400, Mark H Weaver wrote:
> Nala Ginrut writes:
>
> > I've tried to implement a function to mimic string multiply like Python:
> > "asdf" * 10
> >
> > --code
> > (define (str* str n)
> > (format #f "~{~a~}" (make-list n str)))
> >
> > or
Nala Ginrut writes:
> I've tried to implement a function to mimic string multiply like Python:
> "asdf" * 10
>
> --code
> (define (str* str n)
> (format #f "~{~a~}" (make-list n str)))
>
> or
>
> (define (str* str n)
> (string-join (make-list n str) ""))
>
On 1 April 2013 14:59, Daniel Llorens wrote:
>
> Hello,
>
>> From: Daniel Hartwig
>>
>> (define (str* str n)
>> (call-with-output-string
>>(lambda (p)
>> (let lp ((n n))
>>(unless (zero? n)
>> (display str p)
>> (lp (1- n)))
>>
>> Out of curiousity, how doe
On 1 April 2013 14:58, Nala Ginrut wrote:
> On Mon, 2013-04-01 at 13:35 +0800, Daniel Hartwig wrote:
>> 2013/4/1 Nala Ginrut :
>> > Anyway, string-join is so slowly beyond my expectation.
>>
>> Also note that ‘string-concatenate’ (less general than ‘string-join’)
>> performs better for the same ca
Hello,
> From: Daniel Hartwig
>
> 2013/4/1 Nala Ginrut :
>> I've tried to implement a function to mimic string multiply like Python:
>> "asdf" * 10
>>
>> --code
>> (define (str* str n)
>> (format #f "~{~a~}" (make-list n str)))
>>
>> or
>>
>> (define (str* str n)
On Mon, 2013-04-01 at 13:35 +0800, Daniel Hartwig wrote:
> 2013/4/1 Nala Ginrut :
> > Anyway, string-join is so slowly beyond my expectation.
>
> Also note that ‘string-concatenate’ (less general than ‘string-join’)
> performs better for the same case, you could use that directly instead
> of my p
2013/4/1 Nala Ginrut :
> Anyway, string-join is so slowly beyond my expectation.
Also note that ‘string-concatenate’ (less general than ‘string-join’)
performs better for the same case, you could use that directly instead
of my prior suggestion for similar results. Especially since you do
not des
On Mon, 2013-04-01 at 12:39 +0800, Daniel Hartwig wrote:
> 2013/4/1 Nala Ginrut :
> > I've tried to implement a function to mimic string multiply like Python:
> > "asdf" * 10
> >
> > --code
> > (define (str* str n)
> > (format #f "~{~a~}" (make-list n str)))
> >
> > or
2013/4/1 Nala Ginrut :
> I've tried to implement a function to mimic string multiply like Python:
> "asdf" * 10
>
> --code
> (define (str* str n)
> (format #f "~{~a~}" (make-list n str)))
>
> or
>
> (define (str* str n)
> (string-join (make-list n str) ""))
> ---
12 matches
Mail list logo