ããã§ããããè°è«ããã¦ããcall/ccã使ã£ãã¸ã§ãã¬ã¼ã¿ãåå¼·ãã¦ãã«éå®ç¶ç¶ã§æ¸ãç´ãã¦ã¿ããããªããã¼ãªé¨åããªããªã£ã¦ãããªãç´ ç´ã«æ¸ããã (define (make-generator f) (let ((cont #f)) (lambda () (reset (if cont (cont #f) (f (lambda (v) (shift k (set! cont k) v)))))))) (define (fib-generator) (make-generator (lambda (yield) (let loop ((a 1) (b 1)) (yield a) (loop b (+ a b)))))) åä½ã¯ä»¥ä¸ã®ã¨ããã > (define fib (fib-generator)) > (list (fib) (fib) (fib) (fib) (fib)) (1
{{#tags}}- {{label}}
{{/tags}}