Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Ex2.6 Solution - Markdown #1

Open
pritesh-shrivastava opened this issue Jul 24, 2020 · 2 comments · May be fixed by #34
Open

Error in Ex2.6 Solution - Markdown #1

pritesh-shrivastava opened this issue Jul 24, 2020 · 2 comments · May be fixed by #34

Comments

@pritesh-shrivastava
Copy link

You gave the following solution :
(define one (lambda (f) (lambda (x) (f (f x)))))

But this is infact 2 in Church numerals.
You can check the correct solution from the cummunity-scheme-wiki : http://community.schemewiki.org/?sicp-ex-2.6

@sgignoux
Copy link
Owner

sgignoux commented Sep 7, 2020

Hi @pritesh-shrivastava Thanks for pointing this out! I look into it soon.

@ZeliTheZealot
Copy link

ZeliTheZealot commented Dec 7, 2023

I agree with @pritesh-shrivastava . I've tried twice and got the same answer (see below). Besides, this source agrees with us.

(define zero (lambda (f) (lambda (x) x))); a constant function, independent of f
(define (add-1 n) (lambda (f) (lambda (x) (f ((n f) x)))))

Define one directly:

(add-1 zero); proceed by substitution
(lambda (f) (lambda (x) (f ((zero f) x)))); zero will take f as argument
(lambda (f) (lambda (x) (f ((lambda (f) (lambda (x) x) f) x)))); (substituting)
(lambda (f) (lambda (x) (f ((lambda (x) x) x)))); zero returned (lambda (x) x)
(lambda (f) (lambda (x) (f x))); (lambda (x) x) is the identity function

@frankplow frankplow linked a pull request Jun 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants