teaching machines

CS 330 Lecture 34 – Scope and eval

Agenda final project deadline association lists (Scheme’s hash) program this dynamic interpretation sandboxing L-systems Program This Pick one: Write a function apply-productions-once that takes as arguments a list-of-atoms and an association list. Each atom in the list is replaced by the value for which the atom is the key in the association-list. For example, (apply-productions-once […]

CS 145 Lecture 22 – Stopwatch

Agenda Paragraph.plot takes Image, not 2-D array PPMViewer lab gotchas other instances as parameters invoking object is not a parameter writing a Stopwatch Code NDeckerBurger.java package prefinal; public class NDeckerBurger { private int nDecks; private boolean hasCheese; public static final int CALORIES_PER_DECK = 211; public NDeckerBurger(int givenDeckCount) { nDecks = givenDeckCount; } public NDeckerBurger(int givenDeckCount, […]

CS 330 Homework 5 – due before Tuesday, May 8

See the PDF.

CS 330 Lecture 33 – Higher-order

Agenda program this double, square, cosine higher-order functions map and filter variable-length argument lists symbolic differentiation TODO Introduction Google’s MapReduce: http://code.google.com/edu/parallel/mapreduce-tutorial.html. Program This Choose one: Write contains, which takes two arguments: a list and an atom. Return true if the list contains the atom. Write nth-element, which returns the the nth-element (starting at 0) of the […]

CS 145 Lab 10 – Choose-your-own

Reminder Show your completed lab 9 checkpoints to your instructor or TA in the first 20 minutes of this lab. Checkpoint #1 Answering only your professor’s questions only takes you so far. Composing your own is where the money is. Write a checkpoint-type problem for others to solve. Require the development of an object with instance variables, […]

CS 330 Lecture 32 – Scheme, Part II

Agenda why functional? why not functional? reverse engineering finish merge program this double, square, cosine higher-order functions map and filter variable-length argument lists symbolic differentiation TODO http://en.wikipedia.org/wiki/Method_chaining http://www.paulgraham.com/icad.html Reverse Engineering Program This Choose one or both: Write contains, which takes two arguments: a list and an atom. Return true if the list contains the atom. […]

CS 145 Lab 9 – Objects

Prelab Read chapter 8! Reminder Show your completed lab 8 checkpoints to your instructor or TA in the first 20 minutes of this lab. Object-orientation As we’ve seen in lecture, objects are the marriage of data (instance variables, declared at the class level) and methods. Up until now, our programming has been action- or procedure-oriented. We wrote […]

CS 145 Lecture 21 – 2-D arrays, Image

Agenda 2-D arrays (or arrays of arrays) writing an image portable graymap Code Birthday2.java package preexam2; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Birthday2 { public static void main(String[] args) throws FileNotFoundException { File file = new File(“/home/user/bdays.csv”); Scanner in = new Scanner(file); int[][] counters = new int[12][31]; while (in.hasNextInt()) { int month = […]

CS 145 Lecture 20 – NDeckerBurger, our first object

Agenda objects instance variables constructors methods static vs. instance Code NDeckerBurger.java package prefinal; public class NDeckerBurger { private int nDecks; private boolean hasCheese; public static final int CALORIES_PER_DECK = 211; public NDeckerBurger(int givenDeckCount) { nDecks = givenDeckCount; } public NDeckerBurger(int givenDeckCount, boolean hasCheese) { nDecks = givenDeckCount; this.hasCheese = hasCheese; } public int getDeckCount() { […]

CS 330 Lecture 31 – Hi, Scheme

Agenda Thinking functionally recursion over iteration chaining vs. sequence atoms, lists, and S-expressions Polish notation car, cdr, cons, cond our first functions arithmetic expressions logical expressions factorial lambda list functions length contains nth-element merge remove map filter TODO http://racket-lang.org/ Program This Choose one or both: Write contains, which takes two arguments: a list and an […]

1 186 187 188 189 190 204