Start mastering your classes. Access 3M+ class-specific study documents.

Lecture 5: Recursion Midterm-like problems (20 pages)

Previewing pages 1-2, 19-20 of actual document. View the full content.
View Full Document

Previewing pages 1-2, 19-20 of actual document.

View the full content.
View Full Document
View Full Document

Lecture 5: Recursion Midterm-like problems

25 views


Pages:
20
School:
University of California, Berkeley
Course:
Compsci 3 - Introduction to Symbolic Programming
Introduction to Symbolic Programming Documents

Unformatted text preview:

CS3: Introduction to Symbolic Programming Fall 2006 Nate Titterton [email protected] Lecture 5: Recursion Midterm-like problems Spring 2006 CS3: 2 Schedule Lecture: finishing recursion Lab: Miniproject #2 Oct 16-20 8 Lecture: Advanced Recursion Lab: Recursion III Oct 9-13 7 Lecture: Midterm 1 Lab: Recursion II Oct 2-6 6 Lecture: Introduction to Recursion Lab: Recursion Sept 25-29 5 Lecture: Data abstraction in DbD Lab: Miniproject I Sept 18-22 4 Now consider some incorrect implementations of double. For each one, indicate what the call (double 'apple) will return. If no value is returned because the procedure crashes, give the error message that results. (define (double wd) (sentence 'two (wd 's)) ) (define (double wd) (sentence 'two (sentence wd s)) ) (define (double wd) (sentence 'two '(word wd s))) Spring 2006 CS3: 20 between? Write a procedure called between? which takes three numbers as arguments, and returns true if and only if the second argument is between and not equal to the first and the third: (between? 5 6 7) -> #t (between? 7 6 5) -> #t Part A: Write between? without using if or cond. Part B: Write between? without using and or or. Part C: Write a suite of test cases for between?. Make sure you test the possible sets of parameters exhaustively as possible, in order to test different ways the code could be written. Also, make sure you describe what the result of the call should be!



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...