10 Placement 5
10.1 Goal
In this assignment we will switch languages, and see how ideas transfer between them even when their syntaxes (i.e., the text we use to write programs) are wildly different. Concretely, we are going to switch to the language Pyret.
The key thing to note is that all the knowledge you have gained over the previous placement tasks is still valid and directly transfers over. You can even write your solutions in Racket and translate them by hand over to Pyret.
In Pyret, we usually write contracts inside function headers, as opposed to in comments, as we did in Racket. For this assignment, however, you can continue to use the comment syntax, and focus on the other details.
10.2 Tools
You don’t need to install any software: you can program entirely online at code.pyret.org (CPO). Connect it to any Google account you wish. Pyret will save files to Google Drive, but you can also download a file using File | Download to submit homework.
10.3 Pyret Questions
After you have read the above materials and explored the systems, you may still have some questions about Pyret or CPO. Feel free to ask them. However, chances are others may have the same question. Therefore, please couch your question in generic, as opposed to problem-specific, terms (for instance, do not include partial solutions). That way, we can make your questions and our answers public for everyone to read without having to edit your code to obscure a solution or have to rewrite the whole thing in generic terms ourselves.
10.4 Library
You can use the Pyret equivalent of any Racket functions you were permitted to use in Placements 1 through 4.
If in doubt, though, we urge you to write the helper functions you need for yourself. There are some things you can’t do yourself for which you really do need language support; everything else you ought to be able to build by yourself by this point of the placement!
10.5 Programming
From Placement 1: all the flags. Please give each one a top-level name, that of the country (use hyphens for spaces): e.g., saint-lucia.
From Placement 2: the functions score-by-length and words-to-sentence.
From Placement 3: the functions valid-words and unique.
From Placement 4: the function l33t.
In addition, please implement:
unique-r :: List-of-Any -> List-of-Any
Like unique from Placement 3, except it keeps the last element.
median :: List-of-Number -> Number
Produces the median value of the given list. If the list is of even length, produce the average of the two “middle” values. You can assume that the list will not be empty.
For all the above programs: You are welcome to use higher-order functions, but you are not required to. (You can use them for some solutions but not others, too.)
10.6 Turnin
You do not need to turn in test files separately for this assignment: just leave all your tests in the program file.
Please name the program file p5-code.arr. (Why "arr"? Because pirates say "Arrrrr!!!!!")
Failure to follow any of these instructions may result in zero credit.