added in another sk test

This commit is contained in:
Danny Yoo 2011-07-01 13:04:46 -04:00
parent dc441e79c8
commit 0890e81e3d
4 changed files with 42 additions and 3 deletions

View File

@ -312,10 +312,10 @@
;; foldr
;; sort
;; build-list
;; box
box
;; box-immutable
;; unbox
;; set-box!
unbox
set-box!
;; make-hash
;; make-hasheq
;; hash-set!

View File

@ -8,4 +8,5 @@
(test "hello.rkt")
(test "sk-generator.rkt")
(test "sk-generator-2.rkt")
#;(test "simple-structs.rkt")

View File

@ -0,0 +1,6 @@
"a"
"b"
"c"
1
2
3

View File

@ -0,0 +1,32 @@
#lang planet dyoo/whalesong
(define (make-gen gen)
(let ([cont (box #f)])
(lambda ()
(call/cc (lambda (caller)
(if (unbox cont)
((unbox cont) caller)
(gen (lambda (v)
(call/cc (lambda (gen-k)
(begin
(set-box! cont gen-k)
(caller v))))))))))))
(define g1 (make-gen (lambda (return)
(begin
(return "a")
(return "b")
(return "c")))))
(define g2 (make-gen (lambda (ret)
(begin
(ret 1)
(ret 2)
(ret 3)))))
(g1)
(g1)
(g1)
(g2)
(g2)
(g2)