CSE 1729 Study Guide - Final Guide: Car And Cdr, Binary Tree, Empty Set

569 views9 pages
silveralpaca779 and 13 others unlocked
CSE 1729 Full Course Notes
28
CSE 1729 Full Course Notes
Verified Note
28 documents

Document Summary

Give short scheme functions or short answers for the following. (a) (2 points. ) The call-by-value convention passes (a new copy of) the value of an actual parameter to a function thus any changes made to the formal parameter of the function do not change the calling environment. The call-by-reference convention passes a reference to the value of an actual parameter thus any changes to the value are re ected in the calling environment. Scheme uses call-by-value for all atomic types and call-by-reference for all compound type (pairs, vectors). (b) (2 points. ) > ( vector-map (vector 1 2 3) f) #(2 3 4) (define ( vector-map v f) (let (( result (make-vector (vector-length v)))) (do ((i 0 (+ i 1))) ((= i (vector-length v)) result ) (vector-set ! result i (f (vector-ref v i )))))) (c) (3 points. ) L) #f (or ( element (car l) (cdr l)) ( duplicates ? (cdr l)))))

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents