On this page:
10.1 Goal
10.2 Tools
10.3 Pyret Questions
10.4 Language
10.5 Library
10.6 Programming
10.7 Turnin

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.

Pyret is, despite its syntactic difference, actually quite similar to the forms of Racket you have been using so far. At some point you will want to refer to the Pyret documentation. But to start, we recommend you look at DCIC, specifically:
  • §27, which shows how to translate Racket to Pyret

  • §3, which introduces Pyret

  • §5.2, which offers a way to build up list-processing functions via examples

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.

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 Language🔗

In Pyret, we usually write contracts inside function headers, as opposed to in comments, as we did in Racket. We encourage you to get used to this practice, because this is what we will follow during the semester. If, however, you are still struggling with other aspects of the language and it’s more comfortable to use comments as you learn other aspects, you can do so as you get everything else sorted out.

You should not use anything that requires var or block or :=. You didn’t need the corresponding features in Racket, and you don’t need them in Pyret. Indeed, you will not use these in the course, either, until we get to this topic in class.

10.5 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.6 Programming🔗

You will re-implement in Pyret the following assignments:
  • 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:

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.7 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.