Skip to content

Instantly share code, notes, and snippets.

@yamasushi
Created March 16, 2013 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yamasushi/5175794 to your computer and use it in GitHub Desktop.
Save yamasushi/5175794 to your computer and use it in GitHub Desktop.
(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