#! /bin/sh #| Hey Emacs, this is -*-scheme-*- code! #$Id$ exec mzscheme -u "$0" ${1+"$@"} |# #lang scheme ; (string->string) -> string -> string -> # (define (interact-with f in out) (with-output-to-file out #:mode 'text #:exists 'replace (λ () (with-input-from-file in (λ () (let next-line ([line (read-line)]) (cond [(eof-object? line) (void)] [else (write-string (f line)) (newline) (next-line (read-line))]))) #:mode 'text)))) ;; Text file transformation framework (define (main) (define arguments (current-command-line-arguments)) (if (= (vector-length arguments) 2) (let ([in (vector-ref arguments 0)] [out (vector-ref arguments 1)]) (interact-with my-function in out)) (error "interact-with expects exactly 2 arguments : interact-with in-file-path out-file-path\n\tProvided : " arguments))) ; (string) -> (string) (define (my-function o) o) ;; Program execution starts here ;(main)