Created
May 13, 2012 04:43
-
-
Save cryks/2681399 to your computer and use it in GitHub Desktop.
Generator を返す glob
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
(define (gglob2 patterns . opts) | |
(define (cont) | |
(let/cc outer-cont | |
(apply glob-fold patterns | |
(lambda (curr _) | |
(let/cc inner-cont | |
(set! cont inner-cont) | |
(outer-cont curr))) | |
'() opts) | |
(set! cont (lambda () (eof-object))) | |
(eof-object))) | |
(lambda () (cont))) |
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.generator) | |
(define (gglob patterns . opts) | |
(generate | |
(lambda (yield) | |
(apply glob-fold patterns | |
(lambda (curr _) (yield curr)) | |
'() opts)))) |
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.partcont) | |
(define (gglob patterns . opts) | |
(define (cont) | |
(reset | |
(apply glob-fold patterns | |
(lambda (curr _) | |
(shift k (set! cont k) curr)) | |
'() opts) | |
(set! cont (lambda () (eof-object))) | |
(eof-object))) | |
(lambda () (cont))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment