# Racket

Develop a Racket program that provides definitions for the following functions

1. A function that returns the greatest common divisor of two integers
2. A function named occurrences that takes as parameters two arguments, a and b. If a is not a list

then the function should return #f. Otherwise it should return the number of times b is found in

the list a. For example, if a is (3 4 2 53 3 5 4) and b is 3 the function should return 2

3. A function called allDiff? that takes as parameters two lists. The function returns #t if none of
the elements in the first list can be found in the second

4. A tail recursive function that takes as a parameter a list and returns the average of all the
number elements that exist in the list (if none are found it should return #f)

5. A function named divisorsLs that takes as a parameter an integer and returns a list of its divisors.
6. A higher-order function called map2. The function takes as parameter a function f and two lists

ls1 and ls2. It returns a list that corresponds to the application of the function to each pair of the

parameter lists elements. For example, assuming the pow function takes two parameters and

raises the first to the power of the second [ (pow 2 3) -> 8 ], then

(map2 pow (2 3 1 5) (4 2 0 1))

would return

(16 9 1 5)

7. Assume that a two-dimensional point is presented as a dotted pair where the car value is the x-
coordinate and the cdr value the y coordinate. Furthermore, assume that a line is defined by a

pair of two points. Define a function that takes as parameter two lines and returns #t if they

intersect

8. A collection of line segments can be represented by a list of dotted pairs, each one
corresponding to a point on a Cartesian plane. For example, the list

((3 . 6) ( 7 . 8) ( 10 . -2) (11 . -3) ( 18 . 1) (15 . 4) (25 . 9) (26 . -8) )

corresponds to the line segments shown in Figure 1. Create a function that takes as a parameter

a line segment and returns the number of times the segment crosses the horizontal axis. In the

provided example, the function should return 3.

10

-10

30 15