CompSci 108
Fall 2010
The Software Studio

Revised Edition

In addition to the original specifications, add the following functionality to your program. These features emphasize specific design issues and are meant to help you think about what it means to "hard-code" things within your program and how to provide a interface for programmer's to access flexibility when using your program.

Specifications

Your program should recognize the following additional syntax for expressions:

expression syntax semantics examples
Assignment
var = expr
assigns an expression to a variable, if a variable name is used that has not previously been given a value, return a default value (like BLACK)
note, variables should act as references to their expressions rather than copying/evaluating them on assignment (this allows variables to correctly evaluate their contents dynamically, but it has the side-effect that changes to variables are reflected in other expressions)
a = [ 1, 0, 1 ]
bugs = a + x
Multi-Argument Functions
fun(expr,...)
a function that takes one or more expressions as its arguments
sum     // returns sum of all the given expressions together
min     // returns minimum of the given expressions based on their intensity (i.e., grey scale value)
max     // returns maximum of the given expressions based on their intensity (i.e., grey scale value)
average // returns average of all the given expressions        
sum(a, a + b, c * d / x)
min(min(sum(a, b), x+x), y)
Postfix Unary Operator
expr op
appears after an expression 
~       // convert a color to greyscale
a~
(t + a * x)~

A user can explicitly save an expression to a named variable. Such variables serve the program's memory and can be used to refer to the saved expression later in other expressions.

To make it easier to generate expressions automatically rather than typing them in manually, do at least one of the following options:

To make it possible to generate other kinds of images (rather than simply evaluating them for each pixel), do at least one of the following options:

For extra credit, make the "back-end" code more general and efficient by doing at least one of the following options: