What language should I select in DrRacket in order to do SICP exercises?
If you're using SICP with DrRacket, Neil Van Dyke has put together an excellent software package to help with this. Alternatively, you might be able to use the "Pretty Big" language (under Legacy languages).
The best language for using DrRacket in is the "Determine language from source" option, with #lang racket at the top, but SICP programs may not work perfectly in that context.
Related
I am trying to write a source file for DrRacket that specifies one of the languages from How to Design Programs Teaching Languages (see the Racket documentation). I know I can select such a language in the DrRacket menu, but I would like to specify it using a #lang directive and have DrRacket recognize the language automatically.
I cannot find any documentation about the strings that I need to use instead of racket in the initial line
#lang racket
Where can I find the documentation on this? Or can these languages only be selected from DrRacket's menu?
You should be able to use
#lang htdp/bsl
(or htdp/bsl+, htdp/isl, htdp/isl+, or htdp/asl) but it's "not in a complete shape, yet".
I recently picked up an old book on lisp and I'm trying to learn lisp using emacs. I am using both the ielm mode and interactive-mode, but I ran into this problem of keywords not being define. I am following the book's example but sometimes I would get a
*** eval error *** Symbol's function definition is void: -the keyword-
The keywords such as: DEFINE, TIMES, DIFFERENCES, ADD1, ect would not work. While other keywords such as: SQRT, MAX, MIN, ect would work.
I am a complete beginner in emacs so I don't quit understand what is wrong.
There are several dialects of lisp, e.g. Common Lisp, Scheme, Emacs Lisp, etc.
Functions, variables or keywords that are available in one dialect may not be in another one.
As Rainer said, the dialect from your book is probably not in use anymore and you shouldn't learn it. Pick a more recent one and buy a book or find documentation online. If you are new to Lisp, it is probably a good idea to start with Scheme which is a major dialect of Lisp and it relatively simple.
Last thing: Emacs is an editor, you can use it to program in any Lisp dialect. Now, Emacs itself is (mainly) written in Emacs Lisp which is a Lisp dialect that was specially designed for Emacs. It is only useful to know it if you want to modify or customize Emacs.
Your book is probably very old and uses a Lisp dialect which no longer is in use.
You may want to get a slightly newer version of that book.
See: http://people.csail.mit.edu/phw/Books/#AI for old Common Lisp (from the 80s) code for the book.
You'd probably be better of with a book discussing Emacs Lisp (one is bundled with Emacs itself, type C-h i m Emacs Intro RET to access it).
Btw, this books looks ancient and I guess it describes a non-standard Lisp dialect. Consider reading something like Practical Common Lisp or Structure and Interpretation of Computer Programs instead.
I have recently started following the examples from The Little Schemer and when trying out the examples in DrScheme, I have realised that there are some minor syntax changes from the examples in the book to what I can write in DrScheme.
First of all, as a language in DrScheme, I chose Pretty Big (one of the Legacy Languages).
Is this the correct choice for trying the examples in the book?
As regards the syntax changes I have noticed that, for example, I need to prefix the identifiers with a ' in order for them to work.
For example:
(rember 'jelly '(peanut butter jelly))
Are there any more changes (syntactical or not) that I need to be aware of when trying the examples from the 'The Little Schemer' book ?
IIRC, the book uses a different font for quoted pieces of data, and in real Scheme code that requires using quote. As for your use of PLT Scheme -- the "Pretty Big" language is really there just as a legacy language. You should use the Module language, and have all files start with #lang scheme (which should be there by default).
(The "new" way of using different languages in DrScheme is to always be in the Module "language" and specify the actual language using a #lang line.)
See the "Guidelines for the reader" section in the Preface. (I'm looking at the 4th edition here.)
I recently downloaded PLT Scheme and DrScheme. When I open DrScheme, I am told to choose a language. However, I'm not familiar with any of my options, and the help guides don't really break it down to help me easily choose which choice.
So, first - is DrScheme and PLT Scheme really the tools I need to learn Lisp and/or Scheme? If so, what are the different languages and which one(s) should I be using?
Just go for "Pretty Big". That will be all you need until you know what the rest are for. I find that R5RS is good, but it does lack the extensions that PLT has added to DrScheme.
edit: I just checked and I guess that both "Pretty Big" and "R5RS" are considered "legacy" in DrScheme 4 and the "Module" language is favored instead. Just make sure that all the files you use with the Module language start with
#lang scheme
Module is a way to specify the language used in the source file rather than globally by the DrScheme interpreter. This means that you can use different languages for different parts of your program by breaking it up into files and indicating in each file the language you're using. If you're just starting out, all you need to worry about is just keeping #lang scheme at the top of all the files you use.
A small note - this declaration is not official Scheme, and needs to be removed if you attempt to use the files in another Scheme interpreter.
Standard (R5RS) is the actual thing so that would be your best bet
i learnt it from http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/
used MIT Scheme while doing that
but otherwise i find plt a lot nicer to work with
I've been wanting to teach myself Lisp for a while. However, all the interpreters of which I've heard involve some flavor of emacs.
Are there any command line interpreters, such that I could type this into the command line:
lispinterpret sourcefile.lisp
just like I can run perl or python.
While I'd also like to become more familiar with Emacs (if only not to be frustrated when I work with somebody who uses Emacs), I'd rather decouple learning Emacs from learning Lisp.
Edit: I actually want to follow SICP which uses Scheme, so an answer about Scheme would be more useful. I'm just not that familiar with the differences.
You could also try DrScheme, which whilst not exactly a standalone interpreter, isn't emacs :)
It's basically a simple IDE that has an area to type in code that can be executed as a file, and then another area that is the running interpreter that you can interact with.
(Also, find the UC Berkeley CS61A podcasts and listen to them, as well as reading SICP)
It looks like Steel Bank Common Lisp (SBCL) also caters to what you want:
http://www.sbcl.org/manual/#Shebang-Scripts
SBCL is both top rate and open source.
Checkout CLISP wiki-link that ie. was used by Paul Graham
Direct link
I often write lisp shell scripts which start with this line:
#!/usr/bin/clisp
Then you don't even need to type "lispinterpret" on the command-line. Just mark the script executable and run it directly.
Most scheme interpreters that I am familiar with can be run from the command line. (Much of the list below is extracted from the comparative table at Alexey Radul's Scheme Implementation Choices page. There is a more extensive list at schemewiki but that page does not immediately provide command-line invocation syntax.)
Here's how you run a number of implementations at the command line:
Chez Scheme: scheme, petite
MIT Scheme: mit-scheme
Scheme 48: scheme48
RScheme: rs
Racket: racket (But I recommend trying the DrRacket IDE, especially for beginners.)
Guile: guile
Bigloo: bigloo
Chicken: csi
Gambit: gsi
Gauche: gosh
IronScheme: IronScheme.Console
Kawa: kawa, java kawa.repl
Larceny: larceny
SCM: scm
If you are looking for Scheme to work with the SICP, take a look at MIT/GNU Scheme
http://groups.csail.mit.edu/mac/projects/scheme/
http://www.gnu.org/software/mit-scheme/index.html
The most widely used IDE for Common Lisp, particularly in the free software subset of the community, is in fact SLIME, which runs on Emacs. You can use whatever CL compiler you prefer and invoke Lisp source files the way you describe, but if you do that, you won't be taking advantage of many of Lisps dynamic features that are so incredibly useful while developing your application.
I suggest you take a look at this SLIME demonstration video to see what I mean, even though it might be a bit outdated at this point.
If the problem is that you (think you) don't like Emacs, I seriously suggest you try to learn it. Seriously. No, really, I mean that. However, there are alternatives, such as the IDEs provided by commercial Lisp implementations such as Allegro and Lispworks (free trials available), or an Eclipse plug-in called Cusp.
Did you try Allegro CL from http://www.franz.com/?
#Nathan: I've upmodded the Common Lisp links, because you asked about Lisp (especially with reference to Emacs Lisp). However, Common Lisp is very different from Scheme. A program written for one is unlikely to run on the other.
As you mentioned, SICP is for learning Scheme, not Lisp (or at least, not Common Lisp and not Emacs Lisp). There are some overlap in principles, however you can't simply cut and paste code from SICP and expect it to run on any Common Lisp or Emacs Lisp system. :-)
No "interpreter" requires emacs.
Also, emacs can run elisp in a headless manner.
It seems like scheme shell is suitable for your purpose.
Take a look at http://www.scsh.net/index.html
Another good dialect of lisp is cmucl. They used to love to brag about being the "fastest" lisp.