Your Prolog will be evaluated with swipl on mathlab. Your ml with be evaluated with sml on mathlab.
For this assignment, you may work with a partner, or you may work on your own. If you choose to work with a partner, submit one assignment from one of your accounts. Include both partners' names and IDs in a header comment. You are expected to colaborate with your partner but not with other students, although you may discuss syntax and general approach with others.
Attempt to use clear style. Your code should be lightly commented. Include a header with your name and UTorID, and that of your partner, if you have one. In Prolog, do not use singleton variables, instead use "__". A rule like: g(A,B):-A=B. should be written g(A,A). Style rules you've learned in previous courses still apply.
Your Prolog code should not produce duplicate results, or end in an infinite loop. Use careful construction of your predicates, and cuts where appropriate, to ensure this.
For both Prolog and ML, you may assume your input is valid. Document any unclear cases (if you've chosen them as valid or invalid) and what you know of the behaviour for invalid input or unclear cases.
Please let me know of any ambiguities in this assignment specification as soon as possible.
All ML code should include explicit type declarations. All the rules for nice recursion and use of higher order functions from Scheme still apply. Your functions should be lightly commented. You may create helper functions as necessary, use anonymous functions if these helpers are only used once. If you have read ahead about let expressions, you may use them, but you are not required to do so.
A - Write a function list_of_squares which takes an integer n, and returns a list of the first n squares.
B - Palindrome. Write a function palindrome which takes a list, and returns true if the list is the same forwards as backwards.
C - sum_of_digits. Write a function which takes and integer n, and returns an integer which is the sum of the digits of n. You may assume the number is greater than or equal to zero.
D - multiple_of_nine. Write a function which uses the function in C, which takes in an integer (may be assumed to be greater than or equal to zero) and returns true iff it is a multiple of nine.
E - intersection. Write a function, intersection, which takes two pairs of reals (m1, b1),(m2, b2), and interprets them as the slope and Y-intersept of two lines. Return a real * real tuple representing the intersection of the two lines. You should handle the case of parallel lines.