Last active
October 22, 2019 04:20
-
-
Save jiamo/5e21e9c1a044211fc5e3479ec7d3321b 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
#lang lazy | |
(define g | |
(lambda (f) | |
(lambda (n) | |
(if (= n 0) | |
1 | |
(* n (f (- n 1))))))) | |
(define f | |
(lambda (n) | |
(if (= n 0) | |
1 | |
(* n (f (- n 1)))))) | |
(define Y1 | |
(lambda (f) | |
(f (Y1 f)))) | |
(define (Y2 self) | |
(lambda (f) | |
(f ((self self) f)))) ;; 这里没有 f | |
(((Y2 Y2) g) 5) | |
;; self self to let | |
;; but here we are lazy lang we can just use (self self) | |
(define (Y3 self) | |
(lambda (f) | |
(let ((g (self self))) (f (g f))))) | |
;; My Mistake | |
(((Y3 Y3) g) 5) | |
;; ;; (let ((x <expr1>)) <expr2>) | |
;; ==> ((lambda (x) <expr2>) <expr1>) | |
(define (Y4 self) | |
((lambda (g) (lambda (f) (f (g f))))(self self))) | |
;; My mistake | |
(((Y4 Y4) g) 5) | |
(define Y5 (Y4 Y4)) | |
((Y5 g) 5) | |
(define Y6 | |
(let ((Y4-local (lambda (self) ((lambda (g) (lambda (f) (f (g f))))(self self))))) | |
(Y4-local Y4-local))) | |
((Y6 g) 5) | |
(define Y7 | |
(let ((h (lambda (self) ((lambda (g) (lambda (f) (f (g f))))(self self))))) | |
(h h))) | |
((Y7 g) 5) | |
(define Y8 | |
((lambda (h) (h h)) | |
(lambda (self) ((lambda (g) (lambda (f) (f (g f))))(self self))))) | |
((Y8 g) 5) | |
;;(lambda (k) (lambda (f) (lambda (g) (f (g f))) (k k))) to h | |
(define Y9 | |
((lambda (self) ((lambda (g) (lambda (f) (f (g f))))(self self))) | |
(lambda (self) ((lambda (g) (lambda (f) (f (g f))))(self self))))) | |
;; shot | |
(define Y10 | |
((lambda (h) ((lambda (g) (lambda (f) (f (g f)))) (h h))) | |
(lambda (h) ((lambda (g) (lambda (f) (f (g f)))) (h h))))) | |
;; here we can apply (h h) to (lambda (f) (f (g f))) | |
;; at the end is | |
(define Y11 | |
((lambda (h) (lambda (f) (f ((h h) f)))) | |
(lambda (h) (lambda (f) (f ((h h) f)))))) | |
;; or and we can like fact make (lambda (g) (lambda (f) (f (g f)))) as big G | |
;; because (lambda (g) (lambda (f) (f (g f)))) = G has no relation with (h h) | |
(define Y12 | |
(lambda (G) | |
((lambda (h) (G (h h))) | |
(lambda (h) (G (h h)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment