Die antwoord op u vraag is ja:
(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
)))
Dit stel 'n uitgaan voortsetting Sodat u 'n resultaatwaarde van binne die liggaam van 'n funksie kan terugstuur. Die gewone skema -manier is om u opbrengsvorm as die laaste een te plaas, sodat die waarde daarvan teruggestuur word:
(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
)
U het ook 'n probleem hier:
(cond (assignment-complete n assignment) (assignment) )
Hierdie kode doen dit nie maak 'n oproep (assignment-complete n assignment)
. Dit kyk of dit 'n veranderlike is assignment-complete
het 'n nie-nulwaarde, en indien nie, kontroleer dit assignment
veranderlik, maar die terugbesorgde waarde daarvan word in elk geval net geïgnoreer. Miskien ontbreek nog 'n paar hakies daar, en/of 'n else
klousule.