Created
September 13, 2014 10:06
-
-
Save 1995hnagamin/0fdf77c258da3f141d56 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 plus2 | |
(lambda (a . b) | |
(if (null? b) | |
(lambda (b) (+ a b)) | |
(apply (plus2 a) b)))) | |
(define (plus3 a . bc) | |
(if (null? bc) | |
(lambda (b . c) | |
(if (null? c) | |
(lambda (c) (+ a b c)) | |
(apply (plus3 a b) c))) | |
(apply (plus3 a) bc))) | |
;(lambdap-help funfun (a b) (+ a b)) | |
(define (funfun a . hoge) | |
(if (null? hoge) | |
(lambda (b) (+ a b)) | |
(apply (funfun a) hoge))) | |
(define funfun | |
(lambda hoge | |
(if (null? hoge) | |
(lambda (a) (print a)) | |
(apply (funfun) hoge)))) | |
;(lambdap+ funfun (a) (print a)) | |
(define-syntax lambdap+ | |
(syntax-rules () | |
[(_ name (x) body ...) | |
(lambda (x) body ...)] | |
[(_ name (x y ...) body ...) | |
(lambda (x . hoge) | |
(if (null? hoge) | |
(lambdap+ name (y ...) body ...) | |
(apply (name x) hoge)))])) | |
(define-syntax lambdap | |
(syntax-rules () | |
[(_ bind body ...) | |
((lambda (le) | |
((lambda (f) (f f)) | |
(lambda (f) | |
(le (lambda (x) ((f f) x)))))) | |
(lambda (fuga) | |
(lambdap+ fuga bind body ...)))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gensymとかでアブラカタブラしないといけない