Skip to content

Instantly share code, notes, and snippets.

@yamasushi
Created March 16, 2013 10:18
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/5175814 to your computer and use it in GitHub Desktop.
Save yamasushi/5175814 to your computer and use it in GitHub Desktop.
(use gauche.generator)
(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)
($ generator-for-each (tee-format-stderr$ "<<<~a>>>\n")
$ ($ gconcatenate $ gmap ($ x->generator $ string->list $) $)
$ gmap (tee-format-stderr$ "[[~a]]\n")
$ x->generator (cdr args) ) )
; $ gosh t3 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