Here are 2 question about continuation-passing style in racket programming language:
Q1: Define and test a procedure find-cps that is a CPSed version of the following find procedure:
(define find (lambda (u s) (let ((pr (assv u s))) (if pr (find (cdr pr) s) u))))
Q2: Here is the definition of unify with its helpers. The current version uses the version of find given above. Define and test a procedure unify-cps that uses your find-cps.
(define empty-s (lambda () '())) (define unify (lambda (u v s) (cond ((eqv? u v) s) ((number? u) (cons (cons u v) s)) ((number? v) (unify v u s)) ((pair? u) (if (pair? v) (let ((s (unify (find (car u) s) (find (car v) s) s))) (if s (unify (find (cdr u) s) (find (cdr v) s) s) #f)) #f)) (else #f))))