fork download
  1. (define fail-tag 'temp)
  2. (call/cc (lambda (top-level)
  3. (set! fail-tag top-level)))
  4.  
  5. (define (fail)
  6. (fail-tag 'failed))
  7.  
  8. (define (choose . options)
  9. (if (null? options)
  10. (fail)
  11. (call/cc (lambda (success)
  12. (let ((old-fail fail-tag))
  13. (call/cc (lambda (new-fail)
  14. (set! fail-tag new-fail)
  15. (success (car options))))
  16. (set! fail-tag old-fail)
  17. (success (apply choose (cdr options))))))))
  18.  
  19.  
  20. (let ()
  21. (display (list (choose 'a 'b 'c) (choose 1 2 3)))
  22. (fail))
  23.  
Success #stdin #stdout 0.03s 8904KB
stdin
Standard input is empty
stdout
(a 1)(a 2)(a 3)(b 1)(b 2)(b 3)(c 1)(c 2)(c 3)