Created
March 16, 2013 10:07
-
-
Save yamasushi/5175794 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 gauche.lazy) | |
(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) | |
($ for-each (tee-format-stderr$ "<<<~a>>>\n") | |
$ ($ lconcatenate $ lmap string->list $) | |
$ lmap (tee-format-stderr$ "[[~a]]\n") | |
$ x->lseq (cdr args) ) ) | |
; $ gosh t 123 456 789 ABC DEF | |
; [[123]] | |
; [[456]] | |
; [[789]] <----- すでに9要素分のアクセス | |
; <<<1>>> <----- ここで、最初の要素 | |
; <<<2>>> | |
; [[ABC]] | |
; <<<3>>> | |
; <<<4>>> | |
; <<<5>>> | |
; [[DEF]] | |
; <<<6>>> | |
; <<<7>>> | |
; <<<8>>> | |
; <<<9>>> | |
; <<<A>>> | |
; <<<B>>> | |
; <<<C>>> | |
; <<<D>>> | |
; <<<E>>> | |
; <<<F>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment