teaching machines

CS 330 Lecture 22 – Ways to Define Functions: Partial Evaluation

Dear students, There are at least four ways of defining functions in Haskell: by defining a named function by partially applying parameters to get a new function expecting only the remaining parameters by composing a gauntlet of functions together by defining unnamed lambdas A good first question to ask is this: why do we need […]

CS 330 Lecture 21 – More Recursion and Pattern Matching

Dear students, Today we solve more problems in Haskell together. Along the way we will discover some of the peculiarities of functional programming, like the lack of iteration, the supremacy of recursion, and the beauty of pattern matching: Here are the problems we’ll solve: Last time we started to write a function to determine if […]

CS 330 Homework – Wasd – due before May 15

See the PDF.

CS 330 Lecture 20 – Recursion, Cases, and Pattern Matching

Dear students, Today we solve more problems in Haskell together. Along the way we will discover some of the peculiarities of functional programming, like the lack of iteration, the supremacy of recursion, and the beauty of pattern matching: Here is an exercise that I ask you to complete with a neighbor: Collatz The first number […]

CS 330 Homework – Nogramming – due before May 15

See the PDF.

CS 330 Lecture 19 – Functions and Lists

Dear students, Today we solve more problems in Haskell together. Along the way we will discover some of the peculiarities of functional programming, like the supremacy of linked lists. First, an exercise to complete with a neighbor: Parallelogram Write a function pcomplete that completes a parallelogram. Suppose you are given three points in 2D space. […]

CS 330 Lecture 18 – Haskell

Dear students, Today we begin our foray in the Haskell language, which is very different from the Java and C that you have been steeped in. I want to introduce its craziness by just solving some problems. We’ll see what we encounter. Here are the tasks I will ask you to complete with a neighbor: […]

CS 330 Lecture 17 – Heap of Trouble

Dear students, Let’s start with a What Does This Do! Absorb this code into your brain, and predict its output. After a minute of silent reflection, we’ll discuss. void mkfoo(char *s) { s = malloc(sizeof(char) * 4); strcpy(s, "foo"); } int main(int argc, char **argv) { char *text = "slar"; mkfoo(text); printf("%s", text); return 0; […]

CS 330 Lecture 16 – Parametric Polymorphism

Dear students, Don’t get me started on arrays. What sort of world is this where an array is fixed in size, but yet it doesn’t know what that size is? We must fix this. Let’s create a growable array: class Flexray { public: Flexray() : capacity(10), nitems(0), elements(new int[capacity]) { } ~Flexray() { delete[] elements; […]

CS 330 Lecture 15 – Choices in C++

Dear students, C++ is a language with choices. Some call that a curse. I’d argue that asking that all doors be closed but one gives to much authority to an outside entity that can’t possibly understand our situation and can’t be trusted to know which door is best. Let’s discuss a few of these choices […]

1 6 7 8 9 10 35