Question: Please help. Scheme language. Complete each part by creating a function. Each one can be tested with the line that macthes below. Must compile in
Please help. Scheme language. Complete each part by creating a function. Each one can be tested with the line that macthes below. Must compile in DrRacket/emacs
(length '(1 2 3 4)) => 4
(sum-of-squares 3 4 5 6) => 86
(avg 4 5 5 5 5 5) => 29/6
(avg-odd 4 5 5 5 5 5) => 5
(shortest '(1 2) '(2 3 4) '(4) '(5 6 7 8)) => '(4)
(avg-fact 2 3 4) => 32/3
((tally even?) '(1 2 3 4 5)) => 2
(list-ref '(5 7 60 98) 0) => 5


Using the functions, apply, select, map, filter, outer-product and iota, and without using recursion, give definitions for the following functions: 1. length - returns the length of a list. 2. sum-of-squares - returns the sum of the squares of its arguments. 3. avg - returns the average of its arguments. 4. avg-odd - returns the average of its odd arguments. 5. shortest - returns the shortest of its list arguments. 6. avg-fact - returns the average of the factorials of its arguments. 7. tally - takes a predicate and a list and returns the number of list elements which satisfy the predicate. 8. list-ref- takes a list and an integer, n, and returns the n-th element of the list. Using the functions, apply, select, map, filter, outer-product and iota, and without using recursion, give definitions for the following functions: 1. length - returns the length of a list. 2. sum-of-squares - returns the sum of the squares of its arguments. 3. avg - returns the average of its arguments. 4. avg-odd - returns the average of its odd arguments. 5. shortest - returns the shortest of its list arguments. 6. avg-fact - returns the average of the factorials of its arguments. 7. tally - takes a predicate and a list and returns the number of list elements which satisfy the predicate. 8. list-ref- takes a list and an integer, n, and returns the n-th element of the list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
