Learning Scheme (via Simply Scheme)

22 views
Skip to first unread message

Nik Luk

unread,
Sep 18, 2019, 12:41:32 PM9/18/19
to fallibl...@googlegroups.com
I am learning Scheme. I use *Simply Scheme* as a resource as of Elliot’s advice.

Simply Scheme:
https://people.eecs.berkeley.edu/~bh/ss-toc2.html

Elliot’s discussion thread on programming:
http://curi.us/2210-programming-discussion



I have no prior knowledge of programming or computer science.

I did a failed attempt at starting with *Simply Scheme* in August but ended up only reading the introduction before giving up.
I was not enough motivated and gave up on the first hurdle.

Now I am more motivated and I am dedicating 1-2 hours a day to learning Scheme.

---

My setup:

- I use a *MacBook Pro / iOS*
- I use *DrRacket* as the *Scheme interpreter*



Steps taken:

1. (Re)Read Simply Scheme up until Chapter 1, “Talking to Scheme”
2. Read Appendix A of Simply Scheme (https://people.eecs.berkeley.edu/~bh/ssch27/appendix-running.html)
2. Downloaded DrRacket (this was what was recommended for beginners here: https://stackoverflow.com/questions/2521477/what-is-the-best-scheme-interpreter-or-compiler)
3. Installed DrRacket
4. Started up DrRacket
5. File —> Package Manager … —> chose “simply-scheme” as *Package Source*
(I did step 1-5 yesterday without documenting, so I might have an error describing the process. I need to get better at documenting steps.)

6. Back to Appendix A “Turning Our Programs for Your System” to run the experiments —> run into problems

---

DrRacket displays:

> Welcome to DrRacket, version 7.4 [3m].
> Language: racket, with debugging; memory limit: 128 MB.



**Problems:**

- I can not access “ftp://anarres.cs.berkeley.edu/pub/scheme/“ (Appendix A, “Getting Our Programs”, https://people.eecs.berkeley.edu/~bh/ssch27/appendix-running.html)
- When running experiment step 2 “> (error "Your error is" "string")” (Appendix A, "Tuning Our Programs for Your System") I get “string” with quotation marks. I do not know how to or where to correct it. I am supposed to: “edit simply.scm and change the definition of error-printform to
(define (error-printform x) x)”

Alan Forrester

unread,
Sep 19, 2019, 3:21:09 AM9/19/19
to fallibl...@googlegroups.com
Have you tried looking up related terms with a search engine?

Alan

Nik Luk

unread,
Sep 19, 2019, 5:16:53 PM9/19/19
to fallibl...@googlegroups.com
I did try some searching before writing the e-mail - without success.

I did some more searching today and found what looks to be an alternative ftp address:

- ftp://anarres.cs.berkeley.edu/pub/scheme/ (original link, broken)
- ftp://ftp.cs.berkeley.edu/pub/scheme (new, working, link via http://www.hashcollision.org/simply-scheme/index.html)

I e-mailed Brian Harvey (one of the authors of Simply Scheme) about the broken link. He was not aware of it and appreciated the info.
(I would never have done stuff like this - reporting a mistake to the author - before I found FI and curi.us btw.)

The new link contains three additional programs not listed in Appendix A of Simply Scheme.



Steps taken:

- I wrote the following in the DrRacket definitions window as recommended on http://www.hashcollision.org/simply-scheme/index.html

> #lang planet dyoo/simply-scheme:2
> (se (butlast (bf "this"))
> "world”)

This did not solve my problem with experiment 2.

Appendix A of Simply Scheme says:

> In particular, the file simply.scm must be loaded into Scheme to allow anything in the book to work.

- I have tried to load the simply.scm file from the new ftp link. That gives me the following error:

> (if (equal? 'foo (symbol->string 'foo))
> (error "Simply.scm already loaded!!")
> #f)


- I have web searched for “change definition Scheme”, 'error "Your error is" “string”’, and “DrRacket change definition”
- I have found nothing helpful (at my current level of understanding)
- I have looked for a file named “simply.scm” in the installed DrRacket folder locally but have not found any such file
- I have re-read Appendix A

After adding the “#lang …” part from above I get the below error message on every relaunch of DrRacket.

- I have deleted DrRacket (with appCleaner) and reinstalled it. The error message still occurs on relaunch.

> Error in phase 2 for tool #<path:/Users/silverwolf/Library/Racket/planet/300/7.4/cache/dyoo/simply-scheme.plt/2/2/tool.rkt>; #f
>
> drracket:language-configuration:add-language: found two languages with the same result from get-language-numbers: (-500 0), ("Teaching Languages" "Simply Scheme") and ("Teaching Languages" "Simply Scheme")
> context...:
> loop
> /Applications/Racket v7.4/share/pkgs/drracket/drracket/private/language-configuration.rkt:111:4: unpack267
> .../more-scheme.rkt:261:28
> [repeats 22 more times]
> /Applications/Racket v7.4/share/pkgs/drracket/drracket/private/tools.rkt:432:0: run-phases
> .../racket/unit.rkt:996:20
> "/Applications/Racket v7.4/share/pkgs/drracket/drracket/tool-lib.rkt": [running body]
> temp37_0
> for-loop
> run-module-instance!125
> "/Applications/Racket v7.4/share/pkgs/drracket/drracket/private/drracket-normal.rkt": [running body]
> temp37_0
> for-loop
> run-module-instance!125
> "/Applications/Racket v7.4/share/pkgs/drracket/drracket/drracket.rkt": [running body]
> temp37_0
> ...




Next step:

I do not know what next step to take other than a wild guess.

Should I switch from DrRacket? I do think that *I* am the problem here, not the interpreter (DrRacket).

How should I think when I run into similar situations to not get stuck like this?

I will revisit my Scheme problems tomorrow.

Justin Mallone

unread,
Sep 22, 2019, 7:07:23 PM9/22/19
to fallibl...@googlegroups.com, brucenielson1@gmail.com [fallible-ideas]
You could try loading the scheme file here as your definitions file; it appears to be a recently updated version:

https://gist.github.com/alexgian/5b351f367169b40a4ad809f0bb718e1f

Or you could try running an older version of DrRacket (formerly DrScheme) on an older OS and see if that works better http://paleyontology.com/inst/download_install_scheme.html
(virtual machines could be useful for this kinda thing. the paleyontology DrScheme mac app crashed on current macOS but worked on an older version)

Or you could try just doing some exercises in DrRacket with the #lang planet dyoo/simply-scheme:2 declaration, despite the fact that the output doesn’t look 100% correct. Try doing stuff until you run into trouble maybe? Though I think the first link, the github link, produces more correct output than just doing the language declaration.

Like when I did

(butfirst ‘hat)

for the github link scm file i got

at

which i think is closer to the intended output. but when i did (butfirst ‘hat) just with the #lang planet dyoo/simply-scheme:2 declaration, I got

‘at

BTW when I ran the old DrScheme version i linked above in a VM of macOS Leopard, I got the at output with no apostrophe.

BTW I find Harvey’s thing about redefining error-printform very opaque. He needs to show you how to adjust the parens. Look at this, this is from the simply.scm in the paleyontology.com link from above. where are you supposed to put the parens to make it work? there’s kind of a lot going on here to keep track of for a newbie. DrRacket kept complaining when i tried to fix it and then run it. maybe you can follow up with Harvey again or i will if you don’t heh. or maybe one of the many programmers on FI can help!

> ;; Get strings in error messages to print nicely (especially "")
>
> (define whoops
> (let ((string? string?)
> (string-append string-append)
> (error error)
> (cons cons)
> (map map)
> (apply apply))
> (define (error-printform x)
> (if (string? x)
> (string-append "\"" x "\"")
> x))
> (lambda (string . args)
> (apply error (cons string (map error-printform args))))))

so i haven’t gotten (error-printform x) fixed to work the way Harvey says its supposed to yet. I wouldn’t let that particular issue stop you from continuing your learning project though. just get scheme working okay and maybe work on fine-tuning stuff as you go along and get more skill and run into problems.

-JM

Nik Luk

unread,
Sep 23, 2019, 12:59:13 PM9/23/19
to fallibl...@googlegroups.com
Thx. I ran the GitHub code and it loaded nicely. No errors. Just said

> Loading Simply Scheme…
> All done.


I still get the “string” output though.

I have tried to modify the code as instructed in Appendix A

> If the message you get doesn't include quotation marks around the word string, then do nothing. But if you do see "string" with quotation marks, edit simply.scm and change the definition of error-printform to
> (define (error-printform x) x)


I understood it as “change ‘error-printform’ —> '(define (error-printform x) x)’ “. That only gave me parens error.

It might be due to my old error that I haven’t been able to fix (the long relaunch error above).

>
> Like when I did
>
> (butfirst ‘hat)
>
> for the github link scm file i got
>
> at
>
> which i think is closer to the intended output. but when i did (butfirst ‘hat) just with the #lang planet dyoo/simply-scheme:2 declaration, I got
>
> ‘at
>
> BTW when I ran the old DrScheme version i linked above in a VM of macOS Leopard, I got the at output with no apostrophe.
>
> BTW I find Harvey’s thing about redefining error-printform very opaque. He needs to show you how to adjust the parens. Look at this, this is from the simply.scm in the paleyontology.com link from above. where are you supposed to put the parens to make it work? there’s kind of a lot going on here to keep track of for a newbie. DrRacket kept complaining when i tried to fix it and then run it. maybe you can follow up with Harvey again or i will if you don’t heh. or maybe one of the many programmers on FI can help!
>
>> ;; Get strings in error messages to print nicely (especially "")
>>
>> (define whoops
>> (let ((string? string?)
>> (string-append string-append)
>> (error error)
>> (cons cons)
>> (map map)
>> (apply apply))
>> (define (error-printform x)
>> (if (string? x)
>> (string-append "\"" x "\"")
>> x))
>> (lambda (string . args)
>> (apply error (cons string (map error-printform args))))))

Yeah, that’s still greek to me, so to speak. I was doing these steps to learn that very thing (code) :)

>
> so i haven’t gotten (error-printform x) fixed to work the way Harvey says its supposed to yet. I wouldn’t let that particular issue stop you from continuing your learning project though. just get scheme working okay and maybe work on fine-tuning stuff as you go along and get more skill and run into problems.

Thx. I’ll try to skip fixing the “” for now and see if I run into more problems or not. Most likely this will lead to more problems I guess, since they bring it up as an early test of the code.

>
> -JM


Elliot Temple

unread,
Sep 23, 2019, 2:12:09 PM9/23/19
to FIGG, FIYG
A definition starts at “(define" and ends at the matching close parenthesis.

First, try adding the new definition at the bottom of the file. This should redefine the function.

If that doesn’t work, move the new definition to be directly underneath the old one.

If that doesn’t work, change the old one from active code to a comment.

If that doesn’t work, delete the old one.

Elliot Temple
www.elliottemple.com

Nik Luk

unread,
Sep 25, 2019, 12:43:00 PM9/25/19
to fallibl...@googlegroups.com
I think I got this correct. See screenshots below.

I followed the steps as well as I understood them and post screenshots of it.

>
> First, try adding the new definition at the bottom of the file. This should redefine the function.

What I did:

https://drive.google.com/file/d/1BvcHRXbMPOHeIEk-jVRRVBWJIxgk0frM/view?usp=sharing

Error:

https://drive.google.com/file/d/12XPOmFR3J-E00keED_y1JdpCN6zlfn2P/view?usp=sharing

>
> If that doesn’t work, move the new definition to be directly underneath the old one.

What I did:

https://drive.google.com/file/d/1cy_UUYh97C4L1APrSW5BmHKw9H8rVMVt/view?usp=sharing

Error (same as previous):

https://drive.google.com/file/d/12XPOmFR3J-E00keED_y1JdpCN6zlfn2P/view?usp=sharing

>
> If that doesn’t work, change the old one from active code to a comment.

Before this I updated TextMate, hence the different colours.

What I did:

https://drive.google.com/file/d/1XIsde-ffabau_CSmwkvRLEId5gx-F4XL/view?usp=sharing

Error:

https://drive.google.com/file/d/1F5G00KJiDoBGcC6I5SZ6NbK0Bk8OZU2z/view?usp=sharing

>
> If that doesn’t work, delete the old one.

What I did:

https://drive.google.com/file/d/1_Ymq6xKklmgui4p4RKWkSA17F7U4BItV/view?usp=sharing

Error:

https://drive.google.com/file/d/12A9NOuXu1VrvrRN-xOJ1M8LZUA-fvSqE/view?usp=sharing

This is the info from Appendix A (Simply Scheme, https://people.eecs.berkeley.edu/~bh/ssch27/appendix-running.html):

https://drive.google.com/file/d/1tMU7JBB-jRvCBeQzEgqwsfMwEultMmvj/view?usp=sharing

The code I use is the one that Justin sent.

I’ll skip the step of trying to fix the “”-problem for now and hope that it doesn’t cause too much problems.

anonymous FI

unread,
Sep 25, 2019, 2:10:12 PM9/25/19
to fallibl...@googlegroups.com, FIYG
You did not get matching parentheses correct. After you do a bit of
programming in scheme, you should learn what those are, and then be able
to do this successfully.

Nik Luk

unread,
Sep 25, 2019, 2:26:37 PM9/25/19
to fallibl...@googlegroups.com
Ok. I’ll do that and revisit the instructions again once I get a feeling for Scheme. Thx.
Reply all
Reply to author
Forward
0 new messages