Revision of 2.1.3 What Is Meant by Data? from 30 June 2009 - 8:17pm

The revisions let you track differences between multiple versions of a post.

Printer-friendly versionPrinter-friendly version

Exercises

Exercise 2.4

Here is an alternative procedural representation of pairs. For this representation, verify that (car (cons x y)) yields x for any objects x and y.

(define (cons x y)
  (lambda (m) (m x y)))

(define (car z)
  (z (lambda (p q) p)))

What is the corresponding definition of cdr? (Hint: To verify that this works, make use of the substitution model of section 1.1.5.)

Exercise 2.5

Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations if we represent the pair a and b as the integer that is the product 2a 3b. Give the corresponding definitions of the procedures cons, car, and cdr.

Exercise 2.6

In case representing pairs as procedures wasn’t mind-boggling enough, consider that, in a language that can manipulate procedures, we can get by without numbers (at least insofar as nonnegative integers are concerned) by implementing 0 and the operation of adding 1 as

(define zero (lambda (f) (lambda (x) x)))

(define (add-1 n)
  (lambda (f) (lambda (x) (f ((n f) x)))))

This representation is known as Church numerals, after its inventor, Alonzo Church, the logician who invented the λ calculus.

Define one and two directly (not in terms of zero and add-1). (Hint: Use substitution to evaluate (add-1 zero)). Give a direct definition of the addition procedure + (not in terms of repeated application of add-1).

Comments

Beats By Dre Monster

SYNC by 50 If you’re like most of us, you woke up one morning this week and realized it’s almost December,SYNC by 50 and the holidays are swiftly approaching. STREET by 50 And, of course, you still don’t know what to get a few people on your list.We all know that headphones are a dime a dozen. STREET by 50 But a headphone that receives equal points for style and functionality, however, is a rare find. sms by 50 Some of our friends in the press know SMS Audio headphones fit the bill, sms by 50 and recommend you put them on your holiday shopping list this year: Beats By Dre Monster Rolling Stone included the limited edition Yellow STREET by 50 over-ear headphones in its 2012 holiday gift guide featured in the December issue.Beats By Dre MonsterWhat did Rolling Stone have to say about SMS Audio?
http://www.smsby50-beatsbydre.com/

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <hr> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • Adds typographic refinements.

More information about formatting options