Quantcast
Channel: Comments on: Continuation kata
Viewing all articles
Browse latest Browse all 10

By: Peter

$
0
0

I apologize in advance for this not formatting correctly, but I have never left a comment before.

While working on my solution I noticed that if the solution succeeds then some record of possible backtraking continuation is left, and thus if you try to run the program again it will produce strange results. One solution I thought of was a success function that wraps the correct result, however if you define a macro (called with-fail in my solution) that wraps the call you can get this effect, as well as be able to next backtracking functions.

My macro is:

(define-syntax with-fail
(syntax-rules()
((with-fail body …)
(fluid-let ((fail (lambda (x) x)))
body …))))

and the rest of the definitions are:

(define fail (lambda (x) x))

(define in-range
(lambda (low high)
(call/cc
(lambda (outer)
(if (


Viewing all articles
Browse latest Browse all 10

Trending Articles