RU beehive logo ITEC dept promo banner
ITEC 380
2014fall
ibarland

home—lectures—recipe—exams—hws—D2L—breeze (snow day)

hw01
finger exercises

Due:
Section 01: Sep.01 (Mon) 23:59, on D2L and hardcopy on Wednesday
Section 11: Sep.02 (Tue) 23:59, D2L.
Your submitted file should be named “hw01.rkt” as plain-text (which is what DrRacket saves as).

Standard instructions for all homeworks:

Open DrRacket (either in labs, or you can download it to your own computer from racket-lang.org). The first time you start DrRacket, it will ask you to choose a language; select Language > Use Language... > Teaching Languages > Beginning Student, for now.

  1. (3pts) Type each of the following expressions into DrRacket's bottom pane (interactions). Paste the results into a comment in the top pane (definitions), along side the problem number (e.g. “;; 1a: 5”).

    Clarification: (h),(i),(j) give error messages (like (k),(l) do); just give the error-messages they produce. (For (i), notice to yourself what DrRacket highlights.)

    Btw: I have intentionally posted this problem as an image, so that you can't copy/paste. Part of the point of the problem is to get experience typing in the expressions. Bwahaha, etc..

  2. (5pts) Add the following three definitions to your file (top pane):
    (define country "Morocco")
    (define art-style "rococo")
    (define gangsta "racketeer")
      
    For each of the below, give an expression which computes the desired results. Note that your answer should work even if we change the exact strings defined above. Keep your answer in the top pane, and press Run to see its result.
    1. What is the character at index 3 of country?
      Hint: see string-ref.
    2. What is the second-to-last character of country?
      Hint: See string-length, as part of what you pass to to string-ref.
    3. Does art-style comes alphabetically before the string formed by: the characters of country from index two up to (but not including) index 5?
      Hint: see string<?.
    4. What is the first half of gangsta (rounding the midpoint down)?
      Hint: use quotient to do integer division that discards any remainder.
  3. (2pts) Which is a better estimate for the number of seconds in a year: 754, or π·107? Give racket expressions to support your answer.
    (Inspired by xkcd.com/1047/.)

home—lectures—recipe—exams—hws—D2L—breeze (snow day)


©2014, Ian Barland, Radford University
Last modified 2014.Sep.08 (Mon)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Rendered by Racket.