On Mon, Dec 6, 2010 at 11:15 PM, Eli Barzilay <e...@barzilay.org> wrote:
> > One thing to keep in mind is that if you only care about replacing > occurrences in some input file, then you can avoid the overhead of > collecting the full text in memory. For example, this will read the > standard input, and replace each "~a" with a string from the list, > spitting out the new text: > > #lang racket/base > (require racket/generator) > (define get-string (generator () (for-each yield '("X" "Y" "Z")))) > (define (replace-all) > (when (regexp-match "~a" (current-input-port) 0 #f > (current-output-port)) > (display (get-string)) > (replace-all))) > (replace-all) This brings up something I noticed earlier today looking at regexp docs: regexp-replace family does not work with input-port, when the other regexp-* functions do. Are there reasons for the difference? Is it because input-port cannot be written to? But since the string & bytes variants all generate new output, that will seem to be the same for input-port source anyways. Thanks, yc
_________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users