teaching machines

CS 330 Lecture 35 – Lsystem evaluation

Agenda lexical vs. dynamic scope Perl’s scope narrowing scope in Scheme with let executing user code sandboxed evaluation side-effects in Scheme Code lsystem.ss #lang racket (require racket/sandbox) (define apply-productions-once (lambda (loa substitutions) (cond ((null? loa) ‘()) (else (append (cdr (assoc (car loa) substitutions)) (apply-productions-once (cdr loa) substitutions)))))) (define apply-productions-n-times (lambda (current substitutions n) (cond ((= […]

CS 145 Homework 4 – due before Wednesday, May 9

See the PDF.

CS 145 Lecture 23 – GUIs, Non-zero Gravity

Agenda TIOBE flip Swing GUI framework a tease of inheritance event-driven programming painting dropping circles composition collaboration graphs in SMC law #31: try local first Code DroppingCircles.java package prefinal; import javax.swing.JFrame; public class DroppingCircles { public static void main(String[] args) { JFrame frame = new JFrame(“Drop Circles”); // frame.add(new JButton(“Click me!”)); // frame.add(new JLabel(“Read me!”)); frame.add(new […]

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 […]

1 2 3