CS 430: Lecture 7 - Expressions

Dear students:

A new language is upon us. New languages require us to regress to infancy. The world around is filled with expressions that we can't understand, and we are uncomfortable. Today we embrace that discomfort and start babbling in Haskell by solving some Haskell programming problems in small groups.

Inventory

To solve these problems, we'll to make use of some of Haskell's builtin functions. These are the ones from the reading plus a few more that you might find useful:

PairSum

Write a function pairSum that, given a pair of numbers, returns their sum. For example:

Majority

Write a function majority that, given a population as an Int, returns the number of people that are needed to count as a majority in that people. For example:

Neck

Write a function neck that, given a list, returns its second element. For example:

Slice

Write a function slice that, given a list, a starting index, and an ending index, returns the sublist between the given indices. For example:

Frankenstring

Write a function frankenstring that, given two strings, returns a string that is the concatenation of the first half of the first string and the second half of the second string. For example:

Transfer

Write a function transfer that, given a pair of lists, returns a new pair of lists in which the first element of the first list has been prepended on the second list. For example:

Next

Write a function next that accepts two numbers and in an arithmetic sequence and returns the next number. For example:

Quadrant

Write a function quadrant that accepts a Cartesian coordinate pair of numbers. It returns "I", "II", "III", or "IV" to indicate the pairs quadrant. If the pair doesn't lie in a quadrant, it returns "?". For example:

Shy

Write a function shy that accepts an Int number of photos that you wish to arrange in a display. It returns the number of photos you need to achieve a fully-packed square. For example:

Mxb

Write a function mxb that accepts a slope and a y-intercept. It returns the slope-intercept form of the designated line as a string. For example:

RotateLetter

Write a function rotateLetter that accepts a Char uppercase letter and an Int offset and returns the letter with the given offset from the given letter. The offset wraps back to A as necessary. For example:

TODO

Here's your list of things to do before we meet next:

Be ready to demo your project on Thursday during class. This demo is a graded part of your project.
For your final submission, prepare a 2-3 minute screencast of your project that briefly demonstrates its execution. Give voiceover commentary. Pick three programming language ideas and reflect on how they are exhibited in your source code. Upload the video to a streaming service of your choice and share a link to it in your group channel on Discord. Also commit and push to GitHub. Do all this before fall break starts on Wednesday.

See you next time.

Sincerely,