Programming Challenge #2 - "Function Definition"
-
PERIMETER OF TRIANGLE
a. Write the Lisp definition of a function to compute the perimeter of a triangle which takes just one argument, a list of three points. For example, the argument might be the list
((4 8) (1 2) (10.5 7.7))
. Or, it might be((0 0) (9.5 2) (-5 -5))
. Place this function definition (and whatever supporting functions you choose to write) in a file calledpot.l
.b. Demo the program by computing the perimeters for the two triangles given in the previous item. Save the demo to a file called
pot-demo.txt
. -
AREA OF A NORMAN WINDOW
a. Write the Lisp definition of a function to compute the area of a “Norman window” that takes two arguments, the first being the width of the window and the second being the height of the rectangular base of the window. Place this function definition (and whatever supporting functions you choose to write) in a file called
anw.l
. (A norman window consists of a rectangular base surmounted by a semicircular top.)b. Demo the program by computing the areas of Norman windows with (1)
width=10
andheight=21.5
, and (2)width=44.5
andheight=66
. Save the demo to a file calledanw-demo.txt
.