Algorithm - 0と1を次々と返す簡単なお仕事 - scheme版
Algorithm - 0と1を次々と返す簡単なお仕事にscheme版がなかったので、やってみた。
(define (make-flipflop p) (lambda () (set! p (not p)) p)) (define flfp (make-flipflop #f))
実行。
gosh> (define (make-flipflop p) (lambda () (set! p (not p)) p)) make-flipflop gosh> (define flfp (make-flipflop #f)) flfp gosh> (flfp) #t gosh> (flfp) #f gosh> (flfp) #t gosh> (flfp) #f gosh> (flfp) #t gosh>
果たしてこれで良いのか??