callcc - scheme: how to use call/cc for backtracking -
In the last few days I am playing with continuity in the plan (especially cheating) and I am a little disappointed. The result is that there are some functions and were wondering if someone could explain what is happening here. For example, if the next 3 tokens "A", "If you have a token in
(get-token)
is a function that will retrieve the next, "A" is called back for the first time, "B", and "C", calling (torque-token) for the first time, the second time is called "B", and for the third time it is called "c".
What do I want to do / function (Peak-token)
which calls (get-token)
, return the token, and Then return to a state before calling the (get-token)
function. I have tried many different ways to achieve this result, and currently I have one:
;; Writing things a bit easier (define - syntax tie / CC (syntax-rule () ((dam / CC var. Body) (call / CC (lambda (var).))))) ;; The next token to the function and then ;;;; Return to the previous state (Pick-Token) (Tie / CC Returns (let's (token (token))) (return token))
How do I understand it now, Bind / cc will save a continuation on
before return
and then execute the following block of code. Then when return
is hit again, then the program jumps back to the point where continuity was bound and the result is given as token
.
However, when I run the above mentioned task, the results are similar to the original code (get-token)
.
I am so grateful if someone can explain to me that I am wrong or tell me the best way to get the same result (I know that some people hate the call / CC way) .
To mark a mark Twain incorrectly for pieces: call / cc < / Code> Report
More specifically, call / CC
capture call state , program state not. This means that it takes information about the information where the code flow occurs if continuity is applied. It captures information on not variables, and in particular, if your join-token
sets its currency status by setting it to !
When you apply your continuity, then it is not being restored.
In fact, (expression of call / cc (lambda (k)) (get token (token)) () Kashmir token))))
to only (Received token) should behave like
;
Comments
Post a Comment