Lab: Random language generation

Assigned
Wednesday, 2 December 2020
Summary
We explore Racket’s random procedure and ways to use that procedure and a variety of associated procedures to generate language. We consider the implications of having a procedure that does not behave consistently. We also simulate some games of chance.

Important procedures

  • (random n): given a positive integer, generate a difficult-to-predict value between 0 and n-1, inclusive.

Preparation

a. Decide who is side A and who is side B.

A side: random-language-a.rkt

B side: random-language-b.rkt

b. Decide who will submit the lab.

c. Review the procedures included in the lab to make sure you understand what they are intended to do.

Acknowledgements

This laboratory was inspired by an earlier lab on randomness from the spring 2018 version of CSC 151. That lab was, itself, based on a sequence of earlier labs on randomness and simulation.

This version also adds some new exercises on language generation using new procedures in the csc151 library. Those exercises were inspired by similar exercises designed for the summer 2018 “language of code” camp.

For those who care, the punny pair-a-dice first appeared in an exercise in spring 2001. It then resurfaced (with a definition) in a Web-game exercise in fall 2002.