teaching machines

CS 330 Lecture 14 – Graphing Calculator

Dear students, Let’s put subtype polymorphism to work in a Curses-based graphic calculator. Let’s start with an abstract base class for all manner of functions: class Function { public: virtual double operator()(double x) const = 0; }; Now let’s recast our linear and quadratic functions as independent subtypes of Function: class QuadraticFunction : public Function […]

CS 330 Lecture 13 – Vtables and Graphing Calculator

Dear students, We saw last time that for subtype polymorphism to work in languages like Java and C++, we need some for way for each object to carry around some information to help us figure out what method to call at runtime. What exactly is that information and how does the runtime decision—the dynamic dispatch—get […]

CS 330 Lecture 12 – Subtype Polymorphism

Dear students, We introduced four type of polymorphism last time and saw examples of the first two—coercion and ad hoc polymorphism—through the lens of C++. On to a third form: Subtype polymorphism is when a piece of code is targeted to handle an umbrella type, a supertype, but somehow it calls the overridden methods in […]

CS 330 Lecture 11 – Polymorphism: Coercion and Ad Hoc

Dear students, All my favorite talks try to classify some phenomenon in a 2×2 matrix, so let’s do the same. Let’s categorize human endeavors into four buckets based on how much effort is involved and what effect they have: Large Effect polymorphism John Henry learning Vim Small Effect sleeping voting teaching Little Effort Lots of […]

CS 330 Lecture 10 – Type Systems

Dear students, Last time, we introduced types as one of the more prominent distinguishing features of a programming language. We enumerated a bunch of types commonly supported in programming languages. This time, we look at some ways to characterize a language’s type system. To help understand the importance of a language’s type system, imagine if […]

CS 330 Lecture 9 – Types

Dear students, Today we begin our exploration of programming language concepts, rather than the tools (regex) that we’ll later use for interpreting programming languages. In particular, we start off our discussion with C. I used to talk about assembly first, because no programming language should be evaluated outside the context of history. All that humans […]

CS 330 Lecture 8 – Substitution Blocks, Number Ranges, Lookarounds

Dear students, At the end of class, we’re going to play some Regex Bingo. While you’re waiting, find a partner make a 4×4 grid of randomly generated strings. Include uppercase and lowercase letters, numbers, whitespace, and punctuation. Keep the strings short. There’s no free space. Our discussion of gsub was cut short last time. Let’s […]

CS 330 Lecture 7 – Find and Replace

Dear students, We will focus on the final two of the three common operations we for which we will use regular expressions: Asserting that text matches a pattern. Finding all matches of a pattern in a document. Replacing all matches of a pattern with some other text. Finding all matches of a regular expression is […]

CS 330 Lecture 6 – Asserting and Find-All

Dear students, We will discuss three common operations we want to perform on text that are only fun when regular expressions are involved: Asserting that text matches a pattern. Finding all matches of a pattern in a document. Replacing all matches of a pattern with some other text. Today we focus on the first two […]

CS 330 Lecture 5 – Regex

Dear students, Let’s dive right into some Ruby scripts: Calculate an aspect ratio from dimensions given as command line parameters. Generate a list of words that rhyme with a word given as a command-line parameter. Solve Advent of Code problem 1. We aren’t going to concentrate on Ruby as a programming language much at the […]

1 7 8 9 10 11 35