EECS 12 Summer 2006 Homework 4

General Instructions

Please place your programs in seperate files named as described in the problem. Improperly named programs will not count. Turn in your files by placing them in the dropbox. Please be mindful of the late policy.

Grading

Correct80%
Commented10%
Attempted10%

Problems

Problem 0: 25 points

Nested lists can be useful, but sometimes we just want to know all of the items in a list. Create a list flattener, which will take a nested list and turn it into a simple list.

Problem 1: 75 points

Write an interactive data analyzer. Data analysis can be a painstaking effort, and sometimes it is nice to be able to do things step by step without having to do them by hand. In this problem, we will develop a program that will allow users to analyze data with various mathematical functions step by step.

Here is an example run that uses everything at least once:

? help
even,load,square,set,help,show,+,*,list,random,range,scale,clear,store,>
Result: []
? random 5
Result: [0.0079262051586875826, 0.9649961654385576, 0.29754284663124386, 0.57334520230032837, 0.78848891112000485]
? set threshold 0.5
Result: [0.0079262051586875826, 0.9649961654385576, 0.29754284663124386, 0.57334520230032837, 0.78848891112000485]
? > 
Result: [0.9649961654385576, 0.57334520230032837, 0.78848891112000485]
? set scalar 10.0
Result: [0.9649961654385576, 0.57334520230032837, 0.78848891112000485]
? scale
Result: [9.6499616543855762, 5.7334520230032835, 7.8848891112000485]
? even
Result: []
? range 5
Result: [0, 1, 2, 3, 4]
? scale
Result: [0.0, 10.0, 20.0, 30.0, 40.0]
? set threshold 0
Result: [0.0, 10.0, 20.0, 30.0, 40.0]
? >
Result: [10.0, 20.0, 30.0, 40.0]
? *
Result: [240000.0]
? store aa
Result: [240000.0]
? range 10
Result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
? store ab
Result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
? load aa
Result: [240000.0]
? load bb
No variable bb
Result: [240000.0]
? load ab
Result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
? list
threshold: [0.0]
aa: [240000.0]
scalar: [10.0]
ab: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
? show aa
aa: [240000.0]
Result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
? clear
Variables cleared.
Result: []
? list
Result: []
? range 10
Result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
? even
Result: [0, 2, 4, 6, 8]
? +
Result: [20]
? range 10
Result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
? even
Result: [0, 2, 4, 6, 8]
? square
Result: [0, 4, 16, 36, 64]
? +
Result: [120]
? dance
Unknown operation.
? quit
Goodbye!