teaching machines

CS 330 Lecture 33 – State Machines

Dear students, Okay, pruning out the recursive calls that you’ve already done before is one way to tame recursion. Let’s look at another. We mentioned early that the piling up of stack frames is what gets recursion in trouble. Consider this definition of sum’ in Haskell: sum' [] = 0 sum' (first:rest) = first + […]

CS 330 Lecture 32 – Taming Recursion

Dear students, We’ve seen that Haskell does some pretty crazy things: it infers types, it supports this crazy pattern matching stuff, it disallows side effects, and it computes things lazily. Let’s look at one last crazy thing it does: it uses recursion for everything! There are no loop control structures. Normally, when you think of […]

CS 330 Lecture 31 – Call-by-name and Call-by-need

Dear students, Last time we introduced a different way of passing parameters. Instead of eagerly evaluating them, we delayed evaluation until they were referenced inside the function. You are probably thinking, “Call-by-name. Big deal. How many new control structures am I going to need in my life?” Probably not many, but I think the bigger […]

CS 318 Lab 21 – Iframes and Transitions

Dear students, Today we explore transitions to add a little life to our webpages. We will focus on the mechanics of the CSS transitions. I leave it up to your good judgement to not go overboard or favor vanity over content. We’ll do a little example of making some list elements pop out when hovered […]

CS 330 Lecture 30 – Call By Name

Dear students, When you call a function, what happens? In particular, what happens in this code? int m() { cout << "m" << std::endl; return 5; } int r() { cout << "r" << std::endl; return 7; } int multiply(int a, int b) { cout << "*" << std::endl; return a * b; } int […]

CS 318 Lab 20 – Web Jam

Dear students, Let’s shake things up a bit today. When game developers get together to build a game in a very short amount of time, they call that a game jam. We will have a web jam. I want to devote all of today’s lab time to that, so I won’t be doing any talking. […]

CS 330 Lecture 29 – Haskell IO Cont’d

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 28 – Haskell IO

Dear students, There are a few ideas we didn’t get to last time. Let’s touch upon those before diving into a discussion of Haskell I/O. First, what about the type signature for fold? Let’s reason it out. We know it will have four parts: three parameters and a return value. fold :: _ -> _ […]

CS 318 Lab 19 – Reform

Dear students, Today we continue to explore forms. Many of you in this class will be professional communicators. Forms are kind of a big deal to you. Books don’t have them. Nor do radio and television. But our websites do. What power! Forms are a doorway; they make the web a two-way street. Your words […]

CS 330 Lecture 27 – Fold

Dear students, Let’s start with a Program This! Complete two of the following functions based on your row number. All of them accept a list. Solve them using the pattern-matching style, with base cases and general cases defined separately. All of them should be two-liners. upped, which generates an uppercase version of the incoming String […]

1 33 34 35 36 37 110