(30分プログラミング)Gaucheでpasteコマンド
id:mzp:20070902のと比べてみる。
#! /usr/bin/gosh (use srfi-1) (define (main args) (define files (map open-input-file (cdr args))) (let loop () (define l (map read-line files)) (unless (every eof-object? l) (print (string-join (map (lambda (x) (if (eof-object? x) "" x)) l) "\t")) (loop))))
time ./paste.scm [a-c] > /dev/null real 0m5.890s user 0m5.562s sys 0m0.326s
time ./big.paste.rb [a-c] > /dev/null real 0m16.393s user 0m13.724s sys 0m2.662s
本物
time paste [a-c] > /dev/null real 0m0.126s user 0m0.118s sys 0m0.005s