Subject: Re: DD: Cookbook procedure markup sample (Was: DD: Status) From: Dave Love <d.love@xxxxxxxx> Date: 02 Jul 1997 23:38:57 +0100 |
I noticed the substitute-char function. I don't know about Jade, but in a typical Scheme interpreter I wouldn't expect it to be efficient because of undue consing. For example, compare: (define (subs s old new) (list->string (map (lambda (c) (if (char=? c old) new c)) (string->list s)))) Here's a session in the SCM Scheme interpreter. Note the timings for each evaluation and amount of storage allocated (`cells'). Ignore the Scheme-specific `begin' wrapper which just avoids printing the long result. (The amount of substitution actually done doesn't matter, BTW.) `substitute-char' is from the marked-up example with the typpo corrected (`+1'). > (define s (make-string 1000 #\a)) ;Evaluation took 0 mSec (0 in gc) 12 cells work, 1034 bytes other #<unspecified> > (begin (subs s #\a #\b) #t) ;Evaluation took 10 mSec (0 in gc) 5018 cells work, 1032 bytes other #t > (begin (substitute-char s #\a #\b) #t) ;Evaluation took 180 mSec (60 in gc) 10027 cells work, 503531 bytes other #t > This example may not show the same timing ratio in Jade because you'd have to define non-built-in functions, but it's worth bearing in mind the possible effect of constructing and throwing away intermediate data structures if they're not `lazy' like node lists and there's a fair amount of them. HTH. DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: DD: Cookbook procedure markup s, Dave Love | Thread | enchanced Jade TeX backend, Sebastian Rahtz |
Re: DD: Cookbook procedure markup s, Dave Love | Date | enchanced Jade TeX backend, Sebastian Rahtz |
Month |