Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understanding Self-Evaluating and Compound Expressions in Scheme: Tutorial, Slides of Computer Programming

An introduction to a thumbtack jump game and emacs tutorial. The thumbtack jump game involves arranging thumbtacks on a board and jumping them according to certain rules to leave only one thumbtack in the center. The emacs tutorial covers the basics of scheme programming, including self-evaluating expressions (numbers, booleans, and strings) and compound expressions (combinations and special forms). Students will learn about the evaluator, symbol table, and name/value table, as well as simple and compound expressions. Useful for university students studying computer science or programming.

Typology: Slides

2012/2013

Uploaded on 04/25/2013

lathika
lathika 🇮🇳

4

(12)

178 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 1: Introduction and Basic Scheme
We were handed a piece of cardboard with 32 thumbtacks arranged in a cross
pattern with one hole left empty in the very center. The object was to have only one
thumbtack left in the middle of the cardboard after executing thumbtack jumps
(similar in rules to jumping pieces on a checkerboard; no diagonal jumps, only in the
cardinal directions, and the jumped tacks get removed).
O O O
O
O O
O O O O O O O
O O O O O O
O O O O O O O
O O O
O O O
Below is a list of supplied smaller moves to aid us in the bigger puzzle. The circles
represent the thumbtacks, while the dots represent holes in the board. Jumps may
only be executed using the spaces shown.
Macros
The “T”
O O O O
O Æ O O O Æ O
O O O O O
O O • O O • O
O O O Æ • O O Æ O
O O O O
O O O
Find patterns: which pattern when; composition of patterns simplifies
problems.
There was a similar game on the back of the board. We were instructed to use the
“T” macro and another macro listed below the image of the puzzle:
O O
O O O
O O O O
O O O O O
Additional Macro:
O O Î • •
O O O O • O
Docsity.com
pf3
pf4

Partial preview of the text

Download Understanding Self-Evaluating and Compound Expressions in Scheme: Tutorial and more Slides Computer Programming in PDF only on Docsity!

Lecture 1: Introduction and Basic Scheme

We were handed a piece of cardboard with 32 thumbtacks arranged in a cross pattern with one hole left empty in the very center. The object was to have only one thumbtack left in the middle of the cardboard after executing thumbtack jumps (similar in rules to jumping pieces on a checkerboard; no diagonal jumps, only in the cardinal directions, and the jumped tacks get removed). O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Below is a list of supplied smaller moves to aid us in the bigger puzzle. The circles represent the thumbtacks, while the dots represent holes in the board. Jumps may only be executed using the spaces shown.

Macros

The “T”

O O • O • • • O

O Æ • O O O Æ O • •

O • O O O O • •

O O • O O • O •

O O O Æ • • • • O O Æ • • O

O O O • • • O •

O O O • • •

Find patterns: which pattern when; composition of patterns simplifies problems.

There was a similar game on the back of the board. We were instructed to use the “T” macro and another macro listed below the image of the puzzle:

O O

O O O

O O O O

O O O O O

Additional Macro:

  • • O O Î • • O O O O • O

Emacs The mode line is the black highlighted line that has the characters **Edwin: scheme The minibuffer is the region where emacs asks questions and gets answers. The first in-class assignment was saved under class1.scm Some commands not listed in the handout (Edwin-cheat.txt), also commands that were mentioned out loud and may still be listed in handout:

Saving file C-x, C-s Asterisks indicate that the file has been modified since it was last saved Undo C–x, u Switching buffers C–x, b Evaluate C-x, C-e Escape Whatever C-g Emacs Tutorial C-h, t <= worth looking try out

Value

  1. Numbers - written as 4, .75, ¾ Operations performed on numbers: Add/Subtract/Mult./Div. Equality
  2. Booleans – “true” and “false”, written #t and #f Operations performed on Booleans: Not (e.g., not #t indicates “false”) And (e.g., #t and #t indicates “true”) Or (e.g., #t or #f indicates “true”)
  3. Strings – sequence of characters such as “yay” Æ strings are listed in quotes Operations performed on strings: Append strings Split strings Length of string Characters of strings Compare two strings
  4. Procedures – in scheme, macros are considered “things” (a procedure is considered a “thing”) Example of procedure: recipe that’s written, can physically be held in hand Questions asked of a recipe: What are inputs of recipe? Is it a recipe?
  5. Lists – e.g., (1 3 4). It is possible to have lists of lists.

Scheme

Expression – text input by the programmer and sent to the evaluator (with C-x, C-e) Value – result computed by the evaluator when it works on an expression

For every expression, there is a rule to evaluate it and produce a value. Almost every expression has a value (excepting cases covered by 6.001).

Two types of expressions: simple and compound.

(if #t 1 2) if true-ish, then 1, else 2 (not #f)

(if 3 1 2) => 1 (if 0 1 2) => 1 (if + 1 2) => 1

Experiments with names:

Name value foo 4

fooÆ 4 bar Æ fo Æerror Not in table, produces error D debug, q quit