Functional Problem Solving (CSC 151 2014F) : Assignments

Printing Your Exams and Other Code


Summary: We detail three satisfactory ways to print your examinations or other pieces of code so that it is readable for you and for others (particularly for your faculty members and graders).

Introduction

You may have already experienced that reading code takes mental effort. Fortunately, when you are reading code in DrRacket, it adds things like auto-indent and color highlighting to make that job easier. Unfortunately, if you print code in non-standard ways, these helpful cues go away. This document describes three ways (ordered from easiest to more involved) to print code to hard copy that will conserve paper and preserve some amount of readability:

  • Printing directly from DrRacket
  • Printing code copied to a word processor
  • Printing pretty code using the terminal

Printing from DrRacket

The easiest way to print your code is directly from DrRacket. Unfortunately, if you use DrRacket to print from MathLan, the screen size of your font seems not to match the printed page well. We I have found that after you adjust for reasonable line lengths (don't trust DrRacket to wrap your lines sensibly--you must manually enter line breaks), if you change the on screen font size to 7 (using the default "Monospace" font) translates to paper well.

You may adjust the font size as follows:

  • Go to the Edit menu and click the Preferences option, usually at the bottom.
  • Select the Font tab (leftmost, usually selected by default).
  • Adjust the "Font Size" slider to read "7"
  • Click the "OK" button.

To return your font size to "normal" after printing, you may follow the same steps, choosing a different font size (probably 12).

Next, select the File menu and click the Print Definitions... option. You may follow the usual steps to print (preferably double-sided); the closest printer to the labs in SCI 3813 and SCI 3815 is called “duerer”.

Printing code copied to a word processor

Some of you may choose to take advantage of a word processor when submitting code. That is fine, but to preserve the alignment that DrRacket gives your code, you must use what is called a “monospace” font. (That means each character, whether "i" or "m" takes exactly the same width on the page.)

Please leave your code single-spaced (double-spacing makes it harder to read).

If you use LibreOffice on the MathLAN, you can choose from among several fonts with "mono" in the title, including:

  • Courier 10 Pitch
  • DejaVu Sans Mono
  • FreeMono
  • Liberation Mono

If you use another word processing product, some other standard options might include:

  • Courier
  • Courier New
  • Lucida Sans Typewriter

Please preserve the formatting of your code and formal comments in these monospace (fixed pitch) fonts. Other items may be rendered in a sensible font of your choosing.

Printing prett code using the terminal

For those comfortable typing in the command-line terminal, you can issue a command that will both format your text file and submit itfor printing. If you know the path to your file is, say, /home/username/Desktop/myfile.rkt and you wanted to print to the printer duerer, then you would use the Terminal command (changing username to your own user name, of course):

enscript -Pduerer -Escheme /home/username/Desktop/myfile.rkt