Created
April 21, 2017 21:18
-
-
Save panicz/4b61cb44ffdbe19613e19f4f2579245f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (passing-arguments arguments names final) | |
(assert (= (length arguments) (length names))) | |
(match arguments | |
(() | |
(assert (null? names)) | |
final) | |
((argument . next) | |
(let (((name . names) names)) | |
(if (compound? argument) | |
(passing-arguments next names | |
(passing argument | |
`(λ (,name) ,final))) | |
;else | |
(passing-arguments next names final)))))) | |
(define (passing expression continuation) | |
(match expression | |
(('if <condition> <then> <else>) | |
(let ((result (original-name <condition>))) | |
(passing <condition> `(λ (,result) | |
(if ,result | |
,(passing <then> continuation) | |
,(passing <else> continuation)))))) | |
((function . arguments) | |
(let ((simple-arguments (map (λ (argument) | |
(if (compound? argument) | |
(original-name argument) | |
argument)) | |
arguments))) | |
(passing-arguments arguments simple-arguments | |
`(,(passing-function function) | |
,@simple-arguments | |
,continuation)))) | |
(_ ;; value | |
`(,continuation ,expression)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment