hw3 - b For this example give the function calls to obtain...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
COP4020 Spring 2011 Homework Assignment 3 1. Explain the difference between a functional and a special form in Scheme. 2. Why is Scheme called “ homoiconic ”? 3. Which Scheme construct(s) will cause a Scheme program to depart from a purely functional programming model, i.e. are not considered “pure”? 4. We can implement a binary tree data structure by using lists with three elements: (value left-tree right-tree). A leaf is an empty list ‘(). a. Given the tree: What is the representation for this tree in Scheme written as a list? For this list also show the internal Scheme linked list node as a graph of nodes and edges.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: b. For this example, give the function calls to obtain the value “5” from the list representation of the tree (use car and cdr or shorthand combinations thereof if you prefer them). 5. Define a Scheme function “allpos” that takes a list of integers, applies a function that converts an integer to true if the integer is positive and to false otherwise, and reduces the resulting list to a single true/false by conjunction. To keep our code compact, use higher-order Scheme functions whenever possible. See lecture slide 27. The result should be: (allpos ‘(1 2 3)) => #t and (allpos ‘(0 1 2)) => #f 3 5 1 4...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online