Skip to content

Instantly share code, notes, and snippets.

@1995hnagamin
Created September 13, 2014 10:06
Show Gist options
  • Save 1995hnagamin/0fdf77c258da3f141d56 to your computer and use it in GitHub Desktop.
Save 1995hnagamin/0fdf77c258da3f141d56 to your computer and use it in GitHub Desktop.
部分適用(実装中)
(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 ...)))]))
@1995hnagamin
Copy link
Author

gensymとかでアブラカタブラしないといけない

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment