Created
March 16, 2013 10:15
-
-
Save yamasushi/5175809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use util.stream) | |
(define (tee$ outfn) | |
(^ arg | |
(apply outfn arg) ;; xを分岐出力 | |
(apply values arg) ;; xをそのまま返す | |
)) | |
(define (tee-format-stderr$ fmt) | |
(tee$ ($ format (standard-error-port) fmt $) ) ) | |
(define (main args) | |
($ stream-for-each (tee-format-stderr$ "<<<~a>>>\n") | |
$ ($ stream-concatenate $ stream-map ($ list->stream $ string->list $) $) | |
$ stream-map (tee-format-stderr$ "[[~a]]\n") | |
$ list->stream (cdr args) ) ) | |
; $ gosh t2 123 456 789 ABC DEF | |
; [[123]] | |
; <<<1>>> | |
; <<<2>>> | |
; <<<3>>> | |
; [[456]] | |
; <<<4>>> | |
; <<<5>>> | |
; <<<6>>> | |
; [[789]] | |
; <<<7>>> | |
; <<<8>>> | |
; <<<9>>> | |
; [[ABC]] | |
; <<<A>>> | |
; <<<B>>> | |
; <<<C>>> | |
; [[DEF]] | |
; <<<D>>> | |
; <<<E>>> | |
; <<<F>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment