### Problem Set 11

Purpose This problem set (primarily) concerns the design of accumulator-style functions.

Design the function make-palindrome, which consumes a non-empty String and constructs a palindrome by mirroring the String around the last letter. For example, (make-palindrome "fundies") should produce "fundieseidnuf".

Design the function is-palindrome?, which consumes a non-empty String and determines whether the String is a palindrome or not.

Problem 2: A number, n>1, is prime if it is not divisible by any numbers besides 1 and itself, such as 2, 3, 5 and 7.

Design the function prime? which consumes a Natural Number, n and returns true if it is prime and false otherwise. Use the fact that if n is not prime, one if its factors must be less than or equal to the square root of n.

Design the function list-primes which consumes a Natural Number, n, and produces the list of prime numbers up to n.

Design the function fibonacci, (without accumulators) which consumes a Natural Number and produces its Fibonacci number. For example, (fibonacci 11) should produce 89.

Use accumulators to design a more efficient version of fibonacci.

￼￼￼￼￼￼￼￼￼ Design a function, list-fibonacci, that consumes a Natural Number and produces the list of Fibonacci numbers from F0 to Fn.

Problem 4: Many card games are structured around the taking of tricks, a set of four cards where one card is contributed from each player. Examples of trick-taking games include hearts, bridge and whist.

- Define a function that takes a trick and returns the winning player according to the following rules:
High card wins

In the case of a tie i.e. two or more cards of the same value are played the trick goes to the player with the better suit. (Clubs < Diamonds < Hearts < Spades)

Note that the problem is purposely left ambiguous in terms of data definitions and requirements. It is up to you to decide how to implement this problem. There is not one right answer, but some answers are better and simpler than others. Make sure to follow the design recipe. A game is a series of tricks. Design a function that takes a game and returns a winner. The winner is the person who won the most tricks overall.

Problem 5: Twitter is a social networking service that allows users to write messages called tweets that are up to 140 characters.

Design a data definition for a network of Twitter users. A Twitter user should have a handle (or name) and tweeps (or followers).

Create an example of a network of five or more users.

Design a function, list-handles, that consumes a network and produces a list of all of the handles in the network. You must use an accumulator.

Design a function, most-followers, that consumes a network and produces the handle in the network that has the most followers. You must use an accumulator.

Design a function, friends?, that consumes a network and two handles and determines whether it contains two users who follow each other.