teaching machines

CS 330: Lecture 32 – Closures

Dear students, Let’s start with a Program This! Consider the foreach algorithm: for each item in list do something with that item (call a method, print, etc.) The core idea is that we have a list of items, and we want to produce some side effect for each of them. The foreach algorithm doesn’t return […]

CS 318: Lab 22 – Flexbox

Dear students, Today we hit up the new Flexbox system of CSS. In short, Flexbox allows us to control the distribution, alignment, order, and expansion of a bunch children within their parent. It replaces many of the hacks of float and Javascript to achieve certain layouts. We’re going to dive right into the lab today. […]

CS 330: Lecture 31 – HOFs and Lambdas in Java

Dear students, Is Haskell the only language that supports composition and higher-order functions? No. Does Java? It can be made to! Let’s do that today. We start by porting the . operator. What do you suppose the type signature of . is in Haskell? Well, it takes in two functions and gives back a new […]

CS 318: Project Prototype 2 – due May 9

Your next milestone in the project is to iterate on the first digital prototype of your site. You will present this second draft of your prototype to randomly assigned classmates for another round of evaluation. Task 1: Iteration on Your Prototype Create a second draft of your site in a folder named prototype2 in your […]

CS 318: Lab 21 – Peer Review

Dear students, Today is peer review day. You will examine three peers projects and give mostly anonymous written feedback. You will spend 15 minutes examining each site in detail. Look for functional issues, like these: Try to break it by resizing the window and locate weird interactions with links or menus. Are there broken links […]

CS 330: Lecture 30 – Haskell IO Continued

Dear students, Last time we introduced ourselves to Haskell’s world of purity and its world of side effects. We learned that any value that gets created in the world of side effects is packaged up in an IO wrapper using the return function. We can unpackage such wrappers using the <- operator. We will finish […]

CS 330: Lecture 29 – Haskell IO

Dear students, Up till this point we haven’t written any standalone programs—none that get input from the user, none that generate output. We have looked at the purely functional side of Haskell, where time does not exist. Functions always produce the same value given the same inputs. No matter how many times you call it. […]

CS 330: Lecture 28 – Filter, Map, and Fold

Dear students: Last time we talked about lambdas and higher-order functions. We wrote this count method: count :: (a -> Bool) -> [a] -> Int count _ [] = 0 count predicate (first : rest) | predicate first = 1 + count predicate rest | otherwise = count predicate rest Let’s start with a Program […]

CS 318: Lab 20 – Animations

Dear students, Today we explore transitions to add a little life to our webpages using CSS transitions. As an example, we’ll create a list whose items pop out when hovered. We start with a list: <ul> <li>one</li> <li>two</li> <li>three</li> <li>four</li> </ul> Let’s add some background color to each item: li { background-color: blue; color: white; […]

CS 330: Lecture 27 – Lambdas and Higher-Order Functions

Dear students: Let’s start with a Program This: Using composition and point-free style, write a function that yields the square of the elements’ sum. Using sum and ^. It might help to start without composition and point-free style. Here’s my solution. squaredSum :: Num a => [a] -> a squaredSum list = sum list ^ […]