[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string vs list processing
From: |
Jorgen 'forcer' Schaefer |
Subject: |
Re: string vs list processing |
Date: |
17 Apr 2001 22:55:27 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
Martin Grabmueller <address@hidden> writes:
> If you want that to be fast, check out my SRFI-13 (string
> library) implementation, where a call to
> `reverse-string-concatenate' only costs you two traversals over
> the list, one malloc() and one memcpy() of each element string.
> I think this is as fast as you can get.
You could spare one of the traversals if you'd record the length
of the total string while building up the list. If you already
know you're going to concatenate the whole thing, this might be a
very worthwhile thing to do.
It's difficult to abstract this away into a seperate functional
data type, since this would require at least another cons for
each element.
The only sensible thing for an abstract datatype is to use
imperative style:
(define (make-string-list)
(vector '() 0))
(define (string-list-cons str slis)
(vector-set! slis 0 (cons str (vector-ref slis 0)))
(vector-set! slis 1 (+ (string-length str) (vector-ref slis 1))))
or something along these lines.
Of course, one could always just pass the length along in the
recursion. :)
Greetings,
-- jorgen
--
((email . "address@hidden") (www . "http://forcix.cx/")
(irc . "address@hidden (IRCnet)") (gpg . "1024D/028AF63C"))
- Re: SRFI-13 again [was: Re: string vs list processing], (continued)
- Re: SRFI-13 again [was: Re: string vs list processing], Marius Vollmer, 2001/04/20
- Re: SRFI-13 again [was: Re: string vs list processing], Martin Grabmueller, 2001/04/23
- Re: SRFI-13 again [was: Re: string vs list processing], Marius Vollmer, 2001/04/24
- Re: SRFI-13 again [was: Re: string vs list processing], Martin Grabmueller, 2001/04/25
- Re: SRFI-13 again [was: Re: string vs list processing], Marius Vollmer, 2001/04/30
- Re: SRFI-13 again [was: Re: string vs list processing], Rob Browning, 2001/04/20
- Re: SRFI-13 again [was: Re: string vs list processing], Per Bothner, 2001/04/19
- Re: SRFI-13 again [was: Re: string vs list processing], Martin Grabmueller, 2001/04/19
- Re: SRFI-13 again [was: Re: string vs list processing], Per Bothner, 2001/04/19
- Re: string vs list processing, Martin Grabmueller, 2001/04/17
- Re: string vs list processing,
Jorgen 'forcer' Schaefer <=
- Re: string vs list processing, Martin Grabmueller, 2001/04/18
- Re: string vs list processing, Neil Jerram, 2001/04/17
- Re: string vs list processing, Marius Vollmer, 2001/04/16