

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Class: Programming Languages Recitati; Subject: Computer Science; University: University of Texas - San Antonio; Term: Unknown 1989;
Typology: Lab Reports
1 / 3
This page cannot be seen from the preview
Don't miss anything!


CS 3721: Programming Languages Lab Lab #03: Higher order functions in Scheme
Due date: February 12, 3:30pm. At the beginning of the next recitation.
Goals of this lab:
=> 210 Given the lengths of the legs of several right triangles in a list, define a recursive function calcHypotenuse which calculates the hypotenuses of the triangles using the let* operator. Hint: You may want to embed the following template into the else part of the check for whether the input list is null. (let* ((triangle ) (leg1 ) ; second binding (leg2 ) ; third binding (hypotenuse )) ; forth binding (... hypotenuse ...) ; ) Test your function with the expression below. > (calcHypotenuse โ((5 12) (3 4) (7 24) (8 15))) (list 13 5 25 17)
You can call it by the following: > (insert 6 โ(1 5 7)) (list 1 5 6 7) Now, using insert, write a function sort that takes a list of numbers and evaluates to a list containing those same integers sorted into ascending order (Hint: Use let to give a name to the result of recursively sorting the rest of the list (cdr field of the list)). Test your function with the expression below. > (sort โ(3 9 6 1)) (list 1 3 6 9)