6.6

Assignment 1

home work!

Programming Language BSL

Due Date Monday 01/14 at 9pm

Purpose Logistics; To write simple functions & tests relating to numbers, images, and strings

Expectations
  • You should submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept NO email submissions. Failure to submit a .rkt file will result in a 0. Please note that a .rkt~ file or .bak file will NOT be acceptable and will result in a 0.

  • You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0.

  • Your code MUST conform to the guidelines outlined in the style guide on the course website. The style guide will be updated as the semester progresses so please remember to read it before submitting each assignment.

Graded Exercises

The following two exercises should be completed in the handin server. You do not need to write anything for these exercises in your submitted file.

Exercise 1 Read the Course Contract and fill out the Course Contract assignment on the handin server.

Exercise 2 Read the Syllabus and fill out the Exam conflicts assignment on the handin server.

The remaining exercises should all be completed in a single .rkt file which you should submit via the Handin Server. Please note that you can submit as many times as you like but only your most recent submission will be graded. This means that if you submit twice, once before the deadline and once after the deadline, the submission made after the deadline will be graded, and penalized accordingly.

Exercise 3 Now that you have read the syllabus, you know how many lectures there are this semester! You can also find the cost of tuition here. Using these numbers, and the theory that a full time student is taking 4 courses, calculate the cost of one lecture for CS2500. Define a constant for this calculation. Remember this calculation the next time you want to skip lecture. Remember that you are paying this cost whether or not you attend the lecture.

Exercise 4 Search the course website to find the names and email addresses of the tutors and TAs. In a comment, write the name of the TA with the shortest last name and the name of the TA with the longest last name.

Exercise 5 Search the course website to find the style guide. In a comment, write the course policy on hanging parentheses. We expect you to follow this policy and will grade your assignments accordingly.

Exercise 6 In a comment, write the four forms of atomic data introduced in Chapter 1 of the textbook.

Exercise 7 In Pig Latin words that begin with a consonant are shifted so that the first letter goes to the end of the word and is then followed by the suffix "ay". Write a function, pig-latinize that, given a word, follows this pattern. You may assume that the word begins with a consonant and that moving the first letter is enough (that is, given the word "crater" we expect the function to produce "ratercay" even though this is not quite how Pig Latin works). Write at least 2 tests for this function.

Hint: The String function documentation is a useful place to look for functions that operate on Strings.

Exercise 8 Write a function, middle, which, given three arguments, produces the second one. Provide at least two tests for this function. In a comment, explain what types of values this function can take as inputs and what types of values it can produce.

Exercise 9 Yak Travel Agency arranges trips for climbing Mount Everest. For each trip, they charge an initial fee in addition to $0.15 for each vertical meter climbed. For instance, the price for climbing all the way to the summit, which is 3500 meters above the base of the mountain, is $645. Write a function which, given the number of vertical meters climbed, produces the cost of a trip led by the Yak Travel Agency. Write at least two tests for this function.

Hint: it can be useful to write out a table of input/output pairs to help understand these types of mathematical relationships (and these can then provide great tests!)

The following exercises will ask you to provide "sufficient" tests. We are looking for you to test all the interesting cases of the function. This includes each case of any conditionals you write, as well as edge cases (when the inputs are on the edge of a condition).

Exercise 10 Write a function, valid-date? which, given a String representing the month of the year (e.g. "January") and a Number representing the day of the month, returns a Boolean if this is a valid date. Your function should return true if the date is sometimes valid (e.g. February 29th). You should also provide sufficient tests for this function.

Exercise 11 Complete exercise 17 in section 2.1 of the textbook. You should also provide sufficient tests for this function.

Hint: The Image function documentation is a useful place to look for functions that operate on Images.