귀하의 질문에 대한 답은입니다 예:
(define (foo ...)
(call-with-current-continuation
(lambda (return)
...... ; here anywhere inside any sub-expression
...... ; you can call (return 42)
...... ; to return 42 from `foo` right away
)))
이것은 an을 설정합니다 출구 계속 함수의 본문 내부에서 결과 값을 반환 할 수 있도록합니다. 일반적인 체계 방법은 반품 양식을 마지막으로 배치하는 것입니다. 따라서 그 값은 반환됩니다.
(let forLoop ()
(when (valid-choice graph assignment c)
(hash-set! assignment u c)
(set! result (backtrack n graph assignment))
(cond
((not (eq? result #f))
result)) ; the value of `cond` form is ignored
(hash-remove! assignment u))
; the value of `when` form is ignored
(set! c (+ c 1))
(if (>= n c) ; `if` must be the last form
(forLoop) ; so that `forLoop` is tail-recursive
;; else:
return-value) ; <<------ the last form's value
) ; is returned from `let` form
;; (let forLoop ...) must be the last form in your function
;; so its value is returned from the function
)
여기에는 문제가 있습니다.
(cond (assignment-complete n assignment) (assignment) )
이 코드는 그렇습니다 ~ 아니다 전화하다 (assignment-complete n assignment)
. 오히려 변수가 있는지 확인합니다 assignment-complete
널 값이 아닌 값이 없으며 확인하지 않으면 확인 assignment
변수이지만 어쨌든 반환 된 값은 어쨌든 무시됩니다. 아마도 더 많은 괄호가 누락되었을 것입니다. else
절.