teaching machines

CS 330 Lecture 36 – GIMP example, macros

Agenda program this GIMP Script-Fu floodfilling example Program this Sketch out the pseudocode for implementing a paintbucket operation in an image editor. Script-Fu template Code hackbucket.scm (define floodfill (lambda (image color x y) (let ((layer (car (gimp-image-get-active-layer image))) (fill-color (cons-array 3 ‘byte))) ; check for fill != init (floodfill-helper layer (car (cdr (gimp-drawable-get-pixel layer x […]

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

CS 330 Lecture 30 – ANTLR and C++

Agenda A Cartesian grid walker language Translating calculator + functions to C++ TODO New ANTLR C++ target: http://www.antlr.org/wiki/pages/viewpage.action?pageId=29130826 ANTLR C++ REPL Code makefile all: cart CartesianLexer.cpp CartesianParser.cpp: Cartesian.g Player.h java -jar antlr-3.4-with-cpp.jar Cartesian.g cart: cart_interpreter.cpp CartesianLexer.cpp CartesianParser.cpp Player.h g++ -I include -o cart cart_interpreter.cpp CartesianLexer.cpp CartesianParser.cpp clean: rm -f CartesianLexer.cpp CartesianParser.cpp cart CartesianLexer.hpp CartesianParser.hpp Cartesian.g […]

CS 330 Lecture 29 – Garbage Collection

Agenda how does polymorphism work? Jim Blinn’s terrible approach the elegant vtable approach garbage collection programmers don’t get explicit reclamation right OS does reclaim memory when program stops what happens when… … we don’t call free? … we call free twice? … we call free once but leave pointer untouched? some approaches: mark-and-sweep stop-and-copy reference […]

CS 330 Lecture 28 – Inheritance and polymorphism

Agenda fixing our stack? oop: encapsulation polymorphism inheritance is-a vs. has-a inheritance tightly couples, destroys encapsulation modern thinking: limit inheritance, favor shallow hierarchies and has-a composition when inheritance is a good idea when refactoring a library you maintain when writing a GUI widget polymorphism: lets you write conductor code easy in dynamically-typed languages in statically-typed, […]

1 29 30 31 32 33 35