Special Forms - Building Programming Experience - Lecture Slides, Slides of Computer Programming

Some concept of Building Programming Experience are Trees, Square Limit Language, Special Forms, Quizanssheet, Professor Abstraction, Compound Procedure, Procedures And Recursion. Main points of this lecture are: Special Forms, Name Parameters, Form, Equivalent, Duration, More Expressions, Evaluated, Bindings, Value, Relevant Expressions

Typology: Slides

2012/2013

Uploaded on 04/25/2013

lathika
lathika 🇮🇳

4

(12)

167 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Scheme
1. Special Forms
(a) define (sugared form) -(define (name parameters) expressions)
This form is equivalent to (define name (lambda (parameters) expressions)).
(b) let -(let bindings body)
Binds the given bindings for the duration of the body. The bindings is a list of (name
value) pairs. The body consists of one or more expressions which are evaluated in order
and the value of last is returned.
Problems
1. Guess the value, then evaluate the expression in scheme. If your guess differs from the actual
output, try desugaring any relevant expressions.
(define (foo x)
(+ x 3))
foo
(foo 5)
(define bar 5)
(define (baz) 5)
bar
baz
Docsity.com
pf3

Partial preview of the text

Download Special Forms - Building Programming Experience - Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

Scheme

  1. Special Forms

(a) define (sugared form) (define (name parameters) expressions)

This form is equivalent to (define name (lambda (parameters) expressions)).

(b) let (let bindings body)

Binds the given bindings for the duration of the body. The bindings is a list of (name value) pairs. The body consists of one or more expressions which are evaluated in order and the value of last is returned.

Problems

  1. Guess the value, then evaluate the expression in scheme. If your guess differs from the actual output, try desugaring any relevant expressions.

(define (foo x) (+ x 3))

foo

(foo 5)

(define bar 5)

(define (baz) 5)

bar

baz

(bar)

(baz)

(let ((a 3) (b 5)) (+ a b))

(let ((+ ) ( +)) (+ 3 (* 4 5)))

(define m 3) (let ((m (+ m 1))) (+ m 1))

(define n 4) (let ((n 12) (o (+ n 2))) (* n o))

Data Structures

New procedures

  1. (cons a b) Makes a conscell (pair) from a and b
  2. (car c) extracts the value of the first part of the pair
  3. (cdr c) extracts the value of the second part of the pair
  4. (c ad^ a dd^ aa dr c) shortcuts
  5. (list a b c ...) builds a list of the arguments to the procedure
  6. (listref lst n) returns the nth element of lst
  7. (append l1 l2) makes a new list containing the elements of both lists
  8. (null? lst) is lst the empty list?

Problems

  1. Draw boxandpointer for the values of the following expressions.

(list 1 2 3)