CSC 4101 Chapter : Homework1

9 views2 pages
15 Mar 2019
School
Course
Professor

Document Summary

Given the following scheme de nition: (define x "(define (fac n) (if (= n 0) 1 (this de nes not the factorial function fac, but the variable x. ) (* n (fac (- n 1)))))) Write scheme expressions in terms of x that would have the effect of extracting the following expres- sions: (a) (fac n) (b) 0 (c) (- n 1) (d) the second occurrence of fac. (e) the last occurrence of n. E. g. , the expression (car x) would extract define. Don"t just restate the function de nition in english. Hint: not all the code in this function does something useful. (b) (2 pts) Show the result of executing the expression (foo "(((a (b c) d) (((d) e) f) g)): (10 pts) Write a recursive scheme function with two parameters, an atom and a list, that returns the number of occurrences, no matter how deep, of the given atom.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents