Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve in Dr.Racket and (rackunit) A buddy of mine wrote a program that predicts the results of college basketball games (pretty well, I might add).

Solve in Dr.Racket and (rackunit)

A buddy of mine wrote a program that predicts the results of college basketball games (pretty well, I might add). At the end of a week, he would like to know how far his program's predictions were from the actual results. His program has generated a list of predicted difference/actual difference pairs:

 ( (2 -7) (-4 -20) (7 8) (-13 2) ... ) 

The first item in this list says that his program predicted Team 1 would win by 2 points, but Team 2 won by 7 points. For that game, his program was off by abs(2 - (-7)) == abs(9) == 9 points. The third item says that his program predicted that Team 1 would win by 7 points and that it won by 8 points, so his program was off by abs(7 - 8) == abs(-1) == 1 point. The list can contain any number of these pairs. (This, too, is not much of a supposition... He wrote his program in Lisp, an ancestor of Racket, and he can surely write a simple expression to produce such a list from his database!) Write a Racket function named total-error that takes one argument, a list of this form. The function returns the total of all the differences in the list. For example:

 > (define example '((2 -7) (-4 -20) (7 8) (-13 2))) > (total-error example) 41 

I have provided a check-equal? expression for this example. Write at least three more check-equal? expressions to test your solution.

(define total-error (lambda (list-of-games) 'YOUR-CODE-HERE )) ; ----- tests ------- (check-equal? (total-error '((2 -7) (-4 -20) (7 8) (-13 2))) 41) 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

5. Identify three characteristics of the dialectical approach.

Answered: 1 week ago

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago