Created
April 18, 2013 18:28
-
-
Save dyoo/5415070 to your computer and use it in GitHub Desktop.
Gauss sum, using a very perverse loop. Really a test of continuation prompts.
This file contains hidden or 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
#lang racket | |
(define (f i acc) | |
(cond [(> i 0) | |
(abort-current-continuation (default-continuation-prompt-tag) | |
(lambda () | |
(f (sub1 i) (+ i acc)))) | |
(printf "You should not see this\n") | |
(/ 1 0)] | |
[else | |
acc])) | |
(define (gauss i) | |
(call-with-continuation-prompt (lambda () | |
(f i 0)))) | |
(gauss 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment