Browse files

internalize-argument passing

  • Loading branch information...
1 parent a8516c0 commit 18162c932e7ef8f93087ef0540bfe6549ec91f43 @ih committed Apr 4, 2011
Showing with 11 additions and 7 deletions.
  1. +1 −1 scheme/internalize-arguments.scm
  2. +10 −6 scheme/tests/internalize-arguments-tests.scm
View
2 scheme/internalize-arguments.scm
@@ -1,5 +1,5 @@
(library (internalize-arguments)
- (export internalize-arguments has-arguments? find-variable-instances thunkify make-mixture-sexpr remove-abstraction-variable remove-ith-argument remove-application-argument)
+ (export internalize-arguments has-arguments? find-variable-instances thunkify make-mixture-sexpr remove-abstraction-variable remove-ith-argument remove-application-argument internalize-argument)
(import (except (rnrs) string-hash string-ci-hash)
(abstract)
(_srfi :1)
View
16 scheme/tests/internalize-arguments-tests.scm
@@ -26,12 +26,16 @@
;;;change-applications
(let* ([new-abstraction (make-named-abstraction 'F1 '(let ([V1 ((uniform-draw (list (lambda () (F1 1)) (lambda () 1))))]) (node V1)) '())]
[program (make-program (list new-abstraction) '(F1 (F1 1)))]
- [old-abstraction (make-named-abstraction 'F1 '(node V1) '(V1))])
- (check (remove-application-argument program old-abstraction 'V1) => (sexpr->program '(let () (define F1 (lambda () (let ([V1 ((uniform-draw (list (lambda () (F1)) (lambda () 1))))]) (node V1)))) (F1))))
- ;; ;;;internalize-argument
- ;; (let* ([program (sexpr->program '(let () (define F1 (lambda (V1) (node V1))) (F1 (F1 1))))]
- ;; [abstraction (make-named-abstraction 'F1 '(node V1) '(V1))])
- ;; (check (internalize-argument program abstraction 'V1) => (sexpr->program '(let () (define (F1) (let ([V1 ((uniform-draw (list (lambda () (F1)) (lambda () 1))))]) (list V1)) ) (F1)))))
+ [old-abstraction (make-named-abstraction 'F1 '(node V1) '(V1))]
+ [correct-abstraction (make-named-abstraction 'F1 '(let ([V1 ((uniform-draw (list (lambda () (F1)) (lambda () 1))))]) (node V1)) '())]
+ [correct-program (make-program (list correct-abstraction) '(F1))])
+ (check (remove-application-argument program old-abstraction 'V1) => correct-program)
+;;;internalize-argument
+ (let* ([program (sexpr->program '(let () (define F1 (lambda (V1) (node V1))) (F1 (F1 1))))]
+ [abstraction (make-named-abstraction 'F1 '(node V1) '(V1))]
+ [correct-abstraction (make-named-abstraction 'F1 '(let ([V1 ((uniform-draw (list (lambda () (F1)) (lambda () 1))))]) (node V1)) '())]
+ [correct-program (make-program (list correct-abstraction) '(F1))])
+ (check (internalize-argument program abstraction 'V1) => correct-program))
;; ;;;abstraction-internalizations
;; (let* ([program (sexpr->program '(let () (define F1 (lambda (V1) (node V1))) (F1 (F1 1))))]

0 comments on commit 18162c9

Please sign in to comment.