diff options
author | elioat <elioat@tilde.institute> | 2023-08-23 07:52:19 -0400 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2023-08-23 07:52:19 -0400 |
commit | 562a9a52d599d9a05f871404050968a5fd282640 (patch) | |
tree | 7d3305c1252c043bfe246ccc7deff0056aa6b5ab /js/games/nluqo.github.io/~bh/61a-pages | |
parent | 5d012c6c011a9dedf7d0a098e456206244eb5a0f (diff) | |
download | tour-562a9a52d599d9a05f871404050968a5fd282640.tar.gz |
*
Diffstat (limited to 'js/games/nluqo.github.io/~bh/61a-pages')
293 files changed, 78704 insertions, 0 deletions
diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/abstr.levels b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/abstr.levels new file mode 100644 index 0000000..ac4e3ce --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/abstr.levels @@ -0,0 +1,12 @@ +high level of abstraction + application programs + high-level language (Scheme) + low-level language (C) + assembly language + machine language + architecture (registers, memory, arithmetic unit, etc.) + circuit elements (gates) + transistors + solid-state physics + quantum mechanics +low level of abstraction diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/argue.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/argue.scm new file mode 100644 index 0000000..53dafdb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/argue.scm @@ -0,0 +1,16 @@ +(define (argue s) + (if (empty? s) + '() + (sentence (opposite (first s)) + (argue (bf s))))) + +(define (opposite w) + (cond ((equal? w 'like) 'hate) + ((equal? w 'hate) 'like) + ((equal? w 'wonderful) 'terrible) + ((equal? w 'terrible) 'wonderful) + ((equal? w 'great) 'awful) + ((equal? w 'awful) 'great) + ((equal? w 'terrific) 'yucky) + ((equal? w 'yucky) 'terrific) + (else w) )) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/buzz.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/buzz.scm new file mode 100644 index 0000000..f3d62ad --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/buzz.scm @@ -0,0 +1,4 @@ +(define (buzz n) + (cond ((equal? (remainder n 7) 0) 'buzz) + ((member? 7 n) 'buzz) + (else n))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html new file mode 100644 index 0000000..6be1532 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/?C=M;O=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="abstr.levels">abstr.levels</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">300 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="argue.scm">argue.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">440 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="buzz.scm">buzz.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 95 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">624 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="order.scm">order.scm</a> </td><td align="right">2006-09-15 17:12 </td><td align="right">6.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">203 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural.scm">plural.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">133 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural1.scm">plural1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 36 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural2.scm">plural2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 96 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=D;O=A new file mode 100644 index 0000000..aa048a8 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=D;O=A @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/?C=M;O=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="abstr.levels">abstr.levels</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">300 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="argue.scm">argue.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">440 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="buzz.scm">buzz.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 95 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">624 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="order.scm">order.scm</a> </td><td align="right">2006-09-15 17:12 </td><td align="right">6.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">203 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural.scm">plural.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">133 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural1.scm">plural1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 36 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural2.scm">plural2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 96 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=D;O=D new file mode 100644 index 0000000..769b9a1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=D;O=D @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/?C=M;O=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural2.scm">plural2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 96 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural1.scm">plural1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 36 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural.scm">plural.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">133 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">203 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="order.scm">order.scm</a> </td><td align="right">2006-09-15 17:12 </td><td align="right">6.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">624 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="buzz.scm">buzz.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 95 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="argue.scm">argue.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">440 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="abstr.levels">abstr.levels</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">300 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=N;O=A new file mode 100644 index 0000000..6be1532 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=N;O=A @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/?C=M;O=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="abstr.levels">abstr.levels</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">300 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="argue.scm">argue.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">440 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="buzz.scm">buzz.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 95 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">624 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="order.scm">order.scm</a> </td><td align="right">2006-09-15 17:12 </td><td align="right">6.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">203 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural.scm">plural.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">133 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural1.scm">plural1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 36 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural2.scm">plural2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 96 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=N;O=D new file mode 100644 index 0000000..769b9a1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=N;O=D @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/?C=M;O=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural2.scm">plural2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 96 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural1.scm">plural1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 36 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural.scm">plural.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">133 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">203 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="order.scm">order.scm</a> </td><td align="right">2006-09-15 17:12 </td><td align="right">6.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">624 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="buzz.scm">buzz.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 95 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="argue.scm">argue.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">440 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="abstr.levels">abstr.levels</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">300 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=S;O=A new file mode 100644 index 0000000..e4b5f81 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=S;O=A @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/?C=M;O=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural1.scm">plural1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 36 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="buzz.scm">buzz.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 95 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural2.scm">plural2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 96 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural.scm">plural.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">133 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">203 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="abstr.levels">abstr.levels</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">300 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="argue.scm">argue.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">440 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">624 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="order.scm">order.scm</a> </td><td align="right">2006-09-15 17:12 </td><td align="right">6.2K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=S;O=D new file mode 100644 index 0000000..a81db95 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/index.html?C=S;O=D @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/?C=M;O=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="order.scm">order.scm</a> </td><td align="right">2006-09-15 17:12 </td><td align="right">6.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.1/filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">624 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="argue.scm">argue.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">440 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="abstr.levels">abstr.levels</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">300 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">203 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural.scm">plural.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">133 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural2.scm">plural2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 96 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="buzz.scm">buzz.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 95 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="plural1.scm">plural1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 36 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/order.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/order.scm new file mode 100644 index 0000000..a0208b0 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/order.scm @@ -0,0 +1,199 @@ + +;;; Demonstration program for substitution-model evaluation +;;; complete with normal-order and applicative-order versions. +;;; For use with Section 1.1 of SICP. +;;; +;;; This file defines three special forms: DEF, APPLIC, and NORMAL. +;;; +;;; Example of use: +;;; +;;; (def (f a b) (+ (g a) b)) ; define a function +;;; (def (g x) (* 3 x)) ; another one +;;; (applic (f (+ 2 3) (- 15 6))) ; show applicative-order evaluation +;;; (normal (f (+ 2 3) (- 15 6))) ; show normal-order evaluation + +;;; In the printed results, something like +;;; (* 2 3) ==> 6 +;;; indicates the ultimate invocation of a primitive function. But +;;; (f 5 9) ----> +;;; (+ (g 5) 9) +;;; indicates the substitution of actual arguments into the body of +;;; a function defined with DEF. (Of course, whether actual argument +;;; values or actual argument expressions are substituted depends on +;;; whether you used APPLIC or NORMAL, respectively.) + +;;; Restrictions: +;;; * The operands of a combination must be numbers or combinations. +;;; (I.e., no variables, no non-numeric data.) +;;; * The operator of a combination must be a symbol that names a function. +;;; If the function was not defined by DEF, it is taken as primitive +;;; for purposes of the substitution model. +;;; * DEF only understands the short-form function definition syntax. +;;; (I.e., no lambda, no defining anything but functions.) +;;; * The body of a function defined with DEF must be exactly one expression. + +;;; A neat example: +;;; (def (zero x) (- x x)) +;;; (applic (zero (random 10))) +;;; (normal (zero (random 10))) + + +;; The DEF special form. +;; Binds the symbol to a quoted lambda expression, not a closure, since we're +;; using the substitution model. + +;(define def (procedure->macro +; (lambda (exp env) +; `(begin (define ,(caadr exp) +; '(lambda ,(cdadr exp) ,(caddr exp))) +; (set! def-names (cons ',(caadr exp) def-names)) +; ',(caadr exp))))) + +(define-macro (def form . body) + `(begin + (define ,(car form) '(lambda ,(cdr form) ,@body)) + (set! def-names (cons ',(car form) def-names)) + ',(car form))) + +;;;; (extend-syntax (def) +;;;; [(def (name . args) body) +;;;; (begin (define name '(lambda args body)) +;;;; (set! def-names (cons 'name def-names)) +;;;; 'name)]) + +;; A list of the functions defined using DEF. +;; We look in here to distinguish defined functions from primitives. + +(define def-names '()) + +;; The APPLIC special form. Expands an expression in applicative order. +;; Calls procedure applic1 to do the real work, except for some extra +;; top-level stuff to keep the return value separate from printed text. + +;(define applic (procedure->macro +; (lambda (exp env) +; `(let ((result (applic1 ',(cadr exp) ""))) +; (newline) +; result)))) + +(define-macro (applic . exp) + `(let ((result (applic1 ',(car exp) ""))) + (newline) + result)) + +;;;; (extend-syntax (applic) +;;;; [(applic thingo) +;;;; (let ((result (applic1 'thingo '||))) +;;;; (newline) +;;;; result)]) + +;; The second argument to applic1 is a word of (initially zero) spaces +;; used to indent the printing of the expansion of subexpressions. + +(define (applic1 form spaces) + (if (not (pair? form)) + form + (begin + (newline) + (display spaces) + (display form) + (cond ((and (not (memq (car form) def-names)) + (all-numbers? (cdr form))) + (display " ==> ") + (let ((ans (eval form))) + (display ans) + ans)) + (else + (let ((new-form (subapplic (list (car form)) + (cdr form) + (word spaces " ") ))) + (if (and (memq (car form) def-names) + (not (all-numbers? (cdr form))) ) + (begin (newline) (display spaces) (display new-form)) ) + (cond ((memq (car form) def-names) + (display " ----> ") + (applic1 (subst (eval (car form)) (cdr new-form)) + spaces)) + ((equal? (car form) 'quote) (cadr form)) + (else (applic1 new-form spaces)) ))))))) + +(define (all-numbers? l) + (cond ((null? l) #t) + ((not (or (number? (car l)) (boolean? (car l)))) #f) + (else (all-numbers? (cdr l))) )) + +;; subapplic maps applic1 over the operands, left-to-right. + +(define (subapplic done todo spaces) + (if (null? todo) + (reverse done) + (let ((result (applic1 (car todo) spaces))) + (subapplic (cons result done) (cdr todo) spaces) ))) + +;; subst takes a lambda expression and an actual argument list, and +;; returns the body with substitutions of args for formal parameters. + +(define (subst proc args) + (subst-in-body (caddr proc) (cadr proc) args)) + +(define (subst-in-body form params args) + (cond ((null? form) '()) + ((not (pair? form)) (lookup form params args)) + (else (cons (subst-in-body (car form) params args) + (subst-in-body (cdr form) params args) )))) + +(define (lookup form params args) + (cond ((null? params) form) + ((eq? form (car params)) (car args)) + (else (lookup form (cdr params) (cdr args))) )) + +;; The NORMAL special form. Everything below here is analogous to the +;; corresponding piece of APPLIC, but the logic of normal1 is different. + +;(define normal (procedure->macro +; (lambda (exp env) +; `(let ((result (normal1 ',(cadr exp) ""))) +; (newline) +; result)))) + +(define-macro (normal . exp) + `(let ((result (normal1 ',(car exp) ""))) + (newline) + result)) + +;;;; (extend-syntax (normal) +;;;; [(normal thingo) +;;;; (let ((result (normal1 'thingo ""))) +;;;; (newline) +;;;; result)]) + +(define (normal1 form spaces) + (if (not (pair? form)) + form + (begin + (newline) + (display spaces) + (display form) + (cond ((and (not (memq (car form) def-names)) + (all-numbers? (cdr form))) + (display " ==> ") + (let ((ans (eval form))) + (display ans) + ans)) + ((memq (car form) def-names) + (display " ----> ") + (normal1 (subst (eval (car form)) (cdr form)) + spaces)) + ((equal? (car form) 'quote) (cadr form)) + (else + (let ((new-form (subnormal (list (car form)) + (cdr form) + (word spaces " ") ))) + (normal1 new-form spaces) )))))) + +(define (subnormal done todo spaces) + (if (null? todo) + (reverse done) + (let ((result (normal1 (car todo) spaces))) + (subnormal (cons result done) (cdr todo) spaces) ))) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/pigl.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/pigl.scm new file mode 100644 index 0000000..7957fc8 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/pigl.scm @@ -0,0 +1,10 @@ +(define (pigl wd) + (if (pl-done? wd) + (word wd 'ay) + (pigl (word (bf wd) (first wd))))) + +(define (pl-done? wd) + (vowel? (first wd))) + +(define (vowel? letter) + (member? letter '(a e i o u))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/plural.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/plural.scm new file mode 100644 index 0000000..0538d4a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/plural.scm @@ -0,0 +1,8 @@ +(define (plural wd) + (word wd 's)) + +(define (plural wd) + (if (equal? (last wd) 'y) + (word (bl wd) 'ies) + (word wd 's))) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/plural1.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/plural1.scm new file mode 100644 index 0000000..982f79f --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/plural1.scm @@ -0,0 +1,2 @@ +(define (plural wd) + (word wd 's)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/plural2.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/plural2.scm new file mode 100644 index 0000000..3c5ddd3 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.1/plural2.scm @@ -0,0 +1,5 @@ +(define (plural wd) + (if (equal? (last wd) 'y) + (word (bl wd) 'ies) + (word wd 's))) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/bentley b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/bentley new file mode 100644 index 0000000..6e2781e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/bentley @@ -0,0 +1,16 @@ + t1(N) = 3.0 N^3 t2(N) = 19,500,000 N + + N CRAY-1 Fortran TRS-80 Basic + + 10 3.0 microsec 200 millisec + 100 3.0 millisec 2.0 sec + 1000 3.0 sec 20 sec + 10000 49 min 3.2 min + 100000 35 days 32 min + 1000000 95 yrs 5.4 hrs + + + + + from _Programming_Pearls_ + by Jon Bentley (Addison-Wesley, 1986) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/count.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/count.scm new file mode 100644 index 0000000..567e255 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/count.scm @@ -0,0 +1,12 @@ + +(define (count sent) + (if (empty? sent) + 0 + (+ 1 (count (bf sent))) )) + +(define (count sent) + (define (iter wds result) + (if (empty? wds) + result + (iter (bf wds) (+ 1 result)) )) + (iter sent 0) ) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/growth.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/growth.scm new file mode 100644 index 0000000..7ef9fe8 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/growth.scm @@ -0,0 +1,19 @@ +(define (square x) (* x x)) + +(define (squares sent) + (if (empty? sent) + '() + (se (square (first sent)) + (squares (bf sent)) ))) + + +(define (sort sent) + (if (empty? sent) + '() + (insert (first sent) + (sort (bf sent)) ))) + +(define (insert num sent) + (cond ((empty? sent) (se num)) + ((< num (first sent)) (se num sent)) + (else (se (first sent) (insert num (bf sent)))) )) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html new file mode 100644 index 0000000..a711eff --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.2/?C=N;O=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bentley">bentley</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">324 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">227 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="growth.scm">growth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">398 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.2/pascal.scm">pascal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">537 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=D;O=A new file mode 100644 index 0000000..f9e8f3d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=D;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bentley">bentley</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">324 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">227 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="growth.scm">growth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">398 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.2/pascal.scm">pascal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">537 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=D;O=D new file mode 100644 index 0000000..1907dd3 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=D;O=D @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.2/pascal.scm">pascal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">537 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="growth.scm">growth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">398 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">227 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bentley">bentley</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">324 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=M;O=A new file mode 100644 index 0000000..bd30538 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=M;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bentley">bentley</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">324 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">227 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="growth.scm">growth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">398 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.2/pascal.scm">pascal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">537 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=M;O=D new file mode 100644 index 0000000..1907dd3 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=M;O=D @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.2/pascal.scm">pascal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">537 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="growth.scm">growth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">398 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">227 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bentley">bentley</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">324 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=N;O=A new file mode 100644 index 0000000..a711eff --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=N;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.2/?C=N;O=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bentley">bentley</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">324 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">227 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="growth.scm">growth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">398 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.2/pascal.scm">pascal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">537 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=S;O=A new file mode 100644 index 0000000..827c155 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.2/index.html?C=S;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.2/?C=S;O=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">227 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bentley">bentley</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">324 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="growth.scm">growth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">398 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.2/pascal.scm">pascal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">537 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/filter.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/filter.scm new file mode 100644 index 0000000..8df22b0 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/filter.scm @@ -0,0 +1,23 @@ +;;;;; cs60a/lectures/1.3/filter.scm +(define (evens nums) + (cond ((empty? nums) '()) + ((= (remainder (first nums) 2) 0) + (se (first nums) (evens (bf nums))) ) + (else (evens (bf nums))) )) + +(define (ewords sent) + (cond ((empty? sent) '()) + ((member? 'e (first sent)) + (se (first sent) (ewords (bf sent))) ) + (else (ewords (bf sent))) )) + +(define (pronouns sent) + (cond ((empty? sent) '()) + ((member? (first sent) '(I me you he she it him her we us they them)) + (se (first sent) (pronouns (bf sent))) ) + (else (pronouns (bf sent))) )) + +(define (filter pred sent) + (cond((empty? sent) '()) + ((pred (first sent))(se (first sent)(filter pred (bf sent)))) + (else (filter pred (bf sent))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html new file mode 100644 index 0000000..066ad39 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.3</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.3</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">788 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.3/general.scm">general.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">545 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="keep.scm">keep.scm</a> </td><td align="right">2001-08-13 16:27 </td><td align="right">780 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="roots.scm">roots.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">970 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sum.scm">sum.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">321 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=D;O=A new file mode 100644 index 0000000..4e80c90 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=D;O=A @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.3</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.3</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">788 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.3/general.scm">general.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">545 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="keep.scm">keep.scm</a> </td><td align="right">2001-08-13 16:27 </td><td align="right">780 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="roots.scm">roots.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">970 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sum.scm">sum.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">321 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=D;O=D new file mode 100644 index 0000000..774ccf1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=D;O=D @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.3</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.3</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sum.scm">sum.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">321 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="roots.scm">roots.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">970 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="keep.scm">keep.scm</a> </td><td align="right">2001-08-13 16:27 </td><td align="right">780 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.3/general.scm">general.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">545 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">788 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=M;O=A new file mode 100644 index 0000000..6015499 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=M;O=A @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.3</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.3</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="roots.scm">roots.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">970 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sum.scm">sum.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">321 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">788 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.3/general.scm">general.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">545 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="keep.scm">keep.scm</a> </td><td align="right">2001-08-13 16:27 </td><td align="right">780 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=M;O=D new file mode 100644 index 0000000..a582ac1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=M;O=D @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.3</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.3</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="keep.scm">keep.scm</a> </td><td align="right">2001-08-13 16:27 </td><td align="right">780 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.3/general.scm">general.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">545 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">788 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sum.scm">sum.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">321 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="roots.scm">roots.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">970 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=N;O=A new file mode 100644 index 0000000..066ad39 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=N;O=A @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.3</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.3</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">788 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.3/general.scm">general.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">545 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="keep.scm">keep.scm</a> </td><td align="right">2001-08-13 16:27 </td><td align="right">780 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="roots.scm">roots.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">970 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sum.scm">sum.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">321 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=N;O=D new file mode 100644 index 0000000..774ccf1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=N;O=D @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.3</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.3</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sum.scm">sum.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">321 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="roots.scm">roots.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">970 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="keep.scm">keep.scm</a> </td><td align="right">2001-08-13 16:27 </td><td align="right">780 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.3/general.scm">general.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">545 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">788 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=S;O=A new file mode 100644 index 0000000..56f6324 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=S;O=A @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.3</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.3</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sum.scm">sum.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">321 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.3/general.scm">general.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">545 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="keep.scm">keep.scm</a> </td><td align="right">2001-08-13 16:27 </td><td align="right">780 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">788 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="roots.scm">roots.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">970 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=S;O=D new file mode 100644 index 0000000..6d7fa4e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/index.html?C=S;O=D @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/1.3</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/1.3</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="roots.scm">roots.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">970 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="filter.scm">filter.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">788 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="keep.scm">keep.scm</a> </td><td align="right">2001-08-13 16:27 </td><td align="right">780 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/1.3/general.scm">general.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">545 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sum.scm">sum.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">321 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/keep.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/keep.scm new file mode 100644 index 0000000..be83967 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/keep.scm @@ -0,0 +1,23 @@ +;;;;; cs60a/lectures/1.3/keep.scm +(define (evens nums) + (cond ((empty? nums) '()) + ((= (remainder (first nums) 2) 0) + (se (first nums) (evens (bf nums))) ) + (else (evens (bf nums))) )) + +(define (ewords sent) + (cond ((empty? sent) '()) + ((member? 'e (first sent)) + (se (first sent) (ewords (bf sent))) ) + (else (ewords (bf sent))) )) + +(define (pronouns sent) + (cond ((empty? sent) '()) + ((member? (first sent) '(I me you he she it him her we us they them)) + (se (first sent) (pronouns (bf sent))) ) + (else (pronouns (bf sent))) )) + +(define (keep pred sent) + (cond((empty? sent) '()) + ((pred (first sent))(se (first sent)(keep pred (bf sent)))) + (else (keep pred (bf sent))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/roots.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/roots.scm new file mode 100644 index 0000000..079a8b5 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/roots.scm @@ -0,0 +1,47 @@ +;;; Note: all versions work only for quadratics with real roots + +;;; Straightforward but slow way: + +(define (roots a b c) + (se (/ (+ (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a)) + (/ (- (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a)) )) + + +;;; Using a subprocedure to eliminate the repeated computation: + +(define (roots a b c) + (define (roots1 d) + (se (/ (+ (- b) d) (* 2 a)) + (/ (- (- b) d) (* 2 a)) )) + (roots1 (sqrt (- (* b b) (* 4 a c)))) ) + + +;;; Using lambda to avoid naming the subprocedure: + +(define (roots a b c) + ((lambda (d) + (se (/ (+ (- b) d) (* 2 a)) + (/ (- (- b) d) (* 2 a)) )) + (sqrt (- (* b b) (* 4 a c))) )) + + +;;; Using let to rearrange the above: + +(define (roots a b c) + (let ((d (sqrt (- (* b b) (* 4 a c))))) + (se (/ (+ (- b) d) (* 2 a)) + (/ (- (- b) d) (* 2 a)) ))) + + + +;;; More optimization: + +(define (roots a b c) + (let ((d (sqrt (- (* b b) (* 4 a c)))) + (-b (- b)) + (2a (* 2 a))) + (se (/ (+ -b d) 2a) + (/ (- -b d) 2a) ))) + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/sum.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/sum.scm new file mode 100644 index 0000000..db618e4 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/sum.scm @@ -0,0 +1,20 @@ +(define (sumsquare a b) + (if (> a b) + 0 + (+ (* a a) (sumsquare (+ a 1) b)) )) + +(define (sumcube a b) + (if (> a b) + 0 + (+ (* a a a) (sumcube (+ a 1) b)) )) + +(define (sum fn a b) + (if (> a b) + 0 + (+ (fn a) (sum fn (+ a 1) b)))) + +(define (square x) + (* x x)) + +(define (cube x) + (* x x x)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/calc.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/calc.scm new file mode 100644 index 0000000..7d667dd --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/calc.scm @@ -0,0 +1,29 @@ +;; Scheme calculator -- evaluate simple expressions + +; The read-eval-print loop: + +(define (calc) + (display "calc: ") + (flush) + (print (calc-eval (read))) + (calc)) + +; Evaluate an expression: + +(define (calc-eval exp) + (cond ((number? exp) exp) + ((list? exp) (calc-apply (car exp) (map calc-eval (cdr exp)))) + (else (error "Calc: bad expression:" exp)))) + +; Apply a function to arguments: + +(define (calc-apply fn args) + (cond ((eq? fn '+) (accumulate + 0 args)) + ((eq? fn '-) (cond ((null? args) (error "Calc: no args to -")) + ((= (length args) 1) (- (car args))) + (else (- (car args) (accumulate + 0 (cdr args)))))) + ((eq? fn '*) (accumulate * 1 args)) + ((eq? fn '/) (cond ((null? args) (error "Calc: no args to /")) + ((= (length args) 1) (/ (car args))) + (else (/ (car args) (accumulate * 1 (cdr args)))))) + (else (error "Calc: bad operator:" fn)))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/cons.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/cons.scm new file mode 100644 index 0000000..300027e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/cons.scm @@ -0,0 +1,17 @@ +; implementation of pairs as functions + +(define (cons x y) + (lambda (which) + (cond ((equal? which 'car) x) + ((equal? which 'cdr) y) + (else (error "Bad message to CONS" which)) ))) + + +(define (car pair) + (pair 'car)) + +(define (cdr pair) + (pair 'cdr)) + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html new file mode 100644 index 0000000..7d89b1f --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.1/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2006-05-15 11:28 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="cons.scm">cons.scm</a> </td><td align="right">2006-02-13 20:59 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce.scm">mapreduce.scm</a> </td><td align="right">2007-09-26 15:59 </td><td align="right">6.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="total.scm">total.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=D;O=A new file mode 100644 index 0000000..585d38a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=D;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.1/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2006-05-15 11:28 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="cons.scm">cons.scm</a> </td><td align="right">2006-02-13 20:59 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce.scm">mapreduce.scm</a> </td><td align="right">2007-09-26 15:59 </td><td align="right">6.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="total.scm">total.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=D;O=D new file mode 100644 index 0000000..9c410a4 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=D;O=D @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.1/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="total.scm">total.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce.scm">mapreduce.scm</a> </td><td align="right">2007-09-26 15:59 </td><td align="right">6.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="cons.scm">cons.scm</a> </td><td align="right">2006-02-13 20:59 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2006-05-15 11:28 </td><td align="right">875 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=M;O=A new file mode 100644 index 0000000..c165a68 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=M;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.1/?C=M;O=D">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.1/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="total.scm">total.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="cons.scm">cons.scm</a> </td><td align="right">2006-02-13 20:59 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2006-05-15 11:28 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce.scm">mapreduce.scm</a> </td><td align="right">2007-09-26 15:59 </td><td align="right">6.1K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=N;O=A new file mode 100644 index 0000000..7d89b1f --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=N;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.1/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2006-05-15 11:28 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="cons.scm">cons.scm</a> </td><td align="right">2006-02-13 20:59 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce.scm">mapreduce.scm</a> </td><td align="right">2007-09-26 15:59 </td><td align="right">6.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="total.scm">total.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=N;O=D new file mode 100644 index 0000000..9c410a4 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/index.html?C=N;O=D @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.1</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.1</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.1/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="total.scm">total.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce.scm">mapreduce.scm</a> </td><td align="right">2007-09-26 15:59 </td><td align="right">6.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="cons.scm">cons.scm</a> </td><td align="right">2006-02-13 20:59 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2006-05-15 11:28 </td><td align="right">875 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/mapreduce.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/mapreduce.scm new file mode 100644 index 0000000..98c5c47 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/mapreduce.scm @@ -0,0 +1,201 @@ +;;; Non-parallel pseudo-mapreduce + +; Here's what it ISN'T (but sort of is conceptually): +; +; (define (mapreduce mapper reducer base-case data) +; (accumulate reducer base-case (map mapper data))) + +;; key-value pair ADT + +(define make-kv-pair cons) +(define kv-key car) +(define kv-value cdr) + +;; Reminder: an association list (a-list) is a list of key-value pairs. + +; So the parallel version has THREE phases, not just the two in its name: + +(define (mapreduce mapper reducer base-case data) ; handwavy approximation + (GROUPREDUCE reducer base-case + (SORT-INTO-BUCKETS (MAP mapper data)))) + +;; Instead of one call to MAPREDUCE, we separate out the stages, using +;; plain old MAP and the following GROUPREDUCE: + +(define (groupreduce reducer base-case buckets) + (map (lambda (subset) + (make-kv-pair + (kv-key (car subset)) + (accumulate reducer base-case (map kv-value subset)))) + buckets)) + +; (Note: Sort-into-buckets is too messy for lecture, but straightforward.) + +;; Example 1: add grades per student. + +; The data. In a parallel implementation, each midterm would be handled by +; a separate processor; we'll just concatenate them. + +(define mt1 '((cs61a-xc . 27) (cs61a-ya . 40) (cs61a-xw . 35) + (cs61a-xd . 38) (cs61a-yb . 29) (cs61a-xf . 32))) +(define mt2 '((cs61a-yc . 32) (cs61a-xc . 25) (cs61a-xb . 40) + (cs61a-xw . 27) (cs61a-yb . 30) (cs61a-ya . 40))) +(define mt3 '((cs61a-xb . 32) (cs61a-xk . 34) (cs61a-yb . 30) + (cs61a-ya . 40) (cs61a-xc . 28) (cs61a-xf . 33))) + +; >> (sort-into-buckets (append mt1 mt2 mt3)) +; >> (groupreduce + 0 (sort-into-buckets (append mt1 mt2 mt3))) +; >> (groupreduce (lambda (new old) (+ 1 old)) 0 +; (sort-into-buckets (append mt1 mt2 mt3))) + +;; Example 2: word frequency count. + +; First just for one sentence: + +(define (wordcounts1 sent) + (groupreduce + 0 (sort-into-buckets (map (lambda (wd) (make-kv-pair wd 1)) + sent)))) + +; >> (wordcounts1 '(cry baby cry)) + +; Now for simulated files. + +;; pseudo-file ADT + +(define filename car) +(define lines cdr) + +;; Some data (yeah, I left out some songs) + +(define file1 '((please please me) (i saw her standing there) (misery) + (anna go to him) (chains) (boys) (ask me why) + (please please me) (love me do) (ps i love you) + (baby its you) (do you want to know a secret))) +(define file2 '((with the beatles) (it wont be long) (all ive got to do) + (all my loving) (dont bother me) (little child) + (till there was you) (roll over beethoven) (hold me tight) + (you really got a hold on me) (i wanna be your man) + (not a second time))) +(define file3 '((a hard days night) (a hard days night) + (i should have known better) (if i fell) + (im happy just to dance with you) (and i love her) + (tell me why) (cant buy me love) (any time at all) + (ill cry instead) (things we said today) (when i get home) + (you cant do that) (ill be back))) + +;; Mapreduce presents files to us in the form of key-value pairs in which the +;; key is the filename and the value is one line, as a sentence. Here we +;; simulate that: + +(define (file->linelist file) + (map (lambda (line) (make-kv-pair (filename file) line)) + (lines file))) + +; >> (file->linelist file1) + +(define (wordcounts files) + (groupreduce + 0 (sort-into-buckets + (flatmap (lambda (kv-pair) + (map (lambda (wd) (make-kv-pair wd 1)) + (kv-value kv-pair))) + files)))) + +; >> (wordcounts (append (file->linelist file1) +; (file->linelist file2) +; (file->linelist file3))) + +(define (mostfreq files) + (accumulate (lambda (new old) + (cond ((> (kv-value new) (kv-value (car old))) + (list new)) + ((= (kv-value new) (kv-value (car old))) + (cons new old)) ; In case of tie, remember both. + (else old))) + (list (make-kv-pair 'foo 0)) ; Starting value. + (groupreduce + 0 (sort-into-buckets + (flatmap (lambda (kv-pair) + (map (lambda (wd) + (make-kv-pair wd 1)) + (kv-value kv-pair))) + files))))) + +; >> (mostfreq (append (file->linelist file1) +; (file->linelist file2) +; (file->linelist file3))) + + +;; Example 3: Searching for a pattern. + +; >> (match? '(* i * her *) '(i saw her standing there)) +; >> (match? '(* i * her *) '(and i love her)) +; >> (match? '(* i * her *) '(ps i love you)) + +(define (grep pattern files) + (groupreduce cons '() + (sort-into-buckets + (flatmap (lambda (kv-pair) + (if (match? pattern (kv-value kv-pair)) + (list kv-pair) + '())) + files)))) + +; >> (grep '(* i * her *) (append (file->linelist file1) +; (file->linelist file2) +; (file->linelist file3))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Don't read this part, just take it on faith. + +(define (sort-into-buckets alist) + (group (sort-by-key alist))) + +(define (group alist) + (define (help in complete current) + (cond ((null? in) + (reverse (cons (reverse current) complete))) + ((null? current) + (help (cdr in) complete (cons (car in) current))) + ((equal? (kv-key (car in)) (kv-key (car current))) + (help (cdr in) complete (cons (car in) current))) + (else + (help in (cons current complete) '())))) + (if (null? alist) + '() + (help alist '() '()))) + +(define (sort-by-key alist) + (define (keyinsert pair alist) + (cond ((null? alist) (list pair)) + ((bef? (kv-key pair) (kv-key (car alist))) + (cons pair alist)) + ((equal? (kv-key pair) (kv-key (car alist))) + (cons pair alist)) + (else (cons (car alist) (keyinsert pair (cdr alist)))))) + (if (null? alist) + '() + (keyinsert (car alist) (sort-by-key (cdr alist))))) + +(define (bef? a b) ; word or sentence version of BEFORE? + (cond ((word? a) (bef? (se a) b)) + ((word? b) (bef? a (se b))) + ((empty? a) (not (empty? b))) + ((empty? b) #f) + ((before? (first a) (first b)) #t) + ((equal? (first a) (first b)) + (bef? (bf a) (bf b))) + (else #f))) + + + +(define (match? pattern text) + (cond ((null? pattern) (null? text)) + ((null? text) + (and (equal? (car pattern) '*) + (match? (cdr pattern) text))) + ((equal? (car pattern) '*) + (or (match? (cdr pattern) text) + (match? pattern (cdr text)))) + ((equal? (car pattern) (car text)) + (match? (cdr pattern) (cdr text))) + (else #f))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/total.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/total.scm new file mode 100644 index 0000000..2cf3505 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/total.scm @@ -0,0 +1,60 @@ +; first version -- no data abstraction + +(define (total-hand hand) + (if (empty? hand) + 0 + (+ (butlast (last hand)) + (total-hand (butlast hand)) ))) + + +(total-hand '(3h 10c 4d)) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; second version -- add selectors + +(define (total-hand hand) + (if (empty? hand) + 0 + (+ (card-rank (one-card hand)) + (total-hand (remaining-cards hand)) ))) + +(define card-rank butlast) +(define card-suit last) + +(define one-card last) +(define remaining-cards butlast) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; third version -- add constructors + +(define (make-card rank suit) + (word rank (first suit)) ) + +(define make-hand se) + + +(total-hand (make-hand (make-card 3 'heart) + (make-card 10 'club) + (make-card 4 'diamond) )) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; fourth version -- change implementation + +(define (make-card rank suit) + (cond ((equal? suit 'heart) rank) + ((equal? suit 'spade) (+ rank 13)) + ((equal? suit 'diamond) (+ rank 26)) + ((equal? suit 'club) (+ rank 39)) + (else (error "say what?")) )) + +(define (card-rank card) + (remainder card 13)) + +(define (card-suit card) + (nth (quotient card 13) '(heart spade diamond club))) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/bst.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/bst.scm new file mode 100644 index 0000000..3afbf77 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/bst.scm @@ -0,0 +1,24 @@ +;;; bst.scm -- Binary Search Trees (A & S section 2.2.5) +;;; + +(define (entry tree) (car tree)) +(define (left-branch tree) (cadr tree)) +(define (right-branch tree) (caddr tree)) +(define (make-tree entry left right) + (list entry left right)) + +(define tree1 + (make-tree 7 + (make-tree 3 + (make-tree 1 '() '()) + (make-tree 5 '() '())) + (make-tree 9 '() (make-tree 11 '() '())))) + +(define (element-of-set? x set) + (cond + ((null? set) #f) + ((= x (entry set)) #t) + ((< x (entry set)) + (element-of-set? x (left-branch set))) + ((> x (entry set)) + (element-of-set? x (right-branch set))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/bst2.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/bst2.scm new file mode 100644 index 0000000..242b6f2 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/bst2.scm @@ -0,0 +1,24 @@ +;;; bst.scm -- Binary Search Trees (A & S section 2.2.5) +;;; + +(define (entry tree) (cadr tree)) +(define (left-branch tree) (caddr tree)) +(define (right-branch tree) (cadddr tree)) +(define (make-tree entry left right) + (list 'bintree entry left right)) + +(define tree1 + (make-tree 7 + (make-tree 3 + (make-tree 1 '() '()) + (make-tree 5 '() '())) + (make-tree 9 '() (make-tree 11 '() '())))) + +(define (element-of-set? x set) + (cond + ((null? set) #f) + ((= x (entry set)) #t) + ((< x (entry set)) + (element-of-set? x (left-branch set))) + ((> x (entry set)) + (element-of-set? x (right-branch set))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html new file mode 100644 index 0000000..9cf2a12 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/?C=N;O=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">604 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst2.scm">bst2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">616 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/music.scm">music.scm</a> </td><td align="right">2006-10-02 19:45 </td><td align="right">833 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="print.scm">print.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">485 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="search.scm">search.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">333 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sentence.scm">sentence.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">161 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="squares.scm">squares.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tdisp.scm">tdisp.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tiny.scm">tiny.scm</a> </td><td align="right">2007-10-01 15:45 </td><td align="right">453 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree.scm">tree.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">828 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree1.scm">tree1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">520 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree2.scm">tree2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">882 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree3.scm">tree3.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">157 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree11.scm">tree11.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">235 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tree22.scm">tree22.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">122 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="world.scm">world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=D;O=A new file mode 100644 index 0000000..9c02e75 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=D;O=A @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">604 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst2.scm">bst2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">616 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/music.scm">music.scm</a> </td><td align="right">2006-10-02 19:45 </td><td align="right">833 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="print.scm">print.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">485 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="search.scm">search.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">333 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sentence.scm">sentence.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">161 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="squares.scm">squares.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tdisp.scm">tdisp.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tiny.scm">tiny.scm</a> </td><td align="right">2007-10-01 15:45 </td><td align="right">453 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree.scm">tree.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">828 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree1.scm">tree1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">520 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree2.scm">tree2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">882 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree3.scm">tree3.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">157 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree11.scm">tree11.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">235 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tree22.scm">tree22.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">122 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="world.scm">world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=D;O=D new file mode 100644 index 0000000..38682aa --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=D;O=D @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="world.scm">world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tree22.scm">tree22.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">122 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree11.scm">tree11.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">235 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree3.scm">tree3.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">157 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree2.scm">tree2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">882 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree1.scm">tree1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">520 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree.scm">tree.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">828 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tiny.scm">tiny.scm</a> </td><td align="right">2007-10-01 15:45 </td><td align="right">453 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tdisp.scm">tdisp.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="squares.scm">squares.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sentence.scm">sentence.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">161 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="search.scm">search.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">333 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="print.scm">print.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">485 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/music.scm">music.scm</a> </td><td align="right">2006-10-02 19:45 </td><td align="right">833 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst2.scm">bst2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">616 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">604 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=M;O=A new file mode 100644 index 0000000..5ea5379 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=M;O=A @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">604 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst2.scm">bst2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">616 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="search.scm">search.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">333 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sentence.scm">sentence.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">161 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="squares.scm">squares.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tdisp.scm">tdisp.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree.scm">tree.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">828 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree1.scm">tree1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">520 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree2.scm">tree2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">882 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="world.scm">world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/music.scm">music.scm</a> </td><td align="right">2006-10-02 19:45 </td><td align="right">833 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="print.scm">print.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">485 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree3.scm">tree3.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">157 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree11.scm">tree11.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">235 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tree22.scm">tree22.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">122 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tiny.scm">tiny.scm</a> </td><td align="right">2007-10-01 15:45 </td><td align="right">453 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=M;O=D new file mode 100644 index 0000000..6aebf3b --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=M;O=D @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tiny.scm">tiny.scm</a> </td><td align="right">2007-10-01 15:45 </td><td align="right">453 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tree22.scm">tree22.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">122 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree11.scm">tree11.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">235 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree3.scm">tree3.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">157 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="print.scm">print.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">485 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/music.scm">music.scm</a> </td><td align="right">2006-10-02 19:45 </td><td align="right">833 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="world.scm">world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree2.scm">tree2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">882 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree1.scm">tree1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">520 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree.scm">tree.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">828 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tdisp.scm">tdisp.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="squares.scm">squares.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sentence.scm">sentence.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">161 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="search.scm">search.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">333 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst2.scm">bst2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">616 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">604 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=N;O=A new file mode 100644 index 0000000..9cf2a12 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=N;O=A @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/?C=N;O=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">604 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst2.scm">bst2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">616 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/music.scm">music.scm</a> </td><td align="right">2006-10-02 19:45 </td><td align="right">833 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="print.scm">print.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">485 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="search.scm">search.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">333 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sentence.scm">sentence.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">161 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="squares.scm">squares.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tdisp.scm">tdisp.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tiny.scm">tiny.scm</a> </td><td align="right">2007-10-01 15:45 </td><td align="right">453 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree.scm">tree.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">828 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree1.scm">tree1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">520 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree2.scm">tree2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">882 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree3.scm">tree3.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">157 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree11.scm">tree11.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">235 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tree22.scm">tree22.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">122 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="world.scm">world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=S;O=A new file mode 100644 index 0000000..2e4104a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=S;O=A @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tree22.scm">tree22.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">122 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree3.scm">tree3.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">157 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sentence.scm">sentence.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">161 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree11.scm">tree11.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">235 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="search.scm">search.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">333 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tiny.scm">tiny.scm</a> </td><td align="right">2007-10-01 15:45 </td><td align="right">453 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="print.scm">print.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">485 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree1.scm">tree1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">520 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">604 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst2.scm">bst2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">616 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree.scm">tree.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">828 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/music.scm">music.scm</a> </td><td align="right">2006-10-02 19:45 </td><td align="right">833 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree2.scm">tree2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">882 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="world.scm">world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tdisp.scm">tdisp.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="squares.scm">squares.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=S;O=D new file mode 100644 index 0000000..d98d7cb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/index.html?C=S;O=D @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="squares.scm">squares.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tdisp.scm">tdisp.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="world.scm">world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree2.scm">tree2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">882 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/music.scm">music.scm</a> </td><td align="right">2006-10-02 19:45 </td><td align="right">833 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree.scm">tree.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">828 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst2.scm">bst2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">616 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">604 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree1.scm">tree1.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">520 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="print.scm">print.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">485 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tiny.scm">tiny.scm</a> </td><td align="right">2007-10-01 15:45 </td><td align="right">453 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="search.scm">search.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">333 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree11.scm">tree11.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">235 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sentence.scm">sentence.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">161 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tree3.scm">tree3.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">157 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.2/tree22.scm">tree22.scm</a> </td><td align="right">2007-02-23 14:26 </td><td align="right">122 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/print.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/print.scm new file mode 100644 index 0000000..23674a7 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/print.scm @@ -0,0 +1,17 @@ +(define (pre-order tree) + (cond ((null? tree) '()) + (else (print (entry tree)) + (pre-order (left-branch tree)) + (pre-order (right-branch tree)) ))) + +(define (in-order tree) + (cond ((null? tree) '()) + (else (in-order (left-branch tree)) + (print (entry tree)) + (in-order (right-branch tree)) ))) + +(define (post-order tree) + (cond ((null? tree) '()) + (else (post-order (left-branch tree)) + (post-order (right-branch tree)) + (print (entry tree)) ))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/search.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/search.scm new file mode 100644 index 0000000..fa1d291 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/search.scm @@ -0,0 +1,13 @@ +(define (depth-first-search tree) + (print (datum tree)) + (for-each depth-first-search (children tree))) + +(define (breadth-first-search tree) + (bfs-iter (list tree))) + +(define (bfs-iter queue) + (if (null? queue) + 'done + (let ((task (car queue))) + (print (datum task)) + (bfs-iter (append (cdr queue) (children task)))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/sentence.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/sentence.scm new file mode 100644 index 0000000..1f32cc6 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/sentence.scm @@ -0,0 +1,10 @@ +(define (se a b) + (cond ((word? a) (se (list a) b)) + ((word? b) (se a (list b))) + (else (append a b)) )) + +(define (word? x) + (or (symbol? x) (number? x)) ) + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/squares.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/squares.scm new file mode 100644 index 0000000..0209b57 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/squares.scm @@ -0,0 +1,52 @@ +;; Tree ADT. +;; +;; Representation: a tree is a pair, whose car is the datum and whose +;; cdr is a list of the subtrees. + +(define make-tree cons) +(define datum car) +(define children cdr) +(define empty-tree? null?) +(define (leaf? tree) + (null? (children tree))) + +;; Example tree, using ADT, with data at nodes. + +(define t1 (make-tree 6 + (list (make-tree 2 + (list (make-tree 1 '()) + (make-tree 4 '()))) + (make-tree 9 + (list (make-tree 7 '()) + (make-tree 12 '())))))) + +;; review -- mapping over a sequence. + +(define (SQUARES seq) + (if (null? seq) + '() + (cons (SQUARE (car seq)) + (SQUARES (cdr seq)) ))) + +;; Mapping over a tree -- data at all nodes + +(define (SQUARES tree) + (make-tree (SQUARE (datum tree)) + (map SQUARES (children tree)) )) + +;; mapping over tree -- data at leaves only + +(define (SQUARES tree) + (cond ((empty-tree? tree) '()) + ((leaf? tree) (make-tree (SQUARE (datum tree)) '())) + (else (make-tree '() (map SQUARES (children tree)))) )) + +;; Common alternative for mapping data at leaves only, no explicit ADT: + +(define (SQUARES tree) + (cond ((null? tree) '()) + ((not (pair? tree)) (SQUARE tree)) + (else (cons (SQUARES (car tree)) + (SQUARES (cdr tree)) )) )) + +;; Hallmark of tree recursion: recur for both car and cdr. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tdisp.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tdisp.scm new file mode 100644 index 0000000..3811895 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tdisp.scm @@ -0,0 +1,44 @@ +;;; display of tree nodes +;;; that look like (bintree value left right) + +(define spacebox (make-string-box " " )) + +(define (make-bintree-box e) + ;; make a box for e = (bintree val x y) + (let* ((val (form-box (cadr e))) + (subtrees + (make-hbox spacebox (map form-box (cddr e)) emptybox emptybox))) + (make-box (box-width subtrees) + (box-height val) ; new centerline + (append (pad-lines-ctr (- (box-width subtrees) (box-width val)) + (box-lines val)) + (box-lines subtrees))))) + +(put 'bintree 'box-formatter make-bintree-box) + + +;;; bst.scm -- Binary Search Trees (A & S section 2.2.5) modified to have +;;; header "bintree" +;;; + +(define (entry tree) (cadr tree)) +(define (left-branch tree) (caddr tree)) +(define (right-branch tree) (cadddr tree)) +(define (make-tree entry left right) + (list 'bintree entry left right)) + +(define tree1 + (make-tree 7 + (make-tree 3 + (make-tree 1 '() '()) + (make-tree 5 '() '())) + (make-tree 9 '() (make-tree 11 '() '())))) + +(define (element-of-set? x set) + (cond + ((null? set) #f) + ((= x (entry set)) #t) + ((< x (entry set)) + (element-of-set? x (left-branch set))) + ((> x (entry set)) + (element-of-set? x (right-branch set))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree.scm new file mode 100644 index 0000000..eec7e50 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree.scm @@ -0,0 +1,43 @@ +;;; Implementation of tree ADT +;;; +;;; Data at leaves only; leaves are words. + +(define (make-tree datum children) + (cond ((null? datum) children) + ((not (null? children)) (error "datum at branch node!")) + ((list? datum) (error "datum must be a word!")) + (else datum))) + +(define (datum node) + (if (list? node) + '() + node)) + +(define (children node) + (if (list? node) + node + '() )) + +(define (leaf? node) + (not (pair? node))) + +;; or can do: +;; (define (leaf? node) +;; (null? (children node)) ) + +;; Map a function over the data of a tree + +(define (treemap fn tree) + (cond ((null? tree) '()) + ((leaf? tree) (fn tree)) + (else (make-tree '() (map + (lambda (t) (treemap fn t)) + (children tree))) ))) + +;; Sample + +(define (square x) (* x x)) + +(define t1 '((1 2) 3 (4 (5 6)))) + +(treemap square t1) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree1.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree1.scm new file mode 100644 index 0000000..9fbfc11 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree1.scm @@ -0,0 +1,27 @@ +;;; Trees, version 1 +;;; +;;; Data at all nodes, no empty tree defined. + +(define make-tree cons) +(define datum car) +(define children cdr) + +(define (leaf? node) + (null? (children node)) ) + +(define (treemap fn tree) + (make-tree (fn (datum tree)) + (map (lambda (t) (treemap fn t)) + (children tree) ))) + +;; Sample + +(define (square x) (* x x)) + +(define (leaves . seq) + (map (lambda (x) (make-tree x '())) seq)) + +(define t1 + (make-tree 1 + (list (make-tree 2 (leaves 3 4)) + (make-tree 5 (leaves 6 7 8)) ))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree11.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree11.scm new file mode 100644 index 0000000..def3a03 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree11.scm @@ -0,0 +1,9 @@ +(define (treemap fn tree) + (make-tree (fn (datum tree)) + (forest-map fn (children tree)))) + +(define (forest-map fn forest) + (if (null? forest) + '() + (cons (treemap fn (car forest)) + (forest-map fn (cdr forest))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree2.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree2.scm new file mode 100644 index 0000000..2c91932 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree2.scm @@ -0,0 +1,41 @@ +;;; Trees, version 2 +;;; +;;; Data at leaves only, leaves are words + +(define (make-tree d ch) + (cond ((null? d) ch) + ((null? ch) d) + (else (error "Data at leaves only")) )) + +(define (datum node) + (cond ((null? node) '()) + ((not (pair? node)) node) + (else '()) )) + +(define (children node) + (cond ((null? node) '()) + ((not (pair? node)) '()) + (else node) )) + +(define (leaf? node) + (not (pair? node))) + +(define (treemap fn tree) + (cond ((null? tree) '()) + ((leaf? tree) (fn tree)) + (else (map (lambda (t) (treemap fn t)) tree)) )) + +;; Sample + +(define (square x) (* x x)) + +(define t2 '((1 2) 3 (4 (5 6)))) + +(define t3 (make-tree '() + (list (make-tree '() (list (make-tree 1 '()) + (make-tree 2 '()))) + (make-tree 3 '()) + (make-tree '() (list (make-tree 4 '()) + (make-tree '() (list (make-tree 5 '()) + (make-tree 6 '())))))))) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree3.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree3.scm new file mode 100644 index 0000000..09f901c --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/tree3.scm @@ -0,0 +1,6 @@ +(define (deep-map fn xmas) + (cond ((null? xmas) '()) + ((pair? xmas) + (cons (deep-map fn (car xmas)) + (deep-map fn (cdr xmas)))) + (else (fn xmas)))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/world.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/world.scm new file mode 100644 index 0000000..2cb2f3f --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.2/world.scm @@ -0,0 +1,50 @@ +(define datum car) +(define children cdr) +(define make-tree cons) +(define (city x) (make-tree x '())) +(define (leaf? x) (null? (children x))) + +(define world + (make-tree + 'earth + (list (make-tree + 'united-states + (list (make-tree + 'california + (list (city 'berkeley) + (city 'san-francisco) + (city 'palo-alto) + (city 'oakland))) + (make-tree + 'massachusetts + (list (city 'cambridge) + (city 'amherst) + (city 'boston) + (city 'sudbury))) + (make-tree + 'new-york + (list (city 'new-york))))) + (make-tree + 'france + (list (city 'paris) + (city 'lyon) + (city 'marseilles)))))) + +(define (find-place place tree) + (cond ((eq? place (datum tree)) (cons (datum tree) '())) + ((leaf? tree) '()) + (else (let ((try (find-subtree place (children tree)))) + (if (not (null? try)) + (cons (datum tree) try) + '()))))) + +(define (find-subtree place nodes) + (if (null? nodes) + '() + (let ((try (find-place place (car nodes)))) + (if (not (null? try)) + try + (find-subtree place (cdr nodes)))))) + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/data.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/data.scm new file mode 100644 index 0000000..3137436 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/data.scm @@ -0,0 +1,78 @@ +(define (make-regular root) + (attach-type 'regular root)) + +(define (make-es root) + (attach-type 'es root)) + +(define (make-irreg fp sp tp) + (attach-type 'irreg (list fp sp tp))) + +(define (type thing) + (car thing)) + +(define (contents thing) + (cdr thing)) + +(define (attach-type type thing) + (cons type thing)) + +(define (root thing) + thing) + +(define (fp thing) + (car thing)) + +(define (sp thing) + (cadr thing)) + +(define (tp thing) + (caddr thing)) + +(define (add-s wd) + (word wd 's)) + +(define (add-es wd) + (word wd 'es)) + +(define eat (make-regular 'eat)) +(define drink (make-regular 'drink)) +(define go (make-es 'go)) +(define box (make-es 'box)) +(define be (make-irreg 'am 'are 'is)) + +(define (operate op obj) + (let ((proc (get (type obj) op))) + (if (not (null? proc)) + (proc (contents obj)) + (error "Undefined operator" (list op obj))))) + +(define (fps obj) (operate 'fps obj)) +(define (sps obj) (operate 'sps obj)) +(define (tps obj) (operate 'tps obj)) +(define (fpp obj) (operate 'fpp obj)) +(define (spp obj) (operate 'spp obj)) +(define (tpp obj) (operate 'tpp obj)) + +(put 'regular 'fps root) +(put 'regular 'sps root) +(put 'regular 'tps (lambda (x) (add-s (root x)))) +(put 'regular 'fpp root) +(put 'regular 'spp root) +(put 'regular 'tpp root) + +(put 'es 'fps root) +(put 'es 'sps root) +(put 'es 'tps (lambda (x) (add-es (root x)))) +(put 'es 'fpp root) +(put 'es 'spp root) +(put 'es 'tpp root) + +(put 'irreg 'fps fp) +(put 'irreg 'sps sp) +(put 'irreg 'tps tp) +(put 'irreg 'fpp sp) +(put 'irreg 'spp sp) +(put 'irreg 'tpp sp) + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/geom.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/geom.scm new file mode 100644 index 0000000..dd47bd1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/geom.scm @@ -0,0 +1,69 @@ +(define pi 3.141592654) + +;; tagged data + +(define attach-tag cons) +(define type-tag car) +(define contents cdr) + +(define (make-square side) + (attach-tag 'square side)) + +(define (make-circle radius) + (attach-tag 'circle radius)) + +;; conventional style + +(define (area shape) + (cond ((eq? (type-tag shape) 'square) + (* (contents shape) (contents shape))) + ((eq? (type-tag shape) 'circle) + (* pi (contents shape) (contents shape))) + (else (error "Unknown shape -- AREA")))) + +(define (perimeter shape) + (cond ((eq? (type-tag shape) 'square) + (* 4 (contents shape))) + ((eq? (type-tag shape) 'circle) + (* 2 pi (contents shape))) + (else (error "Unknown shape -- PERIMETER")))) + +;; Data-directed programming + +(put 'square 'area (lambda (s) (* s s))) +(put 'circle 'area (lambda (r) (* pi r r))) +(put 'square 'perimeter (lambda (s) (* 4 s))) +(put 'circle 'perimeter (lambda (r) (* 2 pi r))) + +(define (operate op obj) + (let ((proc (get (type-tag obj) op))) + (if proc + (proc (contents obj)) + (error "Unknown operator for type")))) + +(define (area shape) + (operate 'area shape)) + +(define (perimeter shape) + (operate 'perimeter shape)) + +;; message passing + +(define (make-square side) + (lambda (message) + (cond ((eq? message 'area) + (* side side)) + ((eq? message 'perimeter) + (* 4 side)) + (else (error "Unknown message"))))) + +(define (make-circle radius) + (lambda (message) + (cond ((eq? message 'area) + (* pi radius radius)) + ((eq? message 'perimeter) + (* 2 pi radius)) + (else (error "Unknown message"))))) + +(define (operate op obj) + (obj op)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html new file mode 100644 index 0000000..32b7c99 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html @@ -0,0 +1,20 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/bnf">bnf</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">852 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="data.scm">data.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="geom.scm">geom.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="msg.scm">msg.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="trydata.scm">trydata.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="type.scm">type.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=D;O=A new file mode 100644 index 0000000..be6d42d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=D;O=A @@ -0,0 +1,20 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/bnf">bnf</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">852 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="data.scm">data.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="geom.scm">geom.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="msg.scm">msg.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="trydata.scm">trydata.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="type.scm">type.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=D;O=D new file mode 100644 index 0000000..8732d2d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=D;O=D @@ -0,0 +1,20 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="type.scm">type.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="trydata.scm">trydata.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="msg.scm">msg.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="geom.scm">geom.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="data.scm">data.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/bnf">bnf</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">852 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=M;O=A new file mode 100644 index 0000000..6c82bac --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=M;O=A @@ -0,0 +1,20 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/bnf">bnf</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">852 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="data.scm">data.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="geom.scm">geom.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="msg.scm">msg.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="trydata.scm">trydata.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="type.scm">type.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=M;O=D new file mode 100644 index 0000000..8732d2d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=M;O=D @@ -0,0 +1,20 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="type.scm">type.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="trydata.scm">trydata.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="msg.scm">msg.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="geom.scm">geom.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="data.scm">data.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/bnf">bnf</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">852 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=N;O=D new file mode 100644 index 0000000..8732d2d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=N;O=D @@ -0,0 +1,20 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="type.scm">type.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="trydata.scm">trydata.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="msg.scm">msg.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="geom.scm">geom.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="data.scm">data.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/bnf">bnf</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">852 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=S;O=A new file mode 100644 index 0000000..8611b4d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=S;O=A @@ -0,0 +1,20 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/bnf">bnf</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">852 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="msg.scm">msg.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="data.scm">data.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="geom.scm">geom.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="type.scm">type.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="trydata.scm">trydata.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.0K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=S;O=D new file mode 100644 index 0000000..d0eaab1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/index.html?C=S;O=D @@ -0,0 +1,20 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/2.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/2.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="trydata.scm">trydata.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="type.scm">type.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="geom.scm">geom.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="data.scm">data.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="msg.scm">msg.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/2.4/bnf">bnf</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">852 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/msg.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/msg.scm new file mode 100644 index 0000000..a82f298 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/msg.scm @@ -0,0 +1,52 @@ +(define (make-regular root) + (lambda (msg) + (cond ((eq? msg 'fps) root) + ((eq? msg 'sps) root) + ((eq? msg 'tps) (add-s root)) + ((eq? msg 'fpp) root) + ((eq? msg 'spp) root) + ((eq? msg 'tpp) root)))) + +(define (make-es root) + (lambda (msg) + (cond ((eq? msg 'fps) root) + ((eq? msg 'sps) root) + ((eq? msg 'tps) (add-es root)) + ((eq? msg 'fpp) root) + ((eq? msg 'spp) root) + ((eq? msg 'tpp) root)))) + +(define (make-irreg fp sp tp) + (lambda (msg) + (cond ((eq? msg 'fps) fp) + ((eq? msg 'sps) sp) + ((eq? msg 'tps) tp) + ((eq? msg 'fpp) sp) + ((eq? msg 'spp) sp) + ((eq? msg 'tpp) sp)))) + +(define (operate op obj) + (obj op)) + +(define (fps obj) (operate 'fps obj)) +(define (sps obj) (operate 'sps obj)) +(define (tps obj) (operate 'tps obj)) +(define (fpp obj) (operate 'fpp obj)) +(define (spp obj) (operate 'spp obj)) +(define (tpp obj) (operate 'tpp obj)) + + +(define (add-s wd) + (word wd 's)) + +(define (add-es wd) + (word wd 'es)) + +(define eat (make-regular 'eat)) +(define drink (make-regular 'drink)) +(define go (make-es 'go)) +(define box (make-es 'box)) +(define be (make-irreg 'am 'are 'is)) + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/trydata.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/trydata.scm new file mode 100644 index 0000000..f37c4a7 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/trydata.scm @@ -0,0 +1,170 @@ +~cs60a/lectures/2.3/trydata.scm + + Conjugating verbs example... notes for 29 Sept 1993 + +We could start with + +(define (tps v); third person singular version of verb v + (cond((equal? v 'eat) 'eats) ; he eats + ((equal? v 'drink) 'drinks) + ((equal? v 'go) 'goes) +.... + (else (error "unknown verb")))) + +We need a total of six programs. Maintaining this would be really terrible. + + +Let us take a really crude first approach with tables. +(These are sometimes referred to as properties... e.g. +put the 'fps property of the 'eat word to ....) + We could do this: + +(put 'eat 'fps 'eat) ; I eat (get 'eat 'fps) --> eat +(put 'eat 'sps 'eat) ; You eat +(put 'eat 'tps 'eats) ; He eats (get 'eat 'tps) --> eats +(put 'eat 'fpp 'eat) ; We eat +(put 'eat 'spp 'eat) ; You eat +(put 'eat 'tps 'eat) ; They eat + +;;; etc for all other verbs. + +then +(define (tps verb) (get verb 'tps)) +(define (sps verb) (get verb 'sps)) ;etc. for 4 more + +The advantage here is that we can add new verbs and not rewrite programs. + +The problems: this wastes a lot of table space and still not very robust. +(tps 'nonsense) --> () (no error message) + +more robust six programs, each looking like this: + +(define (tps verb)(let((answer (get verb 'tps))) + (if (not (null? answer)) answer + (error 'tps "bad verb ~s~%" verb)))) + +Now, to reduce space consumption.... + +solution: group verbs by type + "regular" (just add -s in tps) as eat, drink + -es (just add -es in tps) as go, box + "irregular" (refer to list) be: (am are is are are are) + +Then all we have to do is say that a verb is regular, and all its forms +are known. We store most of the info on the TYPE not the data. Here's how: + +(put 'eat 'verb-type 'regular) + +(define (type-of-verb v) (get v 'verb-type)) + +(put 'fps 'regular root) ; I eat, drink +(put 'sps 'regular root) ; you eat, drink +(put 'tps 'regular (lambda(x)( add-s (root x)))) ; he eats, drinks +(put 'fpp 'regular root) ; We eat, drink +etc. + + +Now we can write + +(define (tps verb) ;; third person singular + (let ((proc (get (type-of-verb verb) 'tps))) + + ;; either proc is () i.e. not found or we can + ;; apply it to the root verb: + + (if (not (null? proc)) (proc verb)) + (error 'tps "I don't know about verb ~s~% " verb)))) + +we need a total of six such programs.. + +... + +How about using manifest types? Earlier we had proposed (see data.scm) +that, instead of have the verb +be just 'eat, with a property (get 'eat 'verb-type) --> 'regular + +We talk about the verb as an abstraction with a type and a root, +and in the case of an irregular verb, contents that give specific +forms for the verb conjugation. Although we cover it over with +abstraction: make-verb, type, root, contents (see data.scm) the verbs +look like this, if we print them as normal lisp: + +'(regular . eat) (that is, (cons 'regular 'eat)) + +and for an irregular verb we have '(irreg . (be am are is)) + {this actually prints as (irreg be am are is) } + +where + (contents verb) is (cdr verb) which is either (root) or (fp sp tp) + + (root (contents verb)) --> eat, drink etc. (i.e. cdr) + + (type verb) is (car verb) --> regular, irregular, -es (i.e. car) + +Now with this abstraction, we have a similar program, but the +"type" program looks at the manifest type (car) rather than in a table. + +(define (tps verb) ;; third person singular + (let ((proc (get (type verb) 'tps))) ;; this type = car gets manifest type + + ;; either proc is () i.e. not found or we can + ;; apply it to verb: + + (if (not (null? proc)) (proc verb)) + (error 'tps "I don't know about verb ~s~% " verb))) + +for a total of 6 programs that are all about the same.. e.g. + +(define (tpp verb) ;; third person singular + (let ((proc (get (type verb) 'tpp))) + (if (not (null? proc)) (proc verb)) + (error 'tpp "I don't know about verb ~s~% " verb))) + +........... + +Now, another simplification... Since fps, sps, tps, fpp, spp, tpp +are all almost the same program... + +Why not do this: + + (define (fps verb) (operate 'fps obj)) + (define (sps verb) (operate 'sps obj)) + (define (tps verb) (operate 'tps obj)) +etc... + +where operate is +(define (operate op obj) ;; op is one of fps, sps, tps, fpp, spp, tpp + (let ((proc (get (type obj) op))) + (if (not (null? proc)) + (proc (contents obj)) + (error op "Undefined operator" (list op obj))))) + +;;;;;;;;;;;;;;;; + +;; some detailed notes on data.scm -- how lisp represents them + +;; notes + +;; note that (cons 'a 'b) is (a . b) but +;; (cons 'a (cons 'b ()) is (a b) ... + +box --> (es . box) + ^ ^ + type- | |-root + +(get 'es 'fps) --> procedure (actually, root) +(get 'es 'tps) --> procedure (actually (lambda(x)(add-es (root x)))) + +(operate 'fps box) --> ((get (type box) 'fps) then apply it to "box" --> box +(operate 'tps box) --> ((get (type box) 'fps) then apply it to "box" --> boxes + +(define be (make-irreg 'am 'are 'is)) +be --> (irreg am are is) + ^ ^ ^ \tps + type- | | \sps + |-fps + + + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/type.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/type.scm new file mode 100644 index 0000000..06fabeb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.4/type.scm @@ -0,0 +1,83 @@ +(define (make-regular root) + (attach-type 'regular root)) + +(define (make-es root) + (attach-type 'es root)) + +(define (make-irreg fp sp tp) + (attach-type 'irreg (list fp sp tp))) + +(define (attach-type type contents) + (cons type contents)) + +(define (type thing) + (car thing)) + +(define (contents thing) + (cdr thing)) + +(define (fps verb) + (cond ((regular? verb) (root (contents verb))) + ((es? verb) (root (contents verb))) + ((irreg? verb) (fp (contents verb))))) + +(define (sps verb) + (cond ((regular? verb) (root (contents verb))) + ((es? verb) (root (contents verb))) + ((irreg? verb) (sp (contents verb))))) + +(define (tps verb) + (cond ((regular? verb) (add-s (root (contents verb)))) + ((es? verb) (add-es (root (contents verb)))) + ((irreg? verb) (tp (contents verb))))) + +(define (fpp verb) + (cond ((regular? verb) (root (contents verb))) + ((es? verb) (root (contents verb))) + ((irreg? verb) (sp (contents verb))))) + +(define (spp verb) + (cond ((regular? verb) (root (contents verb))) + ((es? verb) (root (contents verb))) + ((irreg? verb) (sp (contents verb))))) + +(define (tpp verb) + (cond ((regular? verb) (root (contents verb))) + ((es? verb) (root (contents verb))) + ((irreg? verb) (sp (contents verb))))) + +(define (regular? verb) + (eq? (type verb) 'regular)) + +(define (es? verb) + (eq? (type verb) 'es)) + +(define (irreg? verb) + (eq? (type verb) 'irreg)) + +(define (root verb) + verb) + +(define (fp verb) + (car verb)) + +(define (sp verb) + (cadr verb)) + +(define (tp verb) + (caddr verb)) + +(define (add-s wd) + (word wd 's)) + +(define (add-es wd) + (word wd 'es)) + +(define eat (make-regular 'eat)) +(define drink (make-regular 'drink)) +(define go (make-es 'go)) +(define box (make-es 'box)) +(define be (make-irreg 'am 'are 'is)) + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/count.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/count.scm new file mode 100644 index 0000000..b68ff2d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/count.scm @@ -0,0 +1,32 @@ +(define-class (counter) + (instance-vars (count 0)) + (method (next) + (set! count (+ count 1)) + count) ) + +(define-class (counter2) + (instance-vars (count 0)) + (class-vars (total 0)) + (method (next) + (set! total (+ total 1)) + (set! count (+ count 1)) + (list count total))) + +(define-class (counter3) + (instance-vars (count 0)) + (class-vars (total 0) (counters '())) + (initialize (set! counters (cons self counters))) + (method (next) + (set! total (+ total 1)) + (set! count (+ count 1)) + (list count total))) + +(define c11 (instantiate counter)) +(define c12 (instantiate counter)) + +(define c21 (instantiate counter2)) +(define c22 (instantiate counter2)) + +(define c31 (instantiate counter3)) +(define c32 (instantiate counter3)) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/demo.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/demo.scm new file mode 100644 index 0000000..d78ae82 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/demo.scm @@ -0,0 +1,15 @@ +(define-class (complex real-part imag-part) + (method (magnitude) + (sqrt (+ (* real-part real-part) + (* imag-part imag-part)))) + (method (angle) + (atan (/ imag-part real-part))) ) + +(define-class (counter) + (instance-vars (count 0)) + (method (next) + (set! count (+ count 1)) + count) ) + +(define-class (doubler) + (method (say stuff) (se stuff stuff))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html new file mode 100644 index 0000000..888468e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.0</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.0</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.0/?C=N;O=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">754 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="demo.scm">demo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">370 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.0/demo2.scm">demo2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=D;O=A new file mode 100644 index 0000000..a956f80 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=D;O=A @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.0</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.0</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">754 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="demo.scm">demo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">370 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.0/demo2.scm">demo2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=D;O=D new file mode 100644 index 0000000..ba3ef93 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=D;O=D @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.0</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.0</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.0/demo2.scm">demo2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="demo.scm">demo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">370 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">754 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=M;O=A new file mode 100644 index 0000000..a085eec --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=M;O=A @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.0</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.0</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">754 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="demo.scm">demo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">370 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.0/demo2.scm">demo2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=M;O=D new file mode 100644 index 0000000..ba3ef93 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=M;O=D @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.0</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.0</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.0/demo2.scm">demo2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="demo.scm">demo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">370 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">754 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=N;O=A new file mode 100644 index 0000000..888468e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=N;O=A @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.0</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.0</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.0/?C=N;O=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">754 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="demo.scm">demo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">370 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.0/demo2.scm">demo2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=S;O=A new file mode 100644 index 0000000..42472bd --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.0/index.html?C=S;O=A @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.0</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.0</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.0/?C=S;O=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="demo.scm">demo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">370 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count.scm">count.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">754 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.0/demo2.scm">demo2.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.3K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/count4.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/count4.scm new file mode 100644 index 0000000..9df6e40 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/count4.scm @@ -0,0 +1,8 @@ +(define make-count + (let ((glob 0)) + (lambda () + (let ((loc 0)) + (lambda () + (set! loc (+ loc 1)) + (set! glob (+ glob 1)) + (list loc glob)))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/count5.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/count5.scm new file mode 100644 index 0000000..16f4a41 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/count5.scm @@ -0,0 +1,14 @@ +(define make-count + (let ((glob 0)) + (lambda () + (let ((loc 0)) + (lambda (msg) + (cond ((eq? msg 'local) + (lambda () + (set! loc (+ loc 1)) + loc)) + ((eq? msg 'global) + (lambda () + (set! glob (+ glob 1)) + glob)) + (else (error "No such method" msg)) )))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/env-note b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/env-note new file mode 100644 index 0000000..161c88e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/env-note @@ -0,0 +1,44 @@ + A Note on Environments, frames, bindings, etc. + + +A frame is just a table. A variable is just an ENTRY (or place) in the +table. E.g., if we have a frame like this one + + x: 1 + y: 2 + +we can think of x and y as labelling the entries in the table, in which +are written 1 and 2. The places where 1 and 2 live are the variables. + +When we say that we bind or rebind the variable x, we mean that we +create an entry for it in new frame we are using to extend the +environment. "set!" simply puts a new value in the table entry +corresponding to a given name. + +All this terminology may be confusing because, in the book, they tend to +confuse variables and names. That is, they say ``create a new binding +for the variable x'', while it would be more accurate to say ``create a +new place (i.e., variable) named x and give it a value''. (Note that if +you just do a "set!", no one (including A&S) says that we have created a +new binding for x; rather, everyone would say that the binding has +changed. What's really changed is simply the value of the variable +(i.e., the value in the place) corresponding to x in the frame; the +association between x and this place remains unchanged. + +Similarly, when they say, ``the variable x is bound to 4 in this +frame'', it would be more accurate to say ``the new variable +corresponding to x in this frame has the value 4''. The difference is +that the first expression gives that impression that there is only one +variable x, and that it is rebound each time a function is called that +uses x as a formal parameter, whereas it is more accurate to say that +there are many variables corresponding to x, each one created when such +a function is called. + +It's important to emphasize that most of the time, the extensions to +environments that are created are thrown away after their use, i.e., +when the call to the function that created them finishes. This is +emphatically NOT the case when the call to a function returns a newly +created function. That is the one instance in which a frame will +persist, even though the function call that created it has ceased to +exist. + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/envrules b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/envrules new file mode 100644 index 0000000..ce2b124 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/envrules @@ -0,0 +1,59 @@ +CS 61A Environment Model of Evaluation + +Every expression is either atomic or compound. + +At any time there is a CURRENT FRAME, initially the global frame. + +1. atomic expressions + + (a) Numbers, strings, #T, and #F are self-evaluating. + + (b) If the expression is a symbol, find the FIRST AVAILABLE binding. + (That is, look in the current frame; if not found there, look in + the frame "behind" the current frame; and so on until the global + frame is reached.) + +2. Compound expressions + +If the car of the expression is a symbol that names a special form, then +follow its rules (2(b) below). Otherwise the expression is a procedure +invocation. + + (a) Procedure invocation + + Step 1: Evaluate all the subexpressions (using these same rules). + Step 2: Apply the procedure (the value of the first subexpression) + to the arguments (the values of the other subexpressions). + + i. If the procedure is compound (user-defined): + A. Create a frame with the formal parameters of the procedure + bound to the actual argument values. + B. Extend the procedure's defining environment with this + new frame. + C. Evaluate the procedure body, using the new frame as + the current frame. + + *** ONLY COMPOUND PROCEDURE INVOCATION CREATES A FRAME *** + + ii. If the procedure is primitive: + Apply it by magic. + + (b) Special forms + + i. LAMBDA creates a procedure. The left circle points to the text + of the lambda expression; the right circle points to the + defining environment, i.e., to the current environment at the + time the lambda is seen. + + *** ONLY LAMBDA CREATES A PROCEDURE *** + + ii. DEFINE adds a NEW binding to the CURRENT FRAME. + + iii. SET! changes the FIRST AVAILABLE binding (see 1(b) for the + definition of "first available"). + + iv. LET = LAMBDA (2(b)i) + invocation (2(a)) + + v. (define (...) ...) = LAMBDA (2(b)i) + DEFINE (2(b)ii) + + vi. Other special forms follow their own rules (e.g. COND, IF). diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html new file mode 100644 index 0000000..25fde3b --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count4.scm">count4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">173 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count5.scm">count5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">356 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/count6.scm">count6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">181 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="env-note">env-note</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="envrules">envrules</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev4.scm">prev4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">208 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev5.scm">prev5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">371 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/prev6.scm">prev6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">262 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=D;O=A new file mode 100644 index 0000000..d75c248 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=D;O=A @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count4.scm">count4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">173 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count5.scm">count5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">356 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/count6.scm">count6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">181 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="env-note">env-note</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="envrules">envrules</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev4.scm">prev4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">208 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev5.scm">prev5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">371 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/prev6.scm">prev6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">262 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=D;O=D new file mode 100644 index 0000000..c405097 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=D;O=D @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/prev6.scm">prev6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev5.scm">prev5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">371 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev4.scm">prev4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">208 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="envrules">envrules</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="env-note">env-note</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/count6.scm">count6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">181 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count5.scm">count5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">356 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count4.scm">count4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">173 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=M;O=A new file mode 100644 index 0000000..11899c1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=M;O=A @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count4.scm">count4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">173 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count5.scm">count5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">356 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/count6.scm">count6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">181 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="env-note">env-note</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="envrules">envrules</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev4.scm">prev4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">208 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev5.scm">prev5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">371 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/prev6.scm">prev6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=M;O=D new file mode 100644 index 0000000..5dcaf88 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=M;O=D @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/prev6.scm">prev6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev5.scm">prev5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">371 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev4.scm">prev4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">208 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="envrules">envrules</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="env-note">env-note</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/count6.scm">count6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">181 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count5.scm">count5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">356 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count4.scm">count4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">173 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=N;O=A new file mode 100644 index 0000000..25fde3b --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=N;O=A @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count4.scm">count4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">173 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count5.scm">count5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">356 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/count6.scm">count6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">181 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="env-note">env-note</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="envrules">envrules</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev4.scm">prev4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">208 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev5.scm">prev5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">371 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/prev6.scm">prev6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">262 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=N;O=D new file mode 100644 index 0000000..c405097 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=N;O=D @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/prev6.scm">prev6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev5.scm">prev5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">371 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev4.scm">prev4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">208 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="envrules">envrules</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="env-note">env-note</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/count6.scm">count6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">181 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count5.scm">count5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">356 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count4.scm">count4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">173 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=S;O=A new file mode 100644 index 0000000..fefb49a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=S;O=A @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count4.scm">count4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">173 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/count6.scm">count6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">181 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev4.scm">prev4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">208 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/prev6.scm">prev6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count5.scm">count5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">356 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev5.scm">prev5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">371 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="env-note">env-note</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="envrules">envrules</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=S;O=D new file mode 100644 index 0000000..ca6e276 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/index.html?C=S;O=D @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="envrules">envrules</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="env-note">env-note</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev5.scm">prev5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">371 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count5.scm">count5.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">356 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/prev6.scm">prev6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">262 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prev4.scm">prev4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">208 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.2/count6.scm">count6.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">181 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="count4.scm">count4.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">173 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/obj.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/obj.scm new file mode 100644 index 0000000..d4a9d7a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/obj.scm @@ -0,0 +1,279 @@ +;;; obj.scm version 4.0 5/18/2000 +;;; -- implementation of the object-oriented syntax +;; By Matt Wright, based on a handout from MIT +;; Revised for STk by Brian Gaeke - removed scm and procedure->macro + +;;; Utilities + +;; MAKNAM: create a new symbol whose name is the concatenation of the +;; names of those in the symbol list SYMBOLS. +(define (maknam . symbols) + (string->symbol (apply string-append (map symbol->string symbols)))) + +;; ASK: send a message to an object + +; The dot in the first line of the definition of ASK, below, makes it +; take a variable number of arguments. The first argument is associated +; with the formal parameter OBJECT; the second with MESSAGE; any extra +; actual arguments are put in a list, and that list is associated with +; the formal parameter ARGS. (If there are only two actual args, then +; ARGS will be the empty list.) + +; APPLY takes two arguments, a procedure and a list, and applies the +; procedure to the things in the list, which are used as actual +; argument values. + +(define (ask object message . args) + (let ((method (object message))) + (if (method? method) + (apply method args) + (error "No method " message " in class " (cadr method))))) + +(define (no-method name) + (list 'no-method name)) + +(define (no-method? x) + (if (pair? x) + (eq? (car x) 'no-method) + #f)) + +(define (method? x) + (not (no-method? x))) + + +;; INSTANTIATE and INSTANTIATE-PARENT: Create an instance of a class + +; The difference is that only INSTANTIATE initializes the new object + +(define (instantiate class . arguments) + (let ((new-instance (apply (class 'instantiate) arguments))) + (ask new-instance 'initialize new-instance) + new-instance)) + +(define (instantiate-parent class . arguments) + (apply (class 'instantiate) arguments)) + +;; GET-METHOD: Send a message to several objects and return the first +;; method found (for multiple inheritance) + +(define (get-method give-up-name message . objects) + (if (null? objects) + (no-method give-up-name) + (let ((method ((car objects) message))) + (if (method? method) + method + (apply get-method (cons give-up-name + (cons message (cdr objects)) )))))) + + + +;; USUAL: Invoke a parent's method +;; Note: The 'send-usual-to-parent method is put in automatically by +;; define-class. + +(define-macro (usual . args) + `(ask dispatch 'send-usual-to-parent . ,args)) + + +;; DEFINE-CLASS: Create a new class. + +; DEFINE-CLASS is a special form. When you type (define-class body...) +; it's as if you typed (make-definitions (quote body...)). In other +; words, the argument to DEFINE-CLASS isn't evaluated. This makes sense +; because the argument isn't Scheme syntax, but rather is the special +; object-oriented programming language we're defining. +; Make-definitions transforms the OOP notation into a standard Scheme +; expression, then uses EVAL to evaluate the result. (You'll see EVAL +; again in chapter 4 with the metacircular evaluator.) + +; When you define a class named THING, for example, two global Scheme +; variables are created. The variable THING has as its value the +; procedure that represents the class. This procedure is invoked by +; INSTANTIATE to create instances of the class. A second variable, +; THING-DEFINITION, has as its value the text of the Scheme expression +; that defines THING. This text is used only by SHOW-CLASS, the +; procedure that lets you examine the result of the OOP-to-Scheme +; translation process. + +(define-macro (define-class . body) (make-definitions body)) + +(define (make-definitions form) + (let ((definition (translate form))) + (eval `(define ,(maknam (class-name form) '-definition) ',definition)) + (eval definition) + (list 'quote (class-name form)))) + +(define (show-class name) + (eval (maknam name '-definition)) ) + +; TRANSLATE does all the work of DEFINE-CLASS. +; The backquote operator (`) works just like regular quote (') except +; that expressions proceeded by a comma are evaluated. Also, expressions +; proceeded by ",@" evaluate to lists; the lists are inserted into the +; text without the outermost level of parentheses. + +(define (translate form) + (cond ((null? form) (error "Define-class: empty body")) + ((not (null? (obj-filter form (lambda (x) (not (pair? x)))))) + (error "Each argument to define-class must be a list")) + ((not (null? (extra-clauses form))) + (error "Unrecognized clause in define-class:" (extra-clauses form))) + (else + `(define ,(class-name form) + (let ,(class-var-bindings form) + (lambda (class-message) + (cond + ,@(class-variable-methods form) + ((eq? class-message 'instantiate) + (lambda ,(instantiation-vars form) + (let ((self '()) + ,@(parent-let-list form) + ,@(instance-vars-let-list form)) + (define (dispatch message) + (cond + ,(init-clause form) + ,(usual-clause form) + ,@(method-clauses form) + ,@(local-variable-methods form) + ,(else-clause form) )) + dispatch ))) + (else (error "Bad message to class" class-message)) ))))))) + +(define *legal-clauses* + '(instance-vars class-vars method default-method parent initialize)) + +(define (extra-clauses form) + (obj-filter (cdr form) + (lambda (x) (null? (member (car x) *legal-clauses*))))) + +(define class-name caar) + +(define (class-var-bindings form) + (let ((classvar-clause (find-a-clause 'class-vars form))) + (if (null? classvar-clause) + '() + (cdr classvar-clause) ))) + +(define instantiation-vars cdar) + +(define (parent-let-list form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map (lambda (parent-and-args) + (list (maknam 'my- (car parent-and-args)) + (cons 'instantiate-parent parent-and-args))) + (cdr parent-clause))))) + +(define (instance-vars-let-list form) + (let ((instance-vars-clause (find-a-clause 'instance-vars form))) + (if (null? instance-vars-clause) + '() + (cdr instance-vars-clause)))) + +(define (init-clause form) + (define (parent-initialization form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map + (lambda (parent-and-args) + `(ask ,(maknam 'my- (car parent-and-args)) 'initialize self) ) + (cdr parent-clause) )))) + (define (my-initialization form) + (let ((init-clause (find-a-clause 'initialize form))) + (if (null? init-clause) '() + (cdr init-clause)))) + (define (init-body form) + (append (parent-initialization form) + (my-initialization form) )) + + `((eq? message 'initialize) + (lambda (value-for-self) + (set! self value-for-self) + ,@(init-body form) ))) + +(define (variable-list var-type form) + (let ((clause (find-a-clause var-type form))) + (if (null? clause) + '() + (map car (cdr clause)) ))) + +(define (class-variable-methods form) + (cons `((eq? class-message 'class-name) (lambda () ',(class-name form))) + (map (lambda (variable) + `((eq? class-message ',variable) (lambda () ,variable))) + (variable-list 'class-vars form)))) + +(define (local-variable-methods form) + (cons `((eq? message 'class-name) (lambda () ',(class-name form))) + (map (lambda (variable) + `((eq? message ',variable) (lambda () ,variable))) + (append (cdr (car form)) + (variable-list 'instance-vars form) + (variable-list 'class-vars form))))) + +(define (method-clauses form) + (map + (lambda (method-defn) + (let ((this-message (car (cadr method-defn))) + (args (cdr (cadr method-defn))) + (body (cddr method-defn))) + `((eq? message ',this-message) + (lambda ,args ,@body)))) + (obj-filter (cdr form) (lambda (x) (eq? (car x) 'method))) )) + +(define (parent-list form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map (lambda (class) (maknam 'my- class)) + (map car (cdr parent-clause)))))) + +(define (usual-clause form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + `((eq? message 'send-usual-to-parent) + (error "Can't use USUAL without a parent." ',(class-name form))) + `((eq? message 'send-usual-to-parent) + (lambda (message . args) + (let ((method (get-method ',(class-name form) + message + ,@(parent-list form)))) + (if (method? method) + (apply method args) + (error "No USUAL method" message ',(class-name form)) ))))))) + +(define (else-clause form) + (let ((parent-clause (find-a-clause 'parent form)) + (default-method (find-a-clause 'default-method form))) + (cond + ((and (null? parent-clause) (null? default-method)) + `(else (no-method ',(class-name form)))) + ((null? parent-clause) + `(else (lambda args ,@(cdr default-method)))) + ((null? default-method) + `(else (get-method ',(class-name form) message ,@(parent-list form))) ) + (else + `(else (let ((method (get-method ',(class-name form) + message + ,@(parent-list form)))) + (if (method? method) + method + (lambda args ,@(cdr default-method)) ))))))) + +(define (find-a-clause clause-name form) + (let ((clauses (obj-filter (cdr form) + (lambda (x) (eq? (car x) clause-name))))) + (cond ((null? clauses) '()) + ((null? (cdr clauses)) (car clauses)) + (else (error "Error in define-class: too many " + clause-name "clauses.")) ))) + +(define (obj-filter l pred) + (cond ((null? l) '()) + ((pred (car l)) + (cons (car l) (obj-filter (cdr l) pred))) + (else (obj-filter (cdr l) pred)))) + +(provide "obj") diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/prev4.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/prev4.scm new file mode 100644 index 0000000..fdb4876 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/prev4.scm @@ -0,0 +1,12 @@ +(define make-previous + (let ((glob 'first-time)) + (lambda () + (let ((old 'first-time)) + (lambda (arg) + (let ((result (list old glob))) + (set! old arg) + (set! glob arg) + result)))))) + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/prev5.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/prev5.scm new file mode 100644 index 0000000..b2a6c27 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/prev5.scm @@ -0,0 +1,19 @@ +(define make-previous + (let ((glob 'first-time)) + (lambda () + (let ((old 'first-time)) + (lambda (msg) + (cond ((eq? msg 'local) + (lambda (arg) + (let ((result old)) + (set! old arg) + result))) + ((eq? msg 'global) + (lambda (arg) + (let ((result glob)) + (set! glob arg) + result))) + (else (error "No such method" msg)) )))))) + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/bad-serial.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/bad-serial.scm new file mode 100644 index 0000000..1d6a486 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/bad-serial.scm @@ -0,0 +1,13 @@ +(define (make-serializer) + (let ((in-use? #f)) + (lambda (proc) + (define (protected-proc . args) + (if in-use? + (begin + (wait-a-while) ; Never mind how to do that. + (apply protected-proc args)) ; Try again. + (begin + (set! in-use? #t) ; Don't let anyone else in. + (apply proc args) ; Call the original procedure. + (set! in-use? #f)))) ; Finished, let others in again. + protected-proc))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html new file mode 100644 index 0000000..86afc8c --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="bad-serial.scm">bad-serial.scm</a> </td><td align="right">2005-04-11 00:50 </td><td align="right">467 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/dining.scm">dining.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">526 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=D;O=A new file mode 100644 index 0000000..9830fe9 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=D;O=A @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="bad-serial.scm">bad-serial.scm</a> </td><td align="right">2005-04-11 00:50 </td><td align="right">467 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/dining.scm">dining.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">526 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=D;O=D new file mode 100644 index 0000000..5403dca --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=D;O=D @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/dining.scm">dining.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">526 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="bad-serial.scm">bad-serial.scm</a> </td><td align="right">2005-04-11 00:50 </td><td align="right">467 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=M;O=A new file mode 100644 index 0000000..6a3a870 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=M;O=A @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/dining.scm">dining.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">526 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="bad-serial.scm">bad-serial.scm</a> </td><td align="right">2005-04-11 00:50 </td><td align="right">467 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=M;O=D new file mode 100644 index 0000000..9f0f7e4 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=M;O=D @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="bad-serial.scm">bad-serial.scm</a> </td><td align="right">2005-04-11 00:50 </td><td align="right">467 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/dining.scm">dining.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">526 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=N;O=D new file mode 100644 index 0000000..5403dca --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=N;O=D @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/dining.scm">dining.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">526 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="bad-serial.scm">bad-serial.scm</a> </td><td align="right">2005-04-11 00:50 </td><td align="right">467 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=S;O=A new file mode 100644 index 0000000..5c3d264 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=S;O=A @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="bad-serial.scm">bad-serial.scm</a> </td><td align="right">2005-04-11 00:50 </td><td align="right">467 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/dining.scm">dining.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">526 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=S;O=D new file mode 100644 index 0000000..5403dca --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.4/index.html?C=S;O=D @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.4</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.4</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.4/dining.scm">dining.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">526 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="bad-serial.scm">bad-serial.scm</a> </td><td align="right">2005-04-11 00:50 </td><td align="right">467 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/fib.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/fib.scm new file mode 100644 index 0000000..6a2d8e6 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/fib.scm @@ -0,0 +1,12 @@ +(define (add-streams s1 s2)(cond((stream-null? s1)s2) + ((stream-null? s2)s1) + (else (cons-stream (+ (stream-car s1) + (stream-car s2)) + (add-streams + (stream-cdr s1) + (stream-cdr s2)))))) + +(define fibs (cons-stream 0 + (cons-stream 1 + (add-streams (stream-cdr fibs) + fibs)))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html new file mode 100644 index 0000000..ec3d559 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html @@ -0,0 +1,28 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.5</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.5</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="fib.scm">fib.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">337 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/ints-from">ints-from</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> 76 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime0.scm">prime0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">166 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime1.scm">prime1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">445 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime2.scm">prime2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">640 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="show-stream.scm">show-stream.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">390 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sieve.scm">sieve.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">268 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/stream-memo.scm">stream-memo.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream-pack.scm">stream-pack.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream0.scm">stream0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">171 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream1.scm">stream1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">462 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream2.scm">stream2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">508 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="streamstate.scm">streamstate.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/why-streams">why-streams</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">381 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=D;O=A new file mode 100644 index 0000000..3ef51c8 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=D;O=A @@ -0,0 +1,28 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.5</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.5</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="fib.scm">fib.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">337 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/ints-from">ints-from</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> 76 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime0.scm">prime0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">166 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime1.scm">prime1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">445 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime2.scm">prime2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">640 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="show-stream.scm">show-stream.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">390 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sieve.scm">sieve.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">268 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/stream-memo.scm">stream-memo.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream-pack.scm">stream-pack.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream0.scm">stream0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">171 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream1.scm">stream1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">462 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream2.scm">stream2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">508 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="streamstate.scm">streamstate.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/why-streams">why-streams</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">381 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=D;O=D new file mode 100644 index 0000000..5905ef1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=D;O=D @@ -0,0 +1,28 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.5</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.5</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/why-streams">why-streams</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">381 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="streamstate.scm">streamstate.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream2.scm">stream2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">508 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream1.scm">stream1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">462 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream0.scm">stream0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">171 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream-pack.scm">stream-pack.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/stream-memo.scm">stream-memo.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sieve.scm">sieve.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">268 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="show-stream.scm">show-stream.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">390 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime2.scm">prime2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">640 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime1.scm">prime1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">445 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime0.scm">prime0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">166 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/ints-from">ints-from</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> 76 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="fib.scm">fib.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">337 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=M;O=A new file mode 100644 index 0000000..bd4b52a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=M;O=A @@ -0,0 +1,28 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.5</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.5</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="fib.scm">fib.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">337 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/ints-from">ints-from</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> 76 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime0.scm">prime0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">166 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime1.scm">prime1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">445 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime2.scm">prime2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">640 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="show-stream.scm">show-stream.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">390 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sieve.scm">sieve.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">268 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/stream-memo.scm">stream-memo.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream-pack.scm">stream-pack.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream0.scm">stream0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">171 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream1.scm">stream1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">462 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream2.scm">stream2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">508 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="streamstate.scm">streamstate.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/why-streams">why-streams</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">381 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=M;O=D new file mode 100644 index 0000000..5905ef1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=M;O=D @@ -0,0 +1,28 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.5</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.5</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/why-streams">why-streams</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">381 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="streamstate.scm">streamstate.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream2.scm">stream2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">508 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream1.scm">stream1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">462 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream0.scm">stream0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">171 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream-pack.scm">stream-pack.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/stream-memo.scm">stream-memo.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sieve.scm">sieve.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">268 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="show-stream.scm">show-stream.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">390 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime2.scm">prime2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">640 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime1.scm">prime1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">445 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime0.scm">prime0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">166 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/ints-from">ints-from</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> 76 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="fib.scm">fib.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">337 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=N;O=A new file mode 100644 index 0000000..ec3d559 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=N;O=A @@ -0,0 +1,28 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.5</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.5</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="fib.scm">fib.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">337 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/ints-from">ints-from</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> 76 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime0.scm">prime0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">166 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime1.scm">prime1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">445 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime2.scm">prime2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">640 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="show-stream.scm">show-stream.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">390 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sieve.scm">sieve.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">268 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/stream-memo.scm">stream-memo.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream-pack.scm">stream-pack.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream0.scm">stream0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">171 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream1.scm">stream1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">462 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream2.scm">stream2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">508 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="streamstate.scm">streamstate.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/why-streams">why-streams</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">381 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=N;O=D new file mode 100644 index 0000000..5905ef1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=N;O=D @@ -0,0 +1,28 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.5</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.5</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/why-streams">why-streams</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">381 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="streamstate.scm">streamstate.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream2.scm">stream2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">508 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream1.scm">stream1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">462 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream0.scm">stream0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">171 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream-pack.scm">stream-pack.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/stream-memo.scm">stream-memo.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sieve.scm">sieve.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">268 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="show-stream.scm">show-stream.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">390 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime2.scm">prime2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">640 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime1.scm">prime1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">445 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime0.scm">prime0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">166 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/ints-from">ints-from</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> 76 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="fib.scm">fib.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">337 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=S;O=A new file mode 100644 index 0000000..0f46813 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/index.html?C=S;O=A @@ -0,0 +1,28 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/3.5</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/3.5</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/?C=S;O=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/ints-from">ints-from</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> 76 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime0.scm">prime0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">166 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream0.scm">stream0.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">171 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="sieve.scm">sieve.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">268 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="fib.scm">fib.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">337 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/why-streams">why-streams</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">381 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="show-stream.scm">show-stream.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">390 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime1.scm">prime1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">445 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream1.scm">stream1.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">462 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream2.scm">stream2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">508 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prime2.scm">prime2.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">640 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.5/stream-memo.scm">stream-memo.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="stream-pack.scm">stream-pack.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">1.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="streamstate.scm">streamstate.scm</a> </td><td align="right">2003-04-25 12:52 </td><td align="right">2.2K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/prime0.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/prime0.scm new file mode 100644 index 0000000..ed84766 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/prime0.scm @@ -0,0 +1,8 @@ + + +(define (prime? n) + (define (iter factor) + (cond ((= factor n) #t) + ((= (remainder n factor) 0) #f) + (else (iter (+ factor 1))))) + (iter 2)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/prime1.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/prime1.scm new file mode 100644 index 0000000..35f7a70 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/prime1.scm @@ -0,0 +1,22 @@ + + +(define (prime? n) + (null? (filter (lambda (x) (= (remainder n x) 0)) + (range 2 (- n 1))))) + +(define (range from to) + (if (> from to) + '() + (cons from (range (+ from 1) to)))) + + +(define (filter predicate data) + (cond ((null? data) '()) + ((predicate (car data)) + (cons (car data) (filter predicate (cdr data)))) + (else (filter predicate (cdr data))))) + + + + +;; try (filter prime? (range 2 100)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/prime2.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/prime2.scm new file mode 100644 index 0000000..4df4e92 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/prime2.scm @@ -0,0 +1,22 @@ + + +(define (stream-prime? n) + (stream-null? (stream-filter (lambda (x) (= (remainder n x) 0)) + (stream-range 2 (- n 1))))) + +(define (stream-range from to) + (if (> from to) + the-empty-stream + (cons-stream from (stream-range (+ from 1) to)))) + +(define (stream-filter predicate data) + (cond ((stream-null? data) the-empty-stream) + ((predicate (stream-car data)) + (cons-stream (stream-car data) + (stream-filter predicate (stream-cdr data)))) + (else (stream-filter predicate (stream-cdr data))))) + +;; try (define s (stream-filter stream-prime? (stream-range 2 100))) +;; s +;; (display-stream s) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/show-stream.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/show-stream.scm new file mode 100644 index 0000000..e9d42f3 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/show-stream.scm @@ -0,0 +1,15 @@ + +(define (show-stream strm . args) ;2nd arg is how many + (if (null? args) + (ss1 strm 10 10) + (ss1 strm (car args) (car args)))) + +(define ss show-stream) + +(define (ss1 strm this all) + (cond ((null? strm) '()) + ((= this 0) '(...)) + ((and (pair? strm) (procedure? (cdr strm))) + (cons (ss1 (stream-car strm) all all) + (ss1 (stream-cdr strm) (- this 1) all))) + (else strm))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/sieve.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/sieve.scm new file mode 100644 index 0000000..bff92b3 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/sieve.scm @@ -0,0 +1,10 @@ +(define (divisible? x y) (= (remainder x y) 0)) + +(define (sieve stream) + (cons-stream + (stream-car stream) + (sieve (stream-filter + (lambda (x) (not (divisible? x (stream-car stream)))) + (stream-cdr stream))))) + +(define primes (sieve (stream-cdr integers))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream-pack.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream-pack.scm new file mode 100644 index 0000000..826b06c --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream-pack.scm @@ -0,0 +1,52 @@ +;; review notes for 4/10/98 +;;can you deadlock on this? + +(parallel-execute (exchange-account a b)(exchange-account a c)) ? + + +what do these do: + +(define a (cons-stream a a)) + +(define a (cons-stream 'a a)) +(show-stream a) +(define a (cons-stream a a)) +(show-stream a) + + +what is the difference between eq? and equal? + +(eq? () '()) + + +(pair? ()) + +;; pack a finite stream with infinite newelements on end + +(define (pack-stream s newelement) + (if (stream-null? s) + (cons-stream newelement(pack-stream s newelement)) + (cons-stream (stream-car s) (pack-stream (stream-cdr s) newelement)))) + +;or (buggy) + +(define (pack-stream s newelement) + (if (stream-null? s) (let ((a (cons-stream newelement a))) a) + (cons-stream (stream-car s) (pack-stream (stream-cdr s) newelement)))) + + +; or (still buggy) + +(define (pack-stream s newelement) + (if (stream-null? s) (let ((a nil)) + (set! a (cons-stream newelement a))) + (cons-stream (stream-car s) (pack-stream (stream-cdr s) newelement)))) +; ok + +(define (pack-stream s newelement) + (if (stream-null? s) (let ((a nil)) + (set! a (cons-stream newelement a)) + a) + (cons-stream (stream-car s) (pack-stream (stream-cdr s) newelement)))) + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream0.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream0.scm new file mode 100644 index 0000000..d6f15da --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream0.scm @@ -0,0 +1,6 @@ +(define (perfect? n) + (define (iter i sum) + (cond ((= i n) sum) + ((= 0 (remainder n i)) (iter (1+ i) (+ sum i))) + (else (iter (1+ i) sum)) )) + (= n (iter 1 0)) ) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream1.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream1.scm new file mode 100644 index 0000000..58c7061 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream1.scm @@ -0,0 +1,20 @@ +(define (filter f lis) + (cond ((null? lis) nil) + ((f (car lis)) (cons (car lis) (filter f (cdr lis)))) + (else (filter f (cdr lis))) )) + +(define (accumulate f start lis) + (if (null? lis) + start + (f (car lis) (accumulate f start (cdr lis))) )) + +(define (range a b) + (if (> a b) + nil + (cons a (range (1+ a) b)) )) + +(define (perfect? n) + (= n (accumulate + + 0 + (filter (lambda (x) (= 0 (remainder n x))) + (range 1 (-1+ n)) ) ))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream2.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream2.scm new file mode 100644 index 0000000..75258b0 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/stream2.scm @@ -0,0 +1,20 @@ +(define (filter f strm) + (cond ((empty-stream? strm) nil) + ((f (head strm)) (cons-stream (head strm) (filter f (tail strm)))) + (else (filter f (tail strm))) )) + +(define (accumulate f start strm) + (if (empty-stream? strm) + start + (f (head strm) (accumulate f start (tail strm))) )) + +(define (range a b) + (if (> a b) + nil + (cons-stream a (range (1+ a) b)) )) + +(define (perfect? n) + (= n (accumulate + + 0 + (filter (lambda (x) (= 0 (remainder n x))) + (range 1 (-1+ n)) ) ))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/streamstate.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/streamstate.scm new file mode 100644 index 0000000..a514f90 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.5/streamstate.scm @@ -0,0 +1,87 @@ +(define (stream-withdraw balance amount-stream) + (cons-stream balance + (stream-withdraw (- balance + (head amount-stream)) + (tail amount-stream)))) + +;; a withdrawal stream + +(define (wd-stream)(cons-stream (prompt)(wd-stream))) + +(define (prompt)(print "new withdrawal -->")(read)) + +(define mywd (wd-stream)) + +;;; insert a few values by (tail(tail (tail mywd))) + +;;; (stream-withdraw 100 mywd) + + +(define (for-each-stream proc stream) + (if (empty-stream? stream) + 'done + (sequence (proc (head stream)) + (for-each-stream proc (tail stream))))) + +;; print a (finite) stream. + +(define (print-stream s) + (for-each-stream print s)) + +(define ps print-stream) + +(define (for-each-stream-count proc stream n) + (if (or (= n 0) (empty-stream? stream)) + 'done + (sequence (proc (head stream)) + (for-each-stream-count proc (tail stream) (+ n -1))))) + +(define (psn s n)(for-each-stream-count print s n)) + +;;;;;;;;;;;;;;;; + +;;; TAYLOR SERIES +;;; (we could use abstraction better here...) +;;; a term in a series looks like (a b) , a list +;;; signifying b*x^a + +;; here is the number 1 = 1*x^0 + + (define unit-term (list 0 1)) ;; could be (make-term 0 1) + +(define (integrate-series series) + (map integrate-term series)) + +;;; to integrate b*x^a with respect to x, produce +;;; (b/(a+1)*x^(a+1) + +(define (integrate-term tt) + (let ((new-order (1+ (car tt)))) ;; could use (order tt) instead of car + (list new-order (/ (cadr tt) new-order)))) ;; make-term; coeff; + +(define exp-series (cons-stream unit-term (integrate-series exp-series))) + +;; (- integrate sin) to get cos (also, cos(0) = 1) + +;; cos x is 1 -x^2/2 + x^4/4! + .. + +;; 1 -0.5 x^2 + 0.04166 x^4+ ... + +(define cos-series (cons-stream unit-term + (neg-st (integrate-series sin-series)))) + + +;; we need to compute the negative of a "taylor series stream" + +(define (neg-st s)(if (empty-stream? s) s + (cons-stream (list (car (head s))(- (cadr (head s)))) + (neg-st (tail s))))) + +;; integrate cos to get sin + +(define sin-series (integrate-series cos-series)) + +;;; sin x = x -x^3/3!+ x^5/5! + ... +;;; x - 0.166 x^3 + 0.0083*x^5 + ... + +;;(psn sin-series 5) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html new file mode 100644 index 0000000..369dec7 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/4.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/4.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="old-MCE-questions">old-MCE-questions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.2/old-MCE-solutions">old-MCE-solutions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pairs.scm">pairs.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="while.scm">while.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">416 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=D;O=A new file mode 100644 index 0000000..7acbaf4 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=D;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/4.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/4.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="old-MCE-questions">old-MCE-questions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.2/old-MCE-solutions">old-MCE-solutions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pairs.scm">pairs.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="while.scm">while.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">416 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=D;O=D new file mode 100644 index 0000000..850f1d1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=D;O=D @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/4.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/4.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="while.scm">while.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">416 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pairs.scm">pairs.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.2/old-MCE-solutions">old-MCE-solutions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="old-MCE-questions">old-MCE-questions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=M;O=A new file mode 100644 index 0000000..3bfcada --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=M;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/4.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/4.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="old-MCE-questions">old-MCE-questions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.2/old-MCE-solutions">old-MCE-solutions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pairs.scm">pairs.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="while.scm">while.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">416 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=M;O=D new file mode 100644 index 0000000..850f1d1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=M;O=D @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/4.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/4.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="while.scm">while.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">416 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pairs.scm">pairs.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.2/old-MCE-solutions">old-MCE-solutions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="old-MCE-questions">old-MCE-questions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=N;O=A new file mode 100644 index 0000000..369dec7 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=N;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/4.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/4.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="old-MCE-questions">old-MCE-questions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.2/old-MCE-solutions">old-MCE-solutions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pairs.scm">pairs.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="while.scm">while.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">416 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=N;O=D new file mode 100644 index 0000000..850f1d1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=N;O=D @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/4.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/4.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="while.scm">while.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">416 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pairs.scm">pairs.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.2/old-MCE-solutions">old-MCE-solutions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="old-MCE-questions">old-MCE-questions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=S;O=A new file mode 100644 index 0000000..6092a5a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=S;O=A @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/4.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/4.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="while.scm">while.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">416 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pairs.scm">pairs.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="old-MCE-questions">old-MCE-questions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.2/old-MCE-solutions">old-MCE-solutions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.8K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=S;O=D new file mode 100644 index 0000000..17bc0d3 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/index.html?C=S;O=D @@ -0,0 +1,18 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/4.2</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/4.2</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.2/old-MCE-solutions">old-MCE-solutions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="old-MCE-questions">old-MCE-questions</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pairs.scm">pairs.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="while.scm">while.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">416 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/old-MCE-questions b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/old-MCE-questions new file mode 100644 index 0000000..d00120f --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/old-MCE-questions @@ -0,0 +1,144 @@ +Here are several metacircular evaluator questions from past 60A final exams. +For each of these questions, you should go through these three steps: + +(a) Is this primarily a change to eval (based on the current environment) or + to apply (based on a procedure's execution environment)? + +(b) Which specific subprocedure should be changed? + +(c) Then write the code. + +The first two steps are most important! + +-------------------------------------------------- + +1. Modify the metacircular evaluator to accept a new kind of cond clause, +as explained below. We are interested in the situation in which some +expression is computed as the predicate part of a clause, and then if that +expression is non-nil, the same expression is part of the desired return +value. For example, suppose we have an association list like + +((I . 1) (V . 5) (X . 10) (L . 50) (C . 100) (D . 500) (M . 1000)) + +The tool we have for looking things up in such a list is assq, which +returns the entire pair whose car matches its argument: + +> (assq 'L roman-number-list) +(L . 50) + +Suppose we want to find the numeric value for a given letter. We could +define the following procedure: + +(define (value letter) + (cond ((assq letter roman-number-list) + (cdr (assq letter roman-number-list))) + (else nil))) + +but this involves computing the call to assq twice. Alternatively, +we could use a let outside the cond, but that's awkward if +the cond has several clauses and only one requires this value. +For example, using a let would be tricky if the example were + +(define (value letter-or-number) + (cond ((number? letter-or-number) letter-or-number) + ((assq letter-or-number roman-number-list) + (cdr (assq letter-or-number roman-number-list))) + (else nil))) + +Here is how this would look using the new syntax you are going to invent: + +(define (value letter-or-number) + (cond ((number? letter-or-number) letter-or-number) + ((assq letter-or-number roman-number-list) => cdr) + (else nil))) + +The first and third clauses are unchanged. The second clause uses the new +syntax. It has exactly three elements; the second of those three is the +keyword => to indicate the use of this syntax, and the third is an +expression whose value is a one-argument procedure (the symbol cdr). If the +value of the first expression is non-nil, then cond should evaluate the +third element and apply that function to the value of the first element. + + + +2. (This is the one we did in class.) + +(a) Modify the metacircular evaluator so that it always evaluates +the arguments in a procedure call from left to right, regardless +of the order of evaluation in the underlying Scheme. + +(b) Does your modified evaluator always evaluate the procedure +expression before it evaluates the argument expressions, regardless +of the underlying Scheme? For example, in evaluating the expression + +(foo a b) + +will your evaluator always look up FOO before looking up A? Explain +why or why not. + +(c) Show an example interaction with Scheme in which the result of the +interaction depends on whether or not the procedure expression is evaluated +before the argument expressions. + + + +3. Modify the metacircular evaluator to allow type-checking of arguments to +procedures. Here is how the feature should work. When a new procedure is +defined, a formal parameter can be either a symbol as usual or else a list +of two elements. In this case, the second element is a symbol, the name of +the formal parameter. The first element is an expression whose value is +a predicate function. That function should return #t if the argument +is valid. For example, here is a procedure foo that has type-checked +parameters num and list: + +> (define (foo (integer? num) ((lambda (x) (not (null? x))) list)) + (nth num list)) +FOO +> (foo 3 '(a b c d e)) +C +> (foo 3.5 '(a b c d e)) +Error: wrong argument type -- 3.5 +> (foo 2 '()) +Error: wrong argument type -- () + +In this example we define a procedure foo with two formal parameters, named +num and list. When foo is invoked, the evaluator will check to see that the +first actual argument is an integer and that the second actual argument is +not empty. The expression whose value is the desired predicate function +should be evaluated with respect to foo's defining environment. + + + +4. Suppose you have a procedure that takes several arguments, e.g., + +(define (foo a b c d e f) ...) + +Now you want to invoke this procedure. You are providing values explicitly +for the parameters a and b, but you have the remaining arguments in a list. +If you had all the arguments in a list, you could say + +(apply foo arglist) + +but instead you have to say something awkward like + +(apply foo (cons a-value (cons b-value arglist))) + +We'd like to invent a new notation, allowing you to invoke the procedure +by saying + +(foo a-value b-value . arglist) + +In this notation, arglist must be a symbol whose value is a list. Your job +is to modify the metacircular evaluator to accept this notation. + +NOTE 1: Although this looks similar to the notation + +(define (foo a b . args) ...) + +used to create a procedure that accepts variable numbers of arguments, it's +not the same feature. This time we're talking about the invocation +of the procedure, not the definition of the procedure. + +NOTE 2: You should assume that the (read) procedure has already taken +care of translating the dot notation into an improper list, which is what +you'll see as the expression to be evaluated. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/pairs.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/pairs.scm new file mode 100644 index 0000000..37e3a98 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/pairs.scm @@ -0,0 +1,40 @@ +;;; The integers. + +(define (ints-from n) + (cons-stream n (ints-from (+ n 1)))) + +(define integers (ints-from 1)) + +;;; pairs of integers, A&S version + +(define (pairs s t) + (cons-stream + (list (stream-car s) (stream-car t)) + (interleave + (stream-map (lambda (x) (list (stream-car s) x)) + (stream-cdr t)) + (pairs (stream-cdr s) (stream-cdr t))))) + +;;; Louis Reasoner's version, ex. 3.68 + +(define (louis-pairs s t) + (interleave + (stream-map (lambda (x) (list (stream-car s) x)) + t) + (louis-pairs (stream-cdr s) (stream-cdr t)))) + +;;; Fixing Louis's version with explicit DELAY and FORCE + +(define (fixed-pairs s t) + (interleave-delayed + (stream-map (lambda (x) (list (stream-car s) x)) + t) + (delay (fixed-pairs (stream-cdr s) (stream-cdr t))))) + +(define (interleave-delayed s1 delayed-s2) + (if (stream-null? s1) + (force delayed-s2) + (cons-stream (stream-car s1) + (interleave-delayed (force delayed-s2) + (delay (stream-cdr s1)))))) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/while.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/while.scm new file mode 100644 index 0000000..640812b --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/while.scm @@ -0,0 +1,17 @@ + (define (while a b)(if (a) (begin (force b) (while a b)) 'done)) + + (define (while a b)(if (a) (begin (b) (while a b)) 'done)) + +(let ((x 10)) +(while (lambda() (> x 0)) (lambda()(display x)(set! x (- x 1))))) ;works + + +(define (while a b)(if (a) (begin (b) (while a b))) + + +(let ((x 10)) + (while (delay (> x 0)) + (delay (begin (display x) + (set! x (- x 1)))) + ; does not work because of memoization + )) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html new file mode 100644 index 0000000..bdc4250 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html @@ -0,0 +1,15 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/Net</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/Net</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=D;O=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="stk-sockets">stk-sockets</a> </td><td align="right">2003-01-22 15:50 </td><td align="right">6.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=M;O=A new file mode 100644 index 0000000..57eebf1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=M;O=A @@ -0,0 +1,15 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/Net</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/Net</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=D;O=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="stk-sockets">stk-sockets</a> </td><td align="right">2003-01-22 15:50 </td><td align="right">6.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=M;O=D new file mode 100644 index 0000000..94c10eb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=M;O=D @@ -0,0 +1,15 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/Net</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/Net</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=D;O=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="stk-sockets">stk-sockets</a> </td><td align="right">2003-01-22 15:50 </td><td align="right">6.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=N;O=D new file mode 100644 index 0000000..94c10eb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=N;O=D @@ -0,0 +1,15 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/Net</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/Net</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=D;O=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="stk-sockets">stk-sockets</a> </td><td align="right">2003-01-22 15:50 </td><td align="right">6.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=S;O=A new file mode 100644 index 0000000..67d69a7 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=S;O=A @@ -0,0 +1,15 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/Net</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/Net</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=D;O=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="stk-sockets">stk-sockets</a> </td><td align="right">2003-01-22 15:50 </td><td align="right">6.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=S;O=D new file mode 100644 index 0000000..94c10eb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/index.html?C=S;O=D @@ -0,0 +1,15 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/Net</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/Net</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/Net/?C=D;O=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/text.gif" alt="[TXT]"></td><td><a href="stk-sockets">stk-sockets</a> </td><td align="right">2003-01-22 15:50 </td><td align="right">6.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/stk-sockets b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/stk-sockets new file mode 100644 index 0000000..78d875d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/Net/stk-sockets @@ -0,0 +1,164 @@ +6.23 Sockets + +STk defines sockets, on systems which support them, as first class objects. +Sockets permit processes to communicate even if they are on different +machines. Sockets are useful for creating client-server applications. + +(make-client-socket hostname port-number) procedure + +make-client-socket returns a new socket object. This socket establishes a link +between the running application listening on port port-number of hostname. + +(socket? socket) procedure + +Returns #t if socket is a socket, otherwise returns #f. + +(socket-host-name socket) procedure + +Returns a string which contains the name of the distant host attached to +socket. If socket has been created with make-client-socket this procedure +returns the official name of the distant machine used for connection. If +socket has been created with make-server-socket, this function returns the +official name of the client connected to the socket. If no client has used yet +the socket, this function returns #f. + +(socket-host-address socket) procedure + +Returns a string which contains the IP number of the distant host attached to +socket. If socket has been created with make-client-socket this procedure +returns the IP number of the distant machine used for connection. If socket +has been created with make-server-socket, this function returns the address of +the client connected to the socket. If no client has used yet the socket, this +function returns #f. + +(socket-local-address socket) procedure + +Returns a string which contains the IP number of the local host attached to +socket. + +(socket-port-number socket) procedure + +Returns the integer number of the port used for socket. + +(socket-input socket) procedure +(socket-output socket) procedure + +Returns the file port associated for reading or writing with the program +connected with socket. If no connection has already been established, these +functions return #f. The following example shows how to make a client socket. +Here we create a socket on port 13 of the machine kaolin.unice.fr: + +(let ((s (make-client-so cke t "kaolin.unice.fr" 13))) + (format #t "Time is: ~A\\n" (read-line (socket-input s))) + (socket-shutdow n s)) + +(make-server-socket) procedure +(make-server-socket port-number) procedure + +make-server-socket returns a new socket object. If port-number is specified, +the socket is listening on the specified port; otherwise, the communication +port is chosen by the system. + +(socket-accept-connection socket) procedure + +socket-accept-connection waits for a client connection on the given socket. If +no client is already waiting for a connection, this procedure blocks its +caller; otherwise, the first connection request on the queue of pending +connections is connected to socket. This procedure must be called on a server +socket created with make-server-socket. The result of socket-accept-connection +is undefined. The following example is a simple server which waits for a +connection on the port 1234. Once the connection with the distant program is +established, we read a line on the input port associated to the socket and we +write the length of this line on its output port. [port 13 is generally used +for testing: making a connection to it permits to know the distant system's +idea of the time of day. Under Unix, you can simply connect to listening +socket with the telnet command. With the given example, this can be achieved +by typing the following command in a window shell: $ telnet localhost 1234] + +(let ((s (make-server-socket 1234))) + (socket-accept-connections) + (let ((l (read-line (socket-input s)))) + (format (socket-output s) "Length is: ~A\\n" (string-length l)) + (flush (socket-output s))) + (socket-shutdown s)) + +(socket-shutdown socket) procedure +(socket-shutdown socket close) procedure + +Socket-shutdown shutdowns the connection associated to socket. Close is a +boolean; it indicates if the socket must be closed or not, when the connection +is destroyed. Closing the socket forbids further connections on the same port +with the socket-accept-connection procedure. Omitting a value for close +implies the closing of socket. The result of socket-shutdown is undefined. +The following example shows a simple server: when there is a new connection +on the port number 1234, the server displays the first line sent to it by the +client, discards the others and go back waiting for further client +connections. + +(let ((s (make-server-socket 1234))) + (let loop () + (socket-accept-connections) + (format #t "I've read: ~A\\n" (read-line (socket-input s))) + (socket-shutdown s #f) + (loop))) + +(socket-down? socket) procedure + +Returns #t if socket has been previously closed with socket-shutdown. It +returns #f otherwise. + +(socket-dup socket) procedure + +Returns a copy of socket. The original and the copy socket can be used +interchangeably. However, if a new connection is accepted on one socket, the +characters exchanged on this socket are not visible on the other socket. +Duplicating a socket is useful when a server must accept multiple simultaneous +connections. The following example creates a server listening on port 1234. +This server is duplicated and, once two clients are present, a message is sent +on both connections. + +(define s1 (make-server-socket 1234)) +(define s2 (socket-dup s1)) +(socket-accept-connection s1) +(socket-accept-connection s2) ;; blocks until two clients are present +(display "Hello,\\n" (socket-output s1)) +(display "world\\n" (socket-output s2)) +(flush (socket-output s1)) +(flush (socket-output s2)) + +(when-socket-ready socket handler) procedure +(when-socket-ready socket) procedure + +Defines a handler for socket. The handler is a thunk which is executed when a +connection is available on socket. If the special value #f is provided as +handler , the current handler for socket is deleted. If a handler is +provided, the value returned by when-socket-ready is undefined. Otherwise, it +returns the handler currently associated to socket. This procedure, in +conjunction with socket-dup permits to build multiple-clients servers which +work asynchronously. Such a server is shown below. + +(define p (make-server-socket 1234)) +(when-socket-ready p + (let ((count 0)) + (lambda () + (set! count (+ count 1)) + (register-connection (socket-dup p) count)))) +(define register-connection + (let ((sockets '())) + (lambda (s cnt) + ;; Accept connection + (socket-accept-connection s) + ;; Save socket somewhere to avoid GC problems + (set! sockets (cons s sockets)) + ;; Create a handler for reading inputs from this new connection + (let ((in (socket-input s)) + (out (socket-output s))) + (when-port-readable in + (lambda () + (let ((l (read-line in))) + (if (eof-object? l) + ;; delete current handler + (when-port-readable in #f) + ;; Just write the line read on the socket + (begin (format out "On #~A --> ~A\\n" cnt l) + (flush out)))))))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/errors b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/errors new file mode 100644 index 0000000..825b0ec --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/errors @@ -0,0 +1,26 @@ + + +(define (list-of-squares nums) + (define (square (car nums)) + (* (car nums) (car nums))) + (if (null? nums) + nil + (cons (square (car nums)) + (list-of-squares (cdr nums))))) + + + + +(set! (cdr x) nil) + + + + + +(define (assq sym alis) + (cond ((null? alis) nil) + ((eq? sym (caar alis)) + (car alis)) + (else + (set! alis (cdr alis)) + (assq sym alis)))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=D;O=A new file mode 100644 index 0000000..86de32d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=D;O=A @@ -0,0 +1,35 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.1/index.html">1.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.2/index.html">1.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.3/index.html">1.3/</a> </td><td align="right">2001-08-13 16:27 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.1/index.html">2.1/</a> </td><td align="right">2007-09-21 10:05 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.2/index.html">2.2/</a> </td><td align="right">2007-10-01 15:45 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.4/index.html">2.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.0/index.html">3.0/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.1/">3.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.2/index.html">3.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.3/">3.3/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.4/index.html">3.4/</a> </td><td align="right">2000-07-25 13:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.5/index.html">3.5/</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.1/">4.1/</a> </td><td align="right">2003-05-03 09:24 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="4.2/index.html">4.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.4/">4.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="Net/index.html">Net/</a> </td><td align="right">2003-01-22 15:50 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="errors">errors</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">364 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/groupreduce.scm">groupreduce.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce-demo.scm">mapreduce-demo.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/summary">summary</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="unix/index.html">unix/</a> </td><td align="right">2020-01-22 14:08 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=D;O=D new file mode 100644 index 0000000..8efb5f4 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=D;O=D @@ -0,0 +1,35 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="unix/index.html">unix/</a> </td><td align="right">2020-01-22 14:08 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/summary">summary</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce-demo.scm">mapreduce-demo.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/groupreduce.scm">groupreduce.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="errors">errors</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">364 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="Net/index.html">Net/</a> </td><td align="right">2003-01-22 15:50 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.4/">4.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="4.2/index.html">4.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.1/">4.1/</a> </td><td align="right">2003-05-03 09:24 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.5/index.html">3.5/</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.4/index.html">3.4/</a> </td><td align="right">2000-07-25 13:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.3/">3.3/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.2/index.html">3.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.1/">3.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.0/index.html">3.0/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.4/index.html">2.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.2/index.html">2.2/</a> </td><td align="right">2007-10-01 15:45 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.1/index.html">2.1/</a> </td><td align="right">2007-09-21 10:05 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.3/index.html">1.3/</a> </td><td align="right">2001-08-13 16:27 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.2/index.html">1.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.1/index.html">1.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=M;O=A new file mode 100644 index 0000000..53639e1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=M;O=A @@ -0,0 +1,35 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.1/index.html">1.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.2/index.html">1.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.4/index.html">2.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.0/index.html">3.0/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.1/">3.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.2/index.html">3.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.3/">3.3/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="4.2/index.html">4.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.4/">4.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="errors">errors</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">364 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/summary">summary</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.4/index.html">3.4/</a> </td><td align="right">2000-07-25 13:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.3/index.html">1.3/</a> </td><td align="right">2001-08-13 16:27 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="Net/index.html">Net/</a> </td><td align="right">2003-01-22 15:50 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.5/index.html">3.5/</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.1/">4.1/</a> </td><td align="right">2003-05-03 09:24 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.1/index.html">2.1/</a> </td><td align="right">2007-09-21 10:05 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.2/index.html">2.2/</a> </td><td align="right">2007-10-01 15:45 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/groupreduce.scm">groupreduce.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce-demo.scm">mapreduce-demo.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="unix/index.html">unix/</a> </td><td align="right">2020-01-22 14:08 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=M;O=D new file mode 100644 index 0000000..4e87aa1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=M;O=D @@ -0,0 +1,35 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="unix/index.html">unix/</a> </td><td align="right">2020-01-22 14:08 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce-demo.scm">mapreduce-demo.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/groupreduce.scm">groupreduce.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.2/index.html">2.2/</a> </td><td align="right">2007-10-01 15:45 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.1/index.html">2.1/</a> </td><td align="right">2007-09-21 10:05 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.1/">4.1/</a> </td><td align="right">2003-05-03 09:24 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.5/index.html">3.5/</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="Net/index.html">Net/</a> </td><td align="right">2003-01-22 15:50 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.3/index.html">1.3/</a> </td><td align="right">2001-08-13 16:27 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.4/index.html">3.4/</a> </td><td align="right">2000-07-25 13:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/summary">summary</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="errors">errors</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">364 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.4/">4.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="4.2/index.html">4.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.3/">3.3/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.2/index.html">3.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.1/">3.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.0/index.html">3.0/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.4/index.html">2.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.2/index.html">1.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.1/index.html">1.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=N;O=A new file mode 100644 index 0000000..bc58487 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=N;O=A @@ -0,0 +1,35 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.1/index.html">1.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.2/index.html">1.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.3/index.html">1.3/</a> </td><td align="right">2001-08-13 16:27 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.1/index.html">2.1/</a> </td><td align="right">2007-09-21 10:05 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.2/index.html">2.2/</a> </td><td align="right">2007-10-01 15:45 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.4/index.html">2.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.0/index.html">3.0/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.1/">3.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.2/index.html">3.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.3/">3.3/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.4/index.html">3.4/</a> </td><td align="right">2000-07-25 13:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.5/index.html">3.5/</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.1/">4.1/</a> </td><td align="right">2003-05-03 09:24 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="4.2/index.html">4.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.4/">4.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="Net/index.html">Net/</a> </td><td align="right">2003-01-22 15:50 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="errors">errors</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">364 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/groupreduce.scm">groupreduce.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce-demo.scm">mapreduce-demo.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/summary">summary</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="unix/index.html">unix/</a> </td><td align="right">2020-01-22 14:08 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=N;O=D new file mode 100644 index 0000000..8efb5f4 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=N;O=D @@ -0,0 +1,35 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="unix/index.html">unix/</a> </td><td align="right">2020-01-22 14:08 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/summary">summary</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce-demo.scm">mapreduce-demo.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/groupreduce.scm">groupreduce.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="errors">errors</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">364 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="Net/index.html">Net/</a> </td><td align="right">2003-01-22 15:50 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.4/">4.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="4.2/index.html">4.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.1/">4.1/</a> </td><td align="right">2003-05-03 09:24 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.5/index.html">3.5/</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.4/index.html">3.4/</a> </td><td align="right">2000-07-25 13:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.3/">3.3/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.2/index.html">3.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.1/">3.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.0/index.html">3.0/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.4/index.html">2.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.2/index.html">2.2/</a> </td><td align="right">2007-10-01 15:45 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.1/index.html">2.1/</a> </td><td align="right">2007-09-21 10:05 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.3/index.html">1.3/</a> </td><td align="right">2001-08-13 16:27 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.2/index.html">1.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.1/index.html">1.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=S;O=A new file mode 100644 index 0000000..57c84e5 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=S;O=A @@ -0,0 +1,35 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.1/index.html">1.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.2/index.html">1.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.3/index.html">1.3/</a> </td><td align="right">2001-08-13 16:27 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.1/index.html">2.1/</a> </td><td align="right">2007-09-21 10:05 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.2/index.html">2.2/</a> </td><td align="right">2007-10-01 15:45 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.4/index.html">2.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.0/index.html">3.0/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.1/">3.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.2/index.html">3.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.3/">3.3/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.4/index.html">3.4/</a> </td><td align="right">2000-07-25 13:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.5/index.html">3.5/</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.1/">4.1/</a> </td><td align="right">2003-05-03 09:24 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="4.2/index.html">4.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.4/">4.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="Net/index.html">Net/</a> </td><td align="right">2003-01-22 15:50 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="unix/index.html">unix/</a> </td><td align="right">2020-01-22 14:08 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="errors">errors</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">364 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/summary">summary</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce-demo.scm">mapreduce-demo.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/groupreduce.scm">groupreduce.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">4.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=S;O=D new file mode 100644 index 0000000..d973de5 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/index.html?C=S;O=D @@ -0,0 +1,35 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/groupreduce.scm">groupreduce.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mapreduce-demo.scm">mapreduce-demo.scm</a> </td><td align="right">2009-11-13 09:40 </td><td align="right">2.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/summary">summary</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="errors">errors</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">364 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="unix/index.html">unix/</a> </td><td align="right">2020-01-22 14:08 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="Net/index.html">Net/</a> </td><td align="right">2003-01-22 15:50 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.4/">4.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="4.2/index.html">4.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/4.1/">4.1/</a> </td><td align="right">2003-05-03 09:24 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.5/index.html">3.5/</a> </td><td align="right">2003-04-25 12:52 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.4/index.html">3.4/</a> </td><td align="right">2000-07-25 13:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.3/">3.3/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.2/index.html">3.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/3.1/">3.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="3.0/index.html">3.0/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.4/index.html">2.4/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.2/index.html">2.2/</a> </td><td align="right">2007-10-01 15:45 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="2.1/index.html">2.1/</a> </td><td align="right">2007-09-21 10:05 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.3/index.html">1.3/</a> </td><td align="right">2001-08-13 16:27 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.2/index.html">1.2/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/folder.gif" alt="[DIR]"></td><td><a href="1.1/index.html">1.1/</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/mapreduce-demo.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/mapreduce-demo.scm new file mode 100644 index 0000000..70a0035 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/mapreduce-demo.scm @@ -0,0 +1,61 @@ +;; CS 61A Mapreduce lecture demos + +;; Count how many times any word is used in the title of a Beatles song: + +(define (wordcount-mapper document-line-kv-pair) + (map (lambda (wd-in-line) (make-kv-pair wd-in-line 1)) + (kv-value document-line-kv-pair))) + +(define wordcounts (mapreduce wordcount-mapper + 0 "/beatles-songs")) + +(ss wordcounts) + +;; How to examine a distributed file + +(ss (mapreduce list cons-stream the-empty-stream "/beatles-songs")) + +;; Find the most commonly used word in any Beatles title. +;; (This actually gets the most commonly used word per initial letter; +;; another reduction on a single machine is needed to get the absolutely +;; most commonly used word.) + +(define (find-max-mapper kv-pair) + (list (make-kv-pair (first (kv-key kv-pair)) + kv-pair))) + +(define (find-max-reducer current so-far) + (if (> (kv-value current) (kv-value so-far)) + current + so-far)) + +(define frequent (mapreduce find-max-mapper find-max-reducer + (make-kv-pair 'foo 0) wordcounts)) + +(ss frequent) + +(stream-accumulate find-max-reducer (make-kv-pair 'foo 0) + (stream-map kv-value frequent)) + +;; Find the total number of lines of text in all of Shakespeare: + +(define will (mapreduce (lambda (kv-pair) (list (make-kv-pair 'line 1))) + + 0 "/gutenberg/shakespeare")) + + +;; This is the desired result from the modification of the above program +;; to find line counts per play. + +'((a-midsummer-nights-dream . 2456) (alls-well-that-ends-well . 3231) + (henry-v . 3643) (loves-labours-lost . 3015) (macbeth . 2900) + (the-taming-of-the-shrew . 3033) (the-tempest . 2644) (king-john . 3028) + (the-merry-wives-of-windsor . 3152) (the-winters-tale . 3595) + (timon-of-athens . 2852) (troilus-and-cressida . 3983) + (as-you-like-it . 2974) (cymbeline . 4164) (henry-iv-1 . 3355) + (henry-vi-1 . 3409) (king-lear . 3985) (sonnets . 2626) + (the-tragedy-of-antony-and-cleopatra . 4175) + (the-tragedy-of-coriolanus . 4277) (the-two-gentlemen-of-verona . 2559) + (a-lovers-complaint . 385) (hamlet . 4553) (henry-iv-2 . 3587) + (henry-vi-2 . 3646) (measure-for-measure . 3119) (othello . 3897) + (richard-iii . 4541) (twelfth-night . 2801) (henry-vi-3 . 3524) + (henry-viii . 3765) (much-ado-about-nothing . 2789) + (romeo-and-juliet . 3620) (the-duke-of-venice . 2968)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html new file mode 100644 index 0000000..ed3b3ad --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/unix</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/unix</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/unix/spell">spell</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">102 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="steps">steps</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">215 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="words">words</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">399K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=D;O=A new file mode 100644 index 0000000..c554c00 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=D;O=A @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/unix</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/unix</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/unix/spell">spell</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">102 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="steps">steps</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">215 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="words">words</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">399K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=D;O=D new file mode 100644 index 0000000..1683def --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=D;O=D @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/unix</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/unix</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="words">words</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">399K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="steps">steps</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">215 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/unix/spell">spell</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">102 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=M;O=A new file mode 100644 index 0000000..64ee941 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=M;O=A @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/unix</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/unix</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/unix/spell">spell</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">102 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="steps">steps</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">215 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="words">words</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">399K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=M;O=D new file mode 100644 index 0000000..1683def --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=M;O=D @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/unix</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/unix</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="words">words</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">399K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="steps">steps</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">215 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/unix/spell">spell</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">102 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=N;O=A new file mode 100644 index 0000000..ed3b3ad --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=N;O=A @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/unix</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/unix</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/unix/spell">spell</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">102 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="steps">steps</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">215 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="words">words</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">399K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=N;O=D new file mode 100644 index 0000000..1683def --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=N;O=D @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/unix</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/unix</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="words">words</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">399K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="steps">steps</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">215 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/unix/spell">spell</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">102 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=S;O=A new file mode 100644 index 0000000..db52bcd --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=S;O=A @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/unix</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/unix</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/unix/spell">spell</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">102 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="steps">steps</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">215 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="words">words</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">399K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=S;O=D new file mode 100644 index 0000000..1683def --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/index.html?C=S;O=D @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lectures/unix</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lectures/unix</h1> + <table> + <tr><th valign="top"><img src="../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../Lectures">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="words">words</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">399K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="steps">steps</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">215 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lectures/unix/spell">spell</a> </td><td align="right">2003-02-14 11:00 </td><td align="right">102 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/steps b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/steps new file mode 100644 index 0000000..605c9e7 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/steps @@ -0,0 +1,7 @@ +tr -d '.,;:"\!\[]()' < summary > nopunct +tr ' ' ' ' < nopunct > notab +tr ' ' '\n' < notab > oneword +tr '[A-Z]' '[a-z]' < oneword > lowcase +sort < lowcase > sorted +uniq < sorted > nodup +join -v1 nodup words > errors diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/words b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/words new file mode 100644 index 0000000..9e3eefb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/unix/words @@ -0,0 +1,45402 @@ +Aarhus +Aaron +Ababa +aback +abaft +abandon +abandoned +abandoning +abandonment +abandons +abase +abased +abasement +abasements +abases +abash +abashed +abashes +abashing +abasing +abate +abated +abatement +abatements +abater +abates +abating +Abba +abbe +abbey +abbeys +abbot +abbots +Abbott +abbreviate +abbreviated +abbreviates +abbreviating +abbreviation +abbreviations +Abby +abdomen +abdomens +abdominal +abduct +abducted +abduction +abductions +abductor +abductors +abducts +Abe +abed +Abel +Abelian +Abelson +Aberdeen +Abernathy +aberrant +aberration +aberrations +abet +abets +abetted +abetter +abetting +abeyance +abhor +abhorred +abhorrent +abhorrer +abhorring +abhors +abide +abided +abides +abiding +Abidjan +Abigail +Abilene +abilities +ability +abject +abjection +abjections +abjectly +abjectness +abjure +abjured +abjures +abjuring +ablate +ablated +ablates +ablating +ablation +ablative +ablaze +able +abler +ablest +ably +Abner +abnormal +abnormalities +abnormality +abnormally +Abo +aboard +abode +abodes +abolish +abolished +abolisher +abolishers +abolishes +abolishing +abolishment +abolishments +abolition +abolitionist +abolitionists +abominable +abominate +aboriginal +aborigine +aborigines +abort +aborted +aborting +abortion +abortions +abortive +abortively +aborts +Abos +abound +abounded +abounding +abounds +about +above +aboveboard +aboveground +abovementioned +abrade +abraded +abrades +abrading +Abraham +Abram +Abrams +Abramson +abrasion +abrasions +abrasive +abreaction +abreactions +abreast +abridge +abridged +abridges +abridging +abridgment +abroad +abrogate +abrogated +abrogates +abrogating +abrupt +abruptly +abruptness +abscess +abscessed +abscesses +abscissa +abscissas +abscond +absconded +absconding +absconds +absence +absences +absent +absented +absentee +absenteeism +absentees +absentia +absenting +absently +absentminded +absents +absinthe +absolute +absolutely +absoluteness +absolutes +absolution +absolve +absolved +absolves +absolving +absorb +absorbed +absorbency +absorbent +absorber +absorbing +absorbs +absorption +absorptions +absorptive +abstain +abstained +abstainer +abstaining +abstains +abstention +abstentions +abstinence +abstract +abstracted +abstracting +abstraction +abstractionism +abstractionist +abstractions +abstractly +abstractness +abstractor +abstractors +abstracts +abstruse +abstruseness +absurd +absurdities +absurdity +absurdly +Abu +abundance +abundant +abundantly +abuse +abused +abuses +abusing +abusive +abut +abutment +abuts +abutted +abutter +abutters +abutting +abysmal +abysmally +abyss +abysses +Abyssinia +Abyssinian +Abyssinians +acacia +academia +academic +academically +academics +academies +academy +Acadia +Acapulco +accede +acceded +accedes +accelerate +accelerated +accelerates +accelerating +acceleration +accelerations +accelerator +accelerators +accelerometer +accelerometers +accent +accented +accenting +accents +accentual +accentuate +accentuated +accentuates +accentuating +accentuation +accept +acceptability +acceptable +acceptably +acceptance +acceptances +accepted +accepter +accepters +accepting +acceptor +acceptors +accepts +access +accessed +accesses +accessibility +accessible +accessibly +accessing +accession +accessions +accessories +accessors +accessory +accident +accidental +accidentally +accidently +accidents +acclaim +acclaimed +acclaiming +acclaims +acclamation +acclimate +acclimated +acclimates +acclimating +acclimatization +acclimatized +accolade +accolades +accommodate +accommodated +accommodates +accommodating +accommodation +accommodations +accompanied +accompanies +accompaniment +accompaniments +accompanist +accompanists +accompany +accompanying +accomplice +accomplices +accomplish +accomplished +accomplisher +accomplishers +accomplishes +accomplishing +accomplishment +accomplishments +accord +accordance +accorded +accorder +accorders +according +accordingly +accordion +accordions +accords +accost +accosted +accosting +accosts +account +accountability +accountable +accountably +accountancy +accountant +accountants +accounted +accounting +accounts +Accra +accredit +accreditation +accreditations +accredited +accretion +accretions +accrue +accrued +accrues +accruing +acculturate +acculturated +acculturates +acculturating +acculturation +accumulate +accumulated +accumulates +accumulating +accumulation +accumulations +accumulator +accumulators +accuracies +accuracy +accurate +accurately +accurateness +accursed +accusal +accusation +accusations +accusative +accuse +accused +accuser +accuses +accusing +accusingly +accustom +accustomed +accustoming +accustoms +ace +aces +acetate +acetone +acetylene +Achaean +Achaeans +ache +ached +aches +achievable +achieve +achieved +achievement +achievements +achiever +achievers +achieves +achieving +Achilles +aching +acid +acidic +acidities +acidity +acidly +acids +acidulous +Ackerman +Ackley +acknowledge +acknowledgeable +acknowledged +acknowledgement +acknowledgements +acknowledger +acknowledgers +acknowledges +acknowledging +acknowledgment +acknowledgments +acme +acne +acolyte +acolytes +acorn +acorns +acoustic +acoustical +acoustically +acoustician +acoustics +acquaint +acquaintance +acquaintances +acquainted +acquainting +acquaints +acquiesce +acquiesced +acquiescence +acquiescent +acquiesces +acquiescing +acquirable +acquire +acquired +acquires +acquiring +acquisition +acquisitions +acquisitive +acquisitiveness +acquit +acquits +acquittal +acquitted +acquitter +acquitting +acre +acreage +acres +acrid +acrimonious +acrimony +acrobat +acrobatic +acrobatics +acrobats +acronym +acronyms +acropolis +across +acrylic +act +Acta +Actaeon +acted +acting +actinium +actinometer +actinometers +action +actions +activate +activated +activates +activating +activation +activations +activator +activators +active +actively +activism +activist +activists +activities +activity +Acton +actor +actors +actress +actresses +Acts +actual +actualities +actuality +actualization +actually +actuals +actuarial +actuarially +actuate +actuated +actuates +actuating +actuator +actuators +acuity +acumen +acute +acutely +acuteness +acyclic +acyclically +ad +Ada +adage +adages +adagio +adagios +Adair +Adam +adamant +adamantly +Adams +Adamson +adapt +adaptability +adaptable +adaptation +adaptations +adapted +adapter +adapters +adapting +adaptive +adaptively +adaptor +adaptors +adapts +add +added +addend +addenda +addendum +adder +adders +addict +addicted +addicting +addiction +addictions +addicts +adding +Addis +Addison +addition +additional +additionally +additions +additive +additives +additivity +address +addressability +addressable +addressed +addressee +addressees +addresser +addressers +addresses +addressing +Addressograph +adds +adduce +adduced +adduces +adducible +adducing +adduct +adducted +adducting +adduction +adductor +adducts +Adelaide +Adele +Adelia +Aden +adept +adequacies +adequacy +adequate +adequately +adhere +adhered +adherence +adherent +adherents +adherer +adherers +adheres +adhering +adhesion +adhesions +adhesive +adhesives +adiabatic +adiabatically +adieu +Adirondack +Adirondacks +adjacency +adjacent +adjective +adjectives +adjoin +adjoined +adjoining +adjoins +adjourn +adjourned +adjourning +adjournment +adjourns +adjudge +adjudged +adjudges +adjudging +adjudicate +adjudicated +adjudicates +adjudicating +adjudication +adjudications +adjunct +adjuncts +adjure +adjured +adjures +adjuring +adjust +adjustable +adjustably +adjusted +adjuster +adjusters +adjusting +adjustment +adjustments +adjustor +adjustors +adjusts +adjutant +adjutants +Adkins +Adler +Adlerian +administer +administered +administering +administerings +administers +administrable +administrate +administration +administrations +administrative +administratively +administrator +administrators +admirable +admirably +admiral +admirals +admiralty +admiration +admirations +admire +admired +admirer +admirers +admires +admiring +admiringly +admissibility +admissible +admission +admissions +admit +admits +admittance +admitted +admittedly +admitter +admitters +admitting +admix +admixed +admixes +admixture +admonish +admonished +admonishes +admonishing +admonishment +admonishments +admonition +admonitions +ado +adobe +adolescence +adolescent +adolescents +Adolph +Adolphus +Adonis +adopt +adopted +adopter +adopters +adopting +adoption +adoptions +adoptive +adopts +adorable +adoration +adore +adored +adores +adorn +adorned +adornment +adornments +adorns +adrenal +adrenaline +Adrian +Adriatic +Adrienne +adrift +adroit +adroitness +ads +adsorb +adsorbed +adsorbing +adsorbs +adsorption +adulate +adulating +adulation +adult +adulterate +adulterated +adulterates +adulterating +adulterer +adulterers +adulterous +adulterously +adultery +adulthood +adults +adumbrate +adumbrated +adumbrates +adumbrating +adumbration +advance +advanced +advancement +advancements +advances +advancing +advantage +advantaged +advantageous +advantageously +advantages +advent +adventist +adventists +adventitious +adventure +adventured +adventurer +adventurers +adventures +adventuring +adventurous +adverb +adverbial +adverbs +adversaries +adversary +adverse +adversely +adversities +adversity +advert +advertise +advertised +advertisement +advertisements +advertiser +advertisers +advertises +advertising +advice +advisability +advisable +advisably +advise +advised +advisedly +advisee +advisees +advisement +advisements +adviser +advisers +advises +advising +advisor +advisors +advisory +advocacy +advocate +advocated +advocates +advocating +Aegean +aegis +Aeneas +Aeneid +Aeolus +aerate +aerated +aerates +aerating +aeration +aerator +aerators +aerial +aerials +aeroacoustic +Aerobacter +aerobic +aerobics +aerodynamic +aerodynamics +aeronautic +aeronautical +aeronautics +aerosol +aerosolize +aerosols +aerospace +Aeschylus +Aesop +aesthetic +aesthetically +aesthetics +afar +affable +affair +affairs +affect +affectation +affectations +affected +affecting +affectingly +affection +affectionate +affectionately +affections +affective +affects +afferent +affianced +affidavit +affidavits +affiliate +affiliated +affiliates +affiliating +affiliation +affiliations +affinities +affinity +affirm +affirmation +affirmations +affirmative +affirmatively +affirmed +affirming +affirms +affix +affixed +affixes +affixing +afflict +afflicted +afflicting +affliction +afflictions +afflictive +afflicts +affluence +affluent +afford +affordable +afforded +affording +affords +affricate +affricates +affright +affront +affronted +affronting +affronts +Afghan +Afghanistan +Afghans +aficionado +afield +afire +aflame +afloat +afoot +afore +aforementioned +aforesaid +aforethought +afoul +afraid +afresh +Africa +African +Africanization +Africanizations +Africanize +Africanized +Africanizes +Africanizing +Africans +Afrikaans +Afrikaner +Afrikaners +aft +after +aftereffect +afterglow +afterimage +afterlife +aftermath +aftermost +afternoon +afternoons +aftershock +aftershocks +afterthought +afterthoughts +afterward +afterwards +again +against +Agamemnon +agape +agar +agate +agates +Agatha +age +aged +Agee +ageless +agencies +agency +agenda +agendas +agent +agents +ager +agers +ages +Aggie +Aggies +agglomerate +agglomerated +agglomerates +agglomeration +agglutinate +agglutinated +agglutinates +agglutinating +agglutination +agglutinin +agglutinins +aggrandize +aggravate +aggravated +aggravates +aggravation +aggregate +aggregated +aggregately +aggregates +aggregating +aggregation +aggregations +aggression +aggressions +aggressive +aggressively +aggressiveness +aggressor +aggressors +aggrieve +aggrieved +aggrieves +aggrieving +aghast +agile +agilely +agility +aging +agitate +agitated +agitates +agitating +agitation +agitations +agitator +agitators +agleam +aglow +Agnes +Agnew +agnostic +agnostics +ago +agog +agonies +agonize +agonized +agonizes +agonizing +agonizingly +agony +agrarian +agree +agreeable +agreeably +agreed +agreeing +agreement +agreements +agreer +agreers +agrees +Agricola +agricultural +agriculturally +agriculture +ague +Agway +ah +ahead +Ahmadabad +Ahmedabad +aid +Aida +aide +aided +Aides +aiding +aids +Aiken +ail +Aileen +aileron +ailerons +ailing +ailment +ailments +aim +aimed +aimer +aimers +aiming +aimless +aimlessly +aims +Ainu +Ainus +air +airbag +airbags +airborne +Airbus +aircraft +airdrop +airdrops +aired +Airedale +airer +airers +Aires +airfare +airfield +airfields +airflow +airfoil +airfoils +airframe +airframes +airily +airing +airings +airless +airlift +airlifts +airline +airliner +airlines +airlock +airlocks +airmail +airmails +airman +airmen +airplane +airplanes +airport +airports +airs +airship +airships +airspace +airspeed +airstrip +airstrips +airtight +airway +airways +airy +aisle +Aitken +ajar +Ajax +Akers +akimbo +akin +Akron +Al +Alabama +Alabamans +Alabamian +alabaster +alacrity +Aladdin +Alameda +Alamo +Alamos +Alan +Alar +alarm +alarmed +alarming +alarmingly +alarmist +alarms +alas +Alaska +Alaskan +Alastair +alba +albacore +Albania +Albanian +Albanians +Albany +albatross +albeit +Alberich +Albert +Alberta +Alberto +Albrecht +Albright +album +albumin +albums +Albuquerque +Alcestis +alchemy +Alcibiades +Alcmena +Alcoa +alcohol +alcoholic +alcoholics +alcoholism +alcohols +Alcott +alcove +alcoves +Aldebaran +Alden +alder +alderman +aldermen +Aldrich +ale +Alec +Aleck +alee +alert +alerted +alertedly +alerter +alerters +alerting +alertly +alertness +alerts +Aleut +Aleutian +Alex +Alexander +Alexandra +Alexandre +Alexandria +Alexandrine +Alexei +Alexis +Alfa +alfalfa +Alfonso +Alfred +Alfredo +alfresco +alga +algae +algaecide +algebra +algebraic +algebraically +algebras +Algenib +Alger +Algeria +Algerian +Algiers +alginate +ALGOL +Algol +Algonquian +Algonquin +algorithm +algorithmic +algorithmically +algorithms +Alhambra +Ali +alias +aliased +aliases +aliasing +alibi +alibis +Alice +Alicia +alien +alienate +alienated +alienates +alienating +alienation +aliens +alight +align +aligned +aligning +alignment +alignments +aligns +alike +aliment +aliments +alimony +Alison +Alistair +alive +alkali +alkaline +alkalis +alkaloid +alkaloids +alkyl +all +Allah +Allan +allay +allayed +allaying +allays +allegation +allegations +allege +alleged +allegedly +alleges +Alleghenies +Allegheny +allegiance +allegiances +alleging +allegoric +allegorical +allegorically +allegories +allegory +Allegra +allegretto +allegrettos +allele +alleles +allemande +Allen +Allendale +Allentown +allergic +allergies +allergy +alleviate +alleviated +alleviates +alleviating +alleviation +alley +alleys +alleyway +alleyways +alliance +alliances +allied +allies +alligator +alligators +Allis +Allison +alliteration +alliterations +alliterative +allocatable +allocate +allocated +allocates +allocating +allocation +allocations +allocator +allocators +allophone +allophones +allophonic +allot +allotment +allotments +allots +allotted +allotter +allotting +allow +allowable +allowably +allowance +allowances +allowed +allowing +allows +alloy +alloys +Allstate +allude +alluded +alludes +alluding +allure +allurement +alluring +allusion +allusions +allusive +allusiveness +ally +allying +Allyn +alma +Almaden +almanac +almanacs +almighty +almond +almonds +almoner +almost +alms +almsman +alnico +aloe +aloes +aloft +aloha +alone +aloneness +along +alongside +aloof +aloofness +aloud +Alpert +alpha +alphabet +alphabetic +alphabetical +alphabetically +alphabetics +alphabetize +alphabetized +alphabetizes +alphabetizing +alphabets +alphanumeric +Alpheratz +Alphonse +alpine +Alps +already +Alsatian +Alsatians +also +Alsop +Altair +altar +altars +alter +alterable +alteration +alterations +altercation +altercations +altered +alterer +alterers +altering +alternate +alternated +alternately +alternates +alternating +alternation +alternations +alternative +alternatively +alternatives +alternator +alternators +alters +Althaea +although +altitude +altitudes +altogether +Alton +Altos +altruism +altruist +altruistic +altruistically +alum +aluminum +alumna +alumnae +alumni +alumnus +alundum +Alva +Alvarez +alveolar +alveoli +alveolus +Alvin +always +Alyssa +am +Amadeus +amain +amalgam +amalgamate +amalgamated +amalgamates +amalgamating +amalgamation +amalgams +Amanda +amanuensis +amaretto +Amarillo +amass +amassed +amasses +amassing +amateur +amateurish +amateurishness +amateurism +amateurs +amatory +amaze +amazed +amazedly +amazement +amazer +amazers +amazes +amazing +amazingly +Amazon +Amazons +ambassador +ambassadors +amber +ambiance +ambidextrous +ambidextrously +ambient +ambiguities +ambiguity +ambiguous +ambiguously +ambition +ambitions +ambitious +ambitiously +ambivalence +ambivalent +ambivalently +amble +ambled +ambler +ambles +ambling +ambrosial +ambulance +ambulances +ambulatory +ambuscade +ambush +ambushed +ambushes +Amdahl +Amelia +ameliorate +ameliorated +ameliorating +amelioration +amen +amenable +amend +amended +amending +amendment +amendments +amends +amenities +amenity +amenorrhea +Amerada +America +American +Americana +Americanism +Americanization +Americanizations +Americanize +Americanizer +Americanizers +Americanizes +Americans +Americas +americium +Ames +Amharic +Amherst +amiable +amicable +amicably +amid +amide +amidst +Amiga +amigo +amino +amiss +amity +Amman +Ammerman +ammo +ammonia +ammoniac +ammonium +ammunition +amnesty +Amoco +amoeba +amoebae +amoebas +amok +among +amongst +Amontillado +amoral +amorality +amorist +amorous +amorphous +amorphously +amortize +amortized +amortizes +amortizing +Amos +amount +amounted +amounter +amounters +amounting +amounts +amour +amperage +ampere +amperes +ampersand +ampersands +Ampex +amphetamine +amphetamines +amphibian +amphibians +amphibious +amphibiously +amphibology +amphitheater +amphitheaters +ample +amplification +amplified +amplifier +amplifiers +amplifies +amplify +amplifying +amplitude +amplitudes +amply +ampoule +ampoules +amputate +amputated +amputates +amputating +Amsterdam +Amtrak +amulet +amulets +amuse +amused +amusedly +amusement +amusements +amuser +amusers +amuses +amusing +amusingly +Amy +amyl +an +Anabaptist +Anabaptists +Anabel +anachronism +anachronisms +anachronistically +anaconda +anacondas +Anacreon +anaerobic +anagram +anagrams +Anaheim +anal +Analects +analog +analogical +analogies +analogous +analogously +analogue +analogues +analogy +analyses +analysis +analyst +analysts +analytic +analytical +analytically +analyticities +analyticity +analyzable +analyze +analyzed +analyzer +analyzers +analyzes +analyzing +anaphora +anaphoric +anaphorically +anaplasmosis +anarchic +anarchical +anarchism +anarchist +anarchists +anarchy +Anastasia +anastomoses +anastomosis +anastomotic +anathema +Anatole +Anatolia +Anatolian +anatomic +anatomical +anatomically +anatomy +ancestor +ancestors +ancestral +ancestry +anchor +anchorage +anchorages +anchored +anchoring +anchorite +anchoritism +anchors +anchovies +anchovy +ancient +anciently +ancients +ancillary +and +Andalusia +Andalusian +Andalusians +Andean +anders +Andersen +Anderson +Andes +anding +Andorra +Andover +Andre +Andrea +Andrei +Andrew +Andrews +Andromache +Andromeda +Andy +anecdotal +anecdote +anecdotes +anechoic +anemia +anemic +anemometer +anemometers +anemometry +anemone +anesthesia +anesthetic +anesthetically +anesthetics +anesthetize +anesthetized +anesthetizes +anesthetizing +anew +angel +Angela +Angeleno +Angelenos +Angeles +angelic +Angelica +Angelina +Angeline +Angelo +angels +anger +angered +angering +angers +Angie +angiography +angle +angled +angler +anglers +Angles +Anglia +Anglican +Anglicanism +Anglicanize +Anglicanizes +Anglicans +angling +Anglo +Anglophilia +Anglophobia +Angola +Angora +angrier +angriest +angrily +angry +angst +angstrom +anguish +anguished +angular +angularly +Angus +Anheuser +anhydrous +anhydrously +aniline +animal +animals +animate +animated +animatedly +animately +animateness +animates +animating +animation +animations +animator +animators +animism +animized +animosity +anion +anionic +anions +anise +aniseikonic +anisotropic +anisotropy +Anita +Ankara +ankle +ankles +Ann +Anna +annal +Annalist +Annalistic +annals +Annapolis +Anne +Annette +annex +annexation +annexed +annexes +annexing +Annie +annihilate +annihilated +annihilates +annihilating +annihilation +anniversaries +anniversary +annotate +annotated +annotates +annotating +annotation +annotations +announce +announced +announcement +announcements +announcer +announcers +announces +announcing +annoy +annoyance +annoyances +annoyed +annoyer +annoyers +annoying +annoyingly +annoys +annual +annually +annuals +annuity +annul +annular +annuli +annulled +annulling +annulment +annulments +annuls +annulus +annum +annunciate +annunciated +annunciates +annunciating +annunciator +annunciators +anode +anodes +anodize +anodized +anodizes +anoint +anointed +anointing +anoints +anomalies +anomalous +anomalously +anomaly +anomic +anomie +anon +anonymity +anonymous +anonymously +anorexia +another +Anselm +Anselmo +ANSI +answer +answerable +answered +answerer +answerers +answering +answers +ant +Antaeus +antagonism +antagonisms +antagonist +antagonistic +antagonistically +antagonists +antagonize +antagonized +antagonizes +antagonizing +antarctic +Antarctica +Antares +ante +anteater +anteaters +antecedent +antecedents +antedate +antelope +antelopes +antenna +antennae +antennas +anterior +anthem +anthems +anther +anthologies +anthology +Anthony +anthracite +anthropological +anthropologically +anthropologist +anthropologists +anthropology +anthropomorphic +anthropomorphically +anti +antibacterial +antibiotic +antibiotics +antibodies +antibody +antic +anticipate +anticipated +anticipates +anticipating +anticipation +anticipations +anticipatory +anticoagulation +anticompetitive +antics +antidisestablishmentarianism +antidote +antidotes +Antietam +antiformant +antifundamentalist +antigen +antigens +Antigone +antihistorical +Antilles +antimicrobial +antimony +antinomian +antinomy +Antioch +antipathy +antiphonal +antipode +antipodes +antiquarian +antiquarians +antiquate +antiquated +antique +antiques +antiquities +antiquity +antiredeposition +antiresonance +antiresonator +antisemitic +antisemitism +antiseptic +antisera +antiserum +antislavery +antisocial +antisubmarine +antisymmetric +antisymmetry +antithesis +antithetical +antithyroid +antitoxin +antitoxins +antitrust +antler +antlered +Antoine +Antoinette +Anton +Antonio +Antonovics +Antony +ants +Antwerp +anus +anvil +anvils +anxieties +anxiety +anxious +anxiously +any +anybody +anyhow +anymore +anyone +anyplace +anything +anytime +anyway +anywhere +aorta +apace +Apaches +Apalachicola +apart +apartment +apartments +apathetic +apathy +ape +aped +aperiodic +aperiodicity +aperture +apes +Apetalous +apex +aphasia +aphasic +aphelion +aphid +aphids +aphonic +aphorism +aphorisms +Aphrodite +apiaries +apiary +apical +apiece +aping +apish +aplenty +aplomb +apocalypse +apocalyptic +Apocrypha +apocryphal +apogee +apogees +Apollinaire +Apollo +Apollonian +apologetic +apologetically +apologia +apologies +apologist +apologists +apologize +apologized +apologizes +apologizing +apology +apostate +apostle +apostles +apostolic +apostrophe +apostrophes +apothecary +apothegm +apotheoses +apotheosis +Appalachia +Appalachian +Appalachians +appall +appalled +appalling +appallingly +Appaloosas +appanage +apparatus +apparel +appareled +apparent +apparently +apparition +apparitions +appeal +appealed +appealer +appealers +appealing +appealingly +appeals +appear +appearance +appearances +appeared +appearer +appearers +appearing +appears +appease +appeased +appeasement +appeases +appeasing +appellant +appellants +appellate +appellation +append +appendage +appendages +appended +appender +appenders +appendices +appendicitis +appending +appendix +appendixes +appends +appertain +appertains +appetite +appetites +appetizer +appetizing +Appia +Appian +applaud +applauded +applauding +applauds +applause +apple +Appleby +applejack +apples +Appleton +appliance +appliances +applicability +applicable +applicant +applicants +application +applications +applicative +applicatively +applicator +applicators +applied +applier +appliers +applies +applique +apply +applying +appoint +appointed +appointee +appointees +appointer +appointers +appointing +appointive +appointment +appointments +appoints +Appomattox +apportion +apportioned +apportioning +apportionment +apportionments +apportions +apposite +appraisal +appraisals +appraise +appraised +appraiser +appraisers +appraises +appraising +appraisingly +appreciable +appreciably +appreciate +appreciated +appreciates +appreciating +appreciation +appreciations +appreciative +appreciatively +apprehend +apprehended +apprehensible +apprehension +apprehensions +apprehensive +apprehensively +apprehensiveness +apprentice +apprenticed +apprentices +apprenticeship +apprise +apprised +apprises +apprising +approach +approachability +approachable +approached +approacher +approachers +approaches +approaching +approbate +approbation +appropriate +appropriated +appropriately +appropriateness +appropriates +appropriating +appropriation +appropriations +appropriator +appropriators +approval +approvals +approve +approved +approver +approvers +approves +approving +approvingly +approximate +approximated +approximately +approximates +approximating +approximation +approximations +appurtenance +appurtenances +apricot +apricots +April +Aprils +apron +aprons +apropos +apse +apsis +apt +aptitude +aptitudes +aptly +aptness +aqua +aquaria +aquarium +Aquarius +aquatic +aqueduct +aqueducts +aqueous +aquifer +aquifers +Aquila +Aquinas +Arab +arabesque +Arabia +Arabian +Arabianize +Arabianizes +Arabians +Arabic +Arabicize +Arabicizes +arable +Arabs +Araby +Arachne +arachnid +arachnids +Aramco +Arapaho +arbiter +arbiters +arbitrarily +arbitrariness +arbitrary +arbitrate +arbitrated +arbitrates +arbitrating +arbitration +arbitrator +arbitrators +arbor +arboreal +arbors +arc +arcade +arcaded +arcades +Arcadia +Arcadian +arcane +arced +arch +archaic +archaically +archaicness +archaism +archaize +archangel +archangels +archbishop +archdiocese +archdioceses +arched +archenemy +archeological +archeologist +archeology +Archer +archers +archery +arches +archetype +archfool +Archibald +Archie +Archimedes +arching +archipelago +archipelagoes +architect +architectonic +architects +architectural +architecturally +architecture +architectures +archival +archive +archived +archiver +archivers +archives +archiving +archivist +archly +arcing +arclike +ARCO +arcs +arcsine +arctangent +arctic +Arcturus +Arden +ardent +ardently +ardor +arduous +arduously +arduousness +are +area +areas +arena +arenas +Arequipa +Ares +Argentina +Argentinian +Argive +Argo +argon +Argonaut +argonauts +Argonne +Argos +argot +arguable +arguably +argue +argued +arguer +arguers +argues +arguing +argument +argumentation +argumentative +arguments +Argus +Ariadne +Arianism +Arianist +Arianists +arid +aridity +Aries +aright +arise +arisen +ariser +arises +arising +arisings +aristocracy +aristocrat +aristocratic +aristocratically +aristocrats +Aristotelian +Aristotle +arithmetic +arithmetical +arithmetically +arithmetics +arithmetize +arithmetized +arithmetizes +Arizona +ark +Arkansan +Arkansas +Arlen +Arlene +Arlington +arm +Armada +armadillo +armadillos +Armageddon +Armagnac +armament +armaments +Armata +armchair +armchairs +Armco +armed +Armenia +Armenian +armer +armers +armful +armhole +armies +arming +armistice +armload +Armonk +armor +armored +armorer +armory +Armour +armpit +armpits +arms +Armstrong +army +Arnold +aroma +aromas +aromatic +arose +around +arousal +arouse +aroused +arouses +arousing +ARPA +ARPANET +Arpanet +arpeggio +arpeggios +arrack +Arragon +arraign +arraigned +arraigning +arraignment +arraignments +arraigns +arrange +arranged +arrangement +arrangements +arranger +arrangers +arranges +arranging +arrant +array +arrayed +arrays +arrears +arrest +arrested +arrester +arresters +arresting +arrestingly +arrestor +arrestors +arrests +Arrhenius +arrival +arrivals +arrive +arrived +arrives +arriving +arrogance +arrogant +arrogantly +arrogate +arrogated +arrogates +arrogating +arrogation +arrow +arrowed +arrowhead +arrowheads +arrows +arroyo +arroyos +arsenal +arsenals +arsenic +arsine +arson +art +Artemia +Artemis +arterial +arteries +arteriolar +arteriole +arterioles +arteriosclerosis +artery +artful +artfully +artfulness +arthritis +arthropod +arthropods +Arthur +artichoke +artichokes +article +articles +articulate +articulated +articulately +articulateness +articulates +articulating +articulation +articulations +articulator +articulators +articulatory +Artie +artifact +artifacts +artifice +artificer +artifices +artificial +artificialities +artificiality +artificially +artificialness +artillerist +artillery +artisan +artisans +artist +artistic +artistically +artistry +artists +artless +arts +Arturo +artwork +Aruba +Aryan +Aryans +as +asbestos +ascend +ascendancy +ascendant +ascended +ascendency +ascendent +ascender +ascenders +ascending +ascends +ascension +ascensions +ascent +ascertain +ascertainable +ascertained +ascertaining +ascertains +ascetic +asceticism +ascetics +ASCII +ascot +ascribable +ascribe +ascribed +ascribes +ascribing +ascription +aseptic +ash +ashamed +ashamedly +ashen +Asher +ashes +Asheville +Ashland +Ashley +ashman +Ashmolean +ashore +ashtray +ashtrays +Asia +Asian +Asians +Asiatic +Asiaticization +Asiaticizations +Asiaticize +Asiaticizes +Asiatics +aside +Asilomar +asinine +ask +askance +asked +asker +askers +askew +asking +asks +asleep +asocial +asp +asparagus +aspect +aspects +aspen +aspersion +aspersions +asphalt +asphyxia +aspic +aspirant +aspirants +aspirate +aspirated +aspirates +aspirating +aspiration +aspirations +aspirator +aspirators +aspire +aspired +aspires +aspirin +aspiring +aspirins +ass +assail +assailant +assailants +assailed +assailing +assails +Assam +assassin +assassinate +assassinated +assassinates +assassinating +assassination +assassinations +assassins +assault +assaulted +assaulting +assaults +assay +assayed +assaying +assemblage +assemblages +assemble +assembled +assembler +assemblers +assembles +assemblies +assembling +assembly +assent +assented +assenter +assenting +assents +assert +asserted +asserter +asserters +asserting +assertion +assertions +assertive +assertively +assertiveness +asserts +asses +assess +assessed +assesses +assessing +assessment +assessments +assessor +assessors +asset +assets +assiduity +assiduous +assiduously +assign +assignable +assigned +assignee +assignees +assigner +assigners +assigning +assignment +assignments +assigns +assimilate +assimilated +assimilates +assimilating +assimilation +assimilations +assist +assistance +assistances +assistant +assistants +assistantship +assistantships +assisted +assisting +assists +associate +associated +associates +associating +association +associational +associations +associative +associatively +associativity +associator +associators +assonance +assonant +assort +assorted +assortment +assortments +assorts +assuage +assuaged +assuages +assume +assumed +assumes +assuming +assumption +assumptions +assurance +assurances +assure +assured +assuredly +assurer +assurers +assures +assuring +assuringly +Assyria +Assyrian +Assyrianize +Assyrianizes +Assyriology +Astaire +Astaires +Astarte +astatine +aster +asterisk +asterisks +asteroid +asteroidal +asteroids +asters +asthma +Aston +astonish +astonished +astonishes +astonishing +astonishingly +astonishment +Astor +Astoria +astound +astounded +astounding +astounds +astral +astray +astride +astringency +astringent +astrology +astronaut +astronautics +astronauts +astronomer +astronomers +astronomical +astronomically +astronomy +astrophysical +astrophysics +astute +astutely +astuteness +Asuncion +asunder +asylum +asymmetric +asymmetrically +asymmetry +asymptomatically +asymptote +asymptotes +asymptotic +asymptotically +asynchronism +asynchronous +asynchronously +asynchrony +at +Atalanta +Atari +atavistic +Atchison +ate +atemporal +Athabascan +atheism +atheist +atheistic +atheists +Athena +Athenian +Athenians +Athens +atherosclerosis +athlete +athletes +athletic +athleticism +athletics +Atkins +Atkinson +Atlanta +Atlantic +Atlantica +Atlantis +atlas +atmosphere +atmospheres +atmospheric +atoll +atolls +atom +atomic +atomically +atomics +atomization +atomize +atomized +atomizes +atomizing +atoms +atonal +atonally +atone +atoned +atonement +atones +atop +Atreus +atrocious +atrociously +atrocities +atrocity +atrophic +atrophied +atrophies +atrophy +atrophying +Atropos +attach +attache +attached +attacher +attachers +attaches +attaching +attachment +attachments +attack +attackable +attacked +attacker +attackers +attacking +attacks +attain +attainable +attainably +attained +attainer +attainers +attaining +attainment +attainments +attains +attempt +attempted +attempter +attempters +attempting +attempts +attend +attendance +attendances +attendant +attendants +attended +attendee +attendees +attender +attenders +attending +attends +attention +attentional +attentionality +attentions +attentive +attentively +attentiveness +attenuate +attenuated +attenuates +attenuating +attenuation +attenuator +attenuators +attest +attested +attesting +attests +attic +Attica +attics +attire +attired +attires +attiring +attitude +attitudes +attitudinal +Attlee +attorney +attorneys +attract +attracted +attracting +attraction +attractions +attractive +attractively +attractiveness +attractor +attractors +attracts +attributable +attribute +attributed +attributes +attributing +attribution +attributions +attributive +attributively +attrition +attune +attuned +attunes +attuning +Atwater +Atwood +atypical +atypically +Auberge +Aubrey +auburn +Auckland +auction +auctioneer +auctioneers +audacious +audaciously +audaciousness +audacity +audible +audibly +audience +audiences +audio +audiogram +audiograms +audiological +audiologist +audiologists +audiology +audiometer +audiometers +audiometric +audiometry +audit +audited +auditing +audition +auditioned +auditioning +auditions +auditor +auditorium +auditors +auditory +audits +Audrey +Audubon +Auerbach +Augean +auger +augers +aught +augment +augmentation +augmented +augmenting +augments +augur +augurs +august +Augusta +Augustan +Augustine +augustly +augustness +Augustus +aunt +aunts +aura +aural +aurally +auras +Aurelius +aureole +aureomycin +Auriga +aurora +Auschwitz +auscultate +auscultated +auscultates +auscultating +auscultation +auscultations +auspice +auspices +auspicious +auspiciously +austere +austerely +austerity +Austin +Australia +Australian +Australianize +Australianizes +Australis +Austria +Austrian +Austrianize +Austrianizes +authentic +authentically +authenticate +authenticated +authenticates +authenticating +authentication +authentications +authenticator +authenticators +authenticity +author +authored +authoring +authoritarian +authoritarianism +authoritative +authoritatively +authorities +authority +authorization +authorizations +authorize +authorized +authorizer +authorizers +authorizes +authorizing +authors +authorship +autism +autistic +auto +autobiographic +autobiographical +autobiographies +autobiography +autocollimator +autocorrelate +autocorrelation +autocracies +autocracy +autocrat +autocratic +autocratically +autocrats +autodecrement +autodecremented +autodecrements +autodialer +autofluorescence +autograph +autographed +autographing +autographs +autoincrement +autoincremented +autoincrements +autoindex +autoindexing +automata +automate +automated +automates +automatic +automatically +automating +automation +automaton +automobile +automobiles +automotive +autonavigator +autonavigators +autonomic +autonomous +autonomously +autonomy +autopilot +autopilots +autopsied +autopsies +autopsy +autoregressive +autos +autosuggestibility +autotransformer +autumn +autumnal +autumns +auxiliaries +auxiliary +avail +availabilities +availability +available +availably +availed +availer +availers +availing +avails +avalanche +avalanched +avalanches +avalanching +avant +avarice +avaricious +avariciously +avenge +avenged +avenger +avenges +avenging +Aventine +Aventino +avenue +avenues +aver +average +averaged +averages +averaging +Avernus +averred +averrer +averring +avers +averse +aversion +aversions +avert +averted +averting +averts +Avery +Avesta +avian +aviaries +aviary +aviation +aviator +aviators +avid +avidity +avidly +Avignon +avionic +avionics +Avis +Aviv +avocado +avocados +avocation +avocations +Avogadro +avoid +avoidable +avoidably +avoidance +avoided +avoider +avoiders +avoiding +avoids +Avon +avouch +avow +avowal +avowed +avows +await +awaited +awaiting +awaits +awake +awaken +awakened +awakening +awakens +awakes +awaking +award +awarded +awarder +awarders +awarding +awards +aware +awareness +awash +away +awe +awed +awesome +awful +awfully +awfulness +awhile +awkward +awkwardly +awkwardness +awl +awls +awning +awnings +awoke +awry +ax +axed +Axel +axer +axers +axes +axial +axially +axing +axiological +axiom +axiomatic +axiomatically +axiomatization +axiomatizations +axiomatize +axiomatized +axiomatizes +axiomatizing +axioms +axis +axle +axles +axolotl +axolotls +axon +axons +aye +Ayers +ayes +Aylesbury +azalea +azaleas +Azerbaijan +azimuth +azimuths +Azores +Aztec +Aztecan +azure +Babbage +babble +babbled +babbles +babbling +Babcock +babe +Babel +Babelize +Babelizes +babes +babied +babies +Babka +baboon +baboons +Babul +baby +babyhood +babying +babyish +Babylon +Babylonian +Babylonians +Babylonize +Babylonizes +babysit +babysitting +baccalaureate +Bacchus +Bach +bachelor +bachelors +bacilli +bacillus +back +backache +backaches +backarrow +backbend +backbends +backboard +backbone +backbones +backdrop +backdrops +backed +backer +backers +backfill +backfiring +background +backgrounds +backhand +backing +backlash +backlog +backlogged +backlogs +backorder +backpack +backpacks +backplane +backplanes +backplate +backs +backscatter +backscattered +backscattering +backscatters +backside +backslash +backslashes +backspace +backspaced +backspaces +backspacing +backstage +backstairs +backstitch +backstitched +backstitches +backstitching +backstop +backtrack +backtracked +backtracker +backtrackers +backtracking +backtracks +backup +backups +Backus +backward +backwardness +backwards +backwater +backwaters +backwoods +backyard +backyards +bacon +bacteria +bacterial +bacterium +bad +bade +Baden +badge +badger +badgered +badgering +badgers +badges +badlands +badly +badminton +badness +Baffin +baffle +baffled +baffler +bafflers +baffling +bag +bagatelle +bagatelles +bagel +bagels +baggage +bagged +bagger +baggers +bagging +baggy +Baghdad +Bagley +bagpipe +bagpipes +Bagrodia +Bagrodias +bags +bah +Bahama +Bahamas +Bahrein +bail +Bailey +Baileys +bailiff +bailiffs +bailing +Baird +Bairdi +Bairn +bait +baited +baiter +baiting +baits +Baja +bake +baked +Bakelite +baker +bakeries +bakers +Bakersfield +bakery +bakes +Bakhtiari +baking +baklava +Baku +balalaika +balalaikas +balance +balanced +balancer +balancers +balances +balancing +Balboa +balconies +balcony +bald +balding +baldly +baldness +Baldwin +bale +baleful +baler +bales +Balfour +Bali +Balinese +balk +Balkan +Balkanization +Balkanizations +Balkanize +balkanized +Balkanizes +balkanizing +Balkans +balked +balkiness +balking +balks +balky +ball +ballad +ballads +Ballard +Ballards +ballast +ballasts +balled +baller +ballerina +ballerinas +ballers +ballet +ballets +ballgown +balling +ballistic +ballistics +balloon +ballooned +ballooner +ballooners +ballooning +balloons +ballot +ballots +ballpark +ballparks +ballplayer +ballplayers +ballroom +ballrooms +balls +ballyhoo +balm +balms +balmy +balsa +balsam +Baltic +Baltimore +Baltimorean +balustrade +balustrades +Balzac +Bamako +Bamberger +Bambi +bamboo +ban +Banach +banal +banally +banana +bananas +Banbury +Bancroft +band +bandage +bandaged +bandages +bandaging +banded +bandied +bandies +banding +bandit +bandits +bandpass +bands +bandstand +bandstands +bandwagon +bandwagons +bandwidth +bandwidths +bandy +bandying +bane +baneful +bang +banged +banging +Bangladesh +bangle +bangles +Bangor +bangs +Bangui +banish +banished +banishes +banishing +banishment +banister +banisters +banjo +banjos +bank +banked +banker +bankers +banking +bankrupt +bankruptcies +bankruptcy +bankrupted +bankrupting +bankrupts +Banks +banned +banner +banners +banning +banquet +banqueting +banquetings +banquets +bans +banshee +banshees +bantam +banter +bantered +bantering +banters +Bantu +Bantus +baptism +baptismal +baptisms +Baptist +Baptiste +baptistery +baptistries +baptistry +Baptists +baptize +baptized +baptizes +baptizing +bar +barb +Barbados +Barbara +barbarian +barbarians +barbaric +barbarism +barbarities +barbarity +barbarous +barbarously +barbecue +barbecued +barbecues +barbed +barbell +barbells +barber +barbital +barbiturate +barbiturates +Barbour +barbs +Barcelona +Barclay +bard +bards +bare +bared +barefaced +barefoot +barefooted +barely +bareness +barer +bares +barest +barflies +barfly +bargain +bargained +bargaining +bargains +barge +barges +barging +Barhop +baring +baritone +baritones +barium +bark +barked +barker +barkers +barking +barks +barley +Barlow +barn +Barnabas +Barnard +Barnes +Barnet +Barnett +Barney +Barnhard +barns +barnstorm +barnstormed +barnstorming +barnstorms +Barnum +barnyard +barnyards +barometer +barometers +barometric +baron +baroness +baronial +baronies +barons +barony +baroque +baroqueness +Barr +barrack +barracks +barrage +barrages +barred +barrel +barrelled +barrelling +barrels +barren +barrenness +Barrett +barricade +barricades +barrier +barriers +barring +barringer +Barrington +Barron +barrow +Barry +Barrymore +Barrymores +bars +Barstow +Bart +bartender +bartenders +barter +bartered +bartering +barters +Barth +Bartholomew +Bartlett +Bartok +Barton +basal +basalt +Bascom +base +baseball +baseballs +baseband +baseboard +baseboards +based +Basel +baseless +baseline +baselines +basely +baseman +basement +basements +baseness +baser +bases +bash +bashed +bashes +bashful +bashfulness +bashing +BASIC +Basic +basic +basically +basics +Basie +basil +basin +basing +basins +basis +bask +basked +basket +basketball +basketballs +baskets +basking +Basque +bass +basses +basset +Bassett +bassinet +bassinets +bastard +bastards +baste +basted +bastes +basting +bastion +bastions +bat +Batavia +batch +batched +Batchelder +batches +Bateman +Bates +bath +bathe +bathed +bather +bathers +bathes +bathing +bathos +bathrobe +bathrobes +bathroom +bathrooms +baths +bathtub +bathtubs +Bathurst +Batista +baton +batons +Bator +bats +battalion +battalions +batted +Battelle +batten +battens +batter +battered +batteries +battering +batters +battery +batting +battle +battled +battlefield +battlefields +battlefront +battlefronts +battleground +battlegrounds +battlement +battlements +battler +battlers +battles +battleship +battleships +battling +bauble +baubles +baud +Baudelaire +Bauer +Bauhaus +Bausch +bauxite +Bavaria +Bavarian +bawdy +bawl +bawled +bawling +bawls +Baxter +bay +Bayda +bayed +Bayes +Bayesian +baying +Baylor +bayonet +bayonets +Bayonne +bayou +bayous +Bayport +Bayreuth +bays +bazaar +bazaars +be +beach +beached +beaches +beachhead +beachheads +beaching +beacon +beacons +bead +beaded +beading +beadle +beadles +beads +beady +beagle +beagles +beak +beaked +beaker +beakers +beaks +beam +beamed +beamer +beamers +beaming +beams +bean +beanbag +beaned +beaner +beaners +beaning +beans +bear +bearable +bearably +beard +bearded +beardless +beards +Beardsley +bearer +bearers +bearing +bearings +bearish +bears +beast +beastly +beasts +beat +beatable +beatably +beaten +beater +beaters +beatific +beatification +beatify +beating +beatings +beatitude +beatitudes +beatnik +beatniks +Beatrice +beats +beau +Beauchamps +Beaujolais +Beaumont +Beauregard +beaus +beauteous +beauteously +beauties +beautifications +beautified +beautifier +beautifiers +beautifies +beautiful +beautifully +beautify +beautifying +beauty +beaver +beavers +Beaverton +becalm +becalmed +becalming +becalms +became +because +Bechtel +beck +Becker +Beckman +beckon +beckoned +beckoning +beckons +Becky +become +becomes +becoming +becomingly +bed +bedazzle +bedazzled +bedazzlement +bedazzles +bedazzling +bedbug +bedbugs +bedded +bedder +bedders +bedding +bedevil +bedeviled +bedeviling +bedevils +bedfast +Bedford +bedlam +bedpost +bedposts +bedraggle +bedraggled +bedridden +bedrock +bedroom +bedrooms +beds +bedside +bedspread +bedspreads +bedspring +bedsprings +bedstead +bedsteads +bedtime +bee +Beebe +beech +Beecham +beechen +beecher +beef +beefed +beefer +beefers +beefing +beefs +beefsteak +beefy +beehive +beehives +been +beep +beeps +beer +beers +bees +beet +Beethoven +beetle +beetled +beetles +beetling +beets +befall +befallen +befalling +befalls +befell +befit +befits +befitted +befitting +befog +befogged +befogging +before +beforehand +befoul +befouled +befouling +befouls +befriend +befriended +befriending +befriends +befuddle +befuddled +befuddles +befuddling +beg +began +beget +begets +begetting +beggar +beggarly +beggars +beggary +begged +begging +begin +beginner +beginners +beginning +beginnings +begins +begot +begotten +begrudge +begrudged +begrudges +begrudging +begrudgingly +begs +beguile +beguiled +beguiles +beguiling +begun +behalf +behave +behaved +behaves +behaving +behavior +behavioral +behaviorally +behaviorism +behavioristic +behaviors +behead +beheading +beheld +behemoth +behemoths +behest +behind +behold +beholden +beholder +beholders +beholding +beholds +behoove +behooves +beige +Beijing +being +beings +Beirut +Bela +belabor +belabored +belaboring +belabors +belated +belatedly +belay +belayed +belaying +belays +belch +belched +belches +belching +Belfast +belfries +belfry +Belgian +Belgians +Belgium +Belgrade +belie +belied +belief +beliefs +belies +believable +believably +believe +believed +believer +believers +believes +believing +belittle +belittled +belittles +belittling +Belize +bell +Bella +Bellamy +Bellatrix +bellboy +bellboys +belle +belles +Belleville +bellhop +bellhops +bellicose +bellicosity +bellies +belligerence +belligerent +belligerently +belligerents +Bellingham +Bellini +bellman +bellmen +Bellovin +bellow +bellowed +bellowing +bellows +bells +bellum +bellwether +bellwethers +Bellwood +belly +bellyache +bellyfull +Belmont +Beloit +belong +belonged +belonging +belongings +belongs +beloved +below +Belshazzar +belt +belted +belting +Belton +belts +Beltsville +Belushi +bely +belying +bemoan +bemoaned +bemoaning +bemoans +Ben +Benares +bench +benched +benches +benchmark +benchmarking +benchmarks +bend +bendable +Bender +benders +bending +Bendix +bends +beneath +Benedict +Benedictine +benediction +benedictions +Benedikt +benefactor +benefactors +beneficence +beneficences +beneficent +beneficial +beneficially +beneficiaries +beneficiary +benefit +benefited +benefiting +benefits +benefitted +benefitting +Benelux +benevolence +benevolent +Bengal +Bengali +benighted +benign +benignly +Benjamin +Bennett +Bennington +Benny +Benson +bent +Bentham +Bentley +Bentleys +Benton +Benz +Benzedrine +benzene +Beograd +Beowulf +bequeath +bequeathal +bequeathed +bequeathing +bequeaths +bequest +bequests +berate +berated +berates +berating +Berea +bereave +bereaved +bereavement +bereavements +bereaves +bereaving +bereft +Berenices +Beresford +beret +berets +Bergen +Bergland +Berglund +Bergman +Bergson +Bergsten +Bergstrom +beribboned +beriberi +Beringer +Berkeley +berkelium +Berkowitz +Berkshire +Berkshires +Berlin +Berliner +Berliners +Berlinize +Berlinizes +Berlioz +Berlitz +Berman +Bermuda +Bern +Bernadine +Bernard +Bernardine +Bernardino +Bernardo +berne +Bernet +Bernhard +Bernice +Bernie +Berniece +Bernini +Bernoulli +Bernstein +Berra +berries +berry +berserk +Bert +berth +Bertha +berths +Bertie +Bertram +Bertrand +Berwick +beryl +beryllium +beseech +beseeches +beseeching +beset +besets +besetting +beside +besides +besiege +besieged +besieger +besiegers +besieging +besmirch +besmirched +besmirches +besmirching +besotted +besotter +besotting +besought +bespeak +bespeaks +bespectacled +bespoke +Bess +Bessel +Bessemer +Bessemerize +Bessemerizes +Bessie +best +bested +bestial +besting +bestir +bestirring +bestow +bestowal +bestowed +bests +bestseller +bestsellers +bestselling +bet +beta +betatron +betel +Betelgeuse +Bethesda +Bethlehem +betide +betray +betrayal +betrayed +betrayer +betraying +betrays +betroth +betrothal +betrothed +bets +Betsey +Betsy +Bette +better +bettered +bettering +betterment +betterments +betters +Betties +betting +Betty +between +betwixt +bevel +beveled +beveling +bevels +beverage +beverages +Beverly +bevy +bewail +bewailed +bewailing +bewails +beware +bewhiskered +bewilder +bewildered +bewildering +bewilderingly +bewilderment +bewilders +bewitch +bewitched +bewitches +bewitching +beyond +Bhagavad-Gita +Bhutan +Bialystok +Bianco +biannual +bias +biased +biases +biasing +bib +bibbed +bibbing +Bible +bibles +biblical +biblically +bibliographic +bibliographical +bibliographies +bibliography +bibliophile +bibs +bicameral +bicarbonate +bicentennial +bicep +biceps +bicker +bickered +bickering +bickers +biconcave +biconnected +biconvex +bicycle +bicycled +bicycler +bicyclers +bicycles +bicycling +bid +biddable +bidden +bidder +bidders +biddies +bidding +Biddle +biddy +bide +bidirectional +bids +Bien +biennial +biennium +Bienville +bier +Bierce +bifocal +bifocals +bifurcate +big +Bigelow +bigger +biggest +Biggs +bight +bights +bigness +bigot +bigoted +bigotry +bigots +biharmonic +bijection +bijections +bijective +bijectively +bike +bikes +biking +bikini +bikinis +bilabial +bilateral +bilaterally +Bilbao +Bilbo +bile +bilge +bilges +bilinear +bilingual +bilk +bilked +bilking +bilks +bill +billboard +billboards +billed +biller +billers +billet +billeted +billeting +billets +billiard +billiards +Billie +Billiken +Billikens +billing +Billings +billion +billions +billionth +billow +billowed +billows +bills +Biltmore +bimetallic +bimetallism +Bimini +bimodal +bimolecular +bimonthlies +bimonthly +bin +binaries +binary +binaural +bind +binder +binders +binding +bindings +binds +bing +binge +binges +Bingham +Binghamton +bingo +Bini +binocular +binoculars +binomial +bins +binuclear +biochemical +biochemist +biochemistry +biofeedback +biographer +biographers +biographic +biographical +biographically +biographies +biography +biological +biologically +biologist +biologists +biology +biomedical +biomedicine +biophysical +biophysicist +biophysics +biopsies +biopsy +bioscience +biosphere +biostatistic +biosynthesize +biota +biotic +bipartisan +bipartite +biped +bipeds +biplane +biplanes +bipolar +biracial +birch +birchen +birches +bird +birdbath +birdbaths +birdie +birdied +birdies +birdlike +birds +birefringence +birefringent +Birgit +Birmingham +Birminghamize +Birminghamizes +birth +birthday +birthdays +birthed +birthplace +birthplaces +birthright +birthrights +births +Biscayne +biscuit +biscuits +bisect +bisected +bisecting +bisection +bisections +bisector +bisectors +bisects +bishop +bishops +Bismarck +Bismark +bismuth +bison +bisons +bisque +bisques +Bissau +bistable +bistate +bit +bitch +bitches +bite +biter +biters +bites +biting +bitingly +bitmap +BITNET +bits +bitten +bitter +bitterer +bitterest +bitterly +bitterness +bitternut +bitterroot +bitters +bittersweet +bitumen +bituminous +bitwise +bivalve +bivalves +bivariate +bivouac +bivouacs +biweekly +bizarre +Bizet +blab +blabbed +blabbermouth +blabbermouths +blabbing +blabs +black +blackberries +blackberry +blackbird +blackbirds +blackboard +blackboards +Blackburn +blacked +blacken +blackened +blackening +blackens +blacker +blackest +Blackfeet +Blackfoot +Blackfoots +blacking +blackjack +blackjacks +blacklist +blacklisted +blacklisting +blacklists +blackly +blackmail +blackmailed +blackmailer +blackmailers +blackmailing +blackmails +Blackman +Blackmer +blackness +blackout +blackouts +blacks +blacksmith +blacksmiths +Blackstone +Blackwell +Blackwells +bladder +bladders +blade +blades +Blaine +Blair +Blake +Blakey +blamable +blame +blamed +blameless +blamelessness +blamer +blamers +blames +blameworthy +blaming +blanch +Blanchard +Blanche +blanched +blanches +blanching +bland +blandly +blandness +blank +blanked +blanker +blankest +blanket +blanketed +blanketer +blanketers +blanketing +blankets +blanking +blankly +blankness +blanks +Blanton +blare +blared +blares +blaring +blase +blaspheme +blasphemed +blasphemes +blasphemies +blaspheming +blasphemous +blasphemously +blasphemousness +blasphemy +blast +blasted +blaster +blasters +blasting +blasts +blatant +blatantly +Blatz +blaze +blazed +blazer +blazers +blazes +blazing +bleach +bleached +bleacher +bleachers +bleaches +bleaching +bleak +bleaker +bleakly +bleakness +blear +bleary +bleat +bleating +bleats +bled +bleed +bleeder +bleeding +bleedings +bleeds +Bleeker +blemish +blemishes +blend +blended +blender +blending +blends +Blenheim +bless +blessed +blessing +blessings +blew +blight +blighted +blimp +blimps +blind +blinded +blinder +blinders +blindfold +blindfolded +blindfolding +blindfolds +blinding +blindingly +blindly +blindness +blinds +blink +blinked +blinker +blinkers +blinking +blinks +Blinn +blip +blips +bliss +blissful +blissfully +blister +blistered +blistering +blisters +blithe +blithely +blitz +blitzes +blitzkrieg +blizzard +blizzards +bloat +bloated +bloater +bloating +bloats +blob +blobs +bloc +Bloch +block +blockade +blockaded +blockades +blockading +blockage +blockages +blocked +blocker +blockers +blockhouse +blockhouses +blocking +blocks +blocs +bloke +blokes +Blomberg +Blomquist +blond +blonde +blondes +blonds +blood +bloodbath +blooded +bloodhound +bloodhounds +bloodied +bloodiest +bloodless +bloods +bloodshed +bloodshot +bloodstain +bloodstained +bloodstains +bloodstream +bloody +bloom +bloomed +bloomers +Bloomfield +blooming +Bloomington +blooms +blooper +blossom +blossomed +blossoms +blot +blots +blotted +blotting +blouse +blouses +blow +blower +blowers +blowfish +blowing +blown +blowout +blows +blowup +blubber +bludgeon +bludgeoned +bludgeoning +bludgeons +blue +blueberries +blueberry +bluebird +bluebirds +bluebonnet +bluebonnets +bluefish +blueness +blueprint +blueprints +bluer +blues +bluest +bluestocking +bluff +bluffing +bluffs +bluing +bluish +Blum +Blumenthal +blunder +blunderbuss +blundered +blundering +blunderings +blunders +blunt +blunted +blunter +bluntest +blunting +bluntly +bluntness +blunts +blur +blurb +blurred +blurring +blurry +blurs +blurt +blurted +blurting +blurts +blush +blushed +blushes +blushing +bluster +blustered +blustering +blusters +blustery +Blythe +boa +boar +board +boarded +boarder +boarders +boarding +boardinghouse +boardinghouses +boards +Boarsh +boast +boasted +boaster +boasters +boastful +boastfully +boasting +boastings +boasts +boat +boater +boaters +boathouse +boathouses +boating +boatload +boatloads +boatman +boatmen +boats +boatsman +boatsmen +boatswain +boatswains +boatyard +boatyards +bob +bobbed +Bobbie +bobbin +bobbing +bobbins +Bobbsey +bobby +bobolink +bobolinks +Bobrow +bobs +bobwhite +bobwhites +Boca +bode +Bodenheim +bodes +bodice +bodied +bodies +bodily +Bodleian +body +bodybuilder +bodybuilders +bodybuilding +bodyguard +bodyguards +bodyweight +Boeing +Boeotia +Boeotian +Boer +Boers +bog +Bogart +Bogartian +bogeymen +bogged +boggle +boggled +boggles +boggling +Bogota +bogs +bogus +Boheme +Bohemia +Bohemian +Bohemianism +Bohr +boil +boiled +boiler +boilerplate +boilers +boiling +boils +Bois +Boise +boisterous +boisterously +bold +bolder +boldest +boldface +boldly +boldness +Bolivia +Bolivian +boll +Bologna +Bolshevik +Bolsheviks +Bolshevism +Bolshevist +Bolshevistic +Bolshoi +bolster +bolstered +bolstering +bolsters +bolt +bolted +bolting +Bolton +bolts +Boltzmann +bomb +bombard +bombarded +bombarding +bombardment +bombards +bombast +bombastic +Bombay +bombed +bomber +bombers +bombing +bombings +bombproof +bombs +bonanza +bonanzas +Bonaparte +Bonaventure +bond +bondage +bonded +bonder +bonders +bonding +bonds +bondsman +bondsmen +bone +boned +boner +boners +bones +bonfire +bonfires +bong +Bonham +Boniface +boning +Bonn +bonnet +bonneted +bonnets +Bonneville +Bonnie +bonny +Bontempo +bonus +bonuses +bony +boo +boob +booboo +booby +book +bookcase +bookcases +booked +booker +bookers +bookie +bookies +booking +bookings +bookish +bookkeeper +bookkeepers +bookkeeping +booklet +booklets +bookmark +books +bookseller +booksellers +bookshelf +bookshelves +bookstore +bookstores +bookworm +boolean +Booleans +boom +boomed +boomerang +boomerangs +booming +booms +boon +Boone +Boonton +boor +boorish +boors +boos +boost +boosted +booster +boosting +boosts +boot +bootable +booted +Bootes +booth +booths +booting +Bootle +bootleg +bootlegged +bootlegger +bootleggers +bootlegging +bootlegs +boots +bootstrap +bootstrapped +bootstrapping +bootstraps +booty +booze +borate +borates +borax +Bordeaux +bordello +bordellos +Borden +border +bordered +bordering +borderings +borderland +borderlands +borderline +borders +bore +Borealis +Boreas +bored +boredom +borer +bores +Borg +boric +boring +Boris +born +borne +Borneo +boron +borough +boroughs +Borroughs +borrow +borrowed +borrower +borrowers +borrowing +borrows +Bosch +Bose +bosom +bosoms +Bosporus +boss +bossed +bosses +Bostitch +Boston +Bostonian +Bostonians +bosun +Boswell +Boswellize +Boswellizes +botanical +botanist +botanists +botany +botch +botched +botcher +botchers +botches +botching +both +bother +bothered +bothering +bothers +bothersome +Botswana +bottle +bottled +bottleneck +bottlenecks +bottler +bottlers +bottles +bottling +bottom +bottomed +bottoming +bottomless +bottoms +botulinus +botulism +Boucher +bouffant +bough +boughs +bought +boulder +boulders +boulevard +boulevards +bounce +bounced +bouncer +bounces +bouncing +bouncy +bound +boundaries +boundary +bounded +bounden +bounding +boundless +boundlessness +bounds +bounteous +bounteously +bounties +bountiful +bounty +bouquet +bouquets +Bourbaki +bourbon +bourgeois +bourgeoisie +Bourne +boustrophedon +boustrophedonic +bout +boutique +bouts +Bouvier +bovine +bovines +bow +Bowditch +bowdlerize +bowdlerized +bowdlerizes +bowdlerizing +Bowdoin +bowed +bowel +bowels +Bowen +bower +bowers +Bowes +bowing +bowl +bowled +bowler +bowlers +bowline +bowlines +bowling +bowls +bowman +bows +bowstring +bowstrings +box +boxcar +boxcars +boxed +boxer +boxers +boxes +Boxford +boxing +boxtop +boxtops +boxwood +boy +Boyce +boycott +boycotted +boycotts +Boyd +boyfriend +boyfriends +boyhood +boyish +boyishness +Boyle +Boylston +boys +bra +brace +braced +bracelet +bracelets +braces +bracing +bracket +bracketed +bracketing +brackets +brackish +Bradbury +Bradford +Bradley +Bradshaw +Brady +brae +braes +brag +Bragg +bragged +bragger +bragging +brags +Brahmaputra +Brahms +Brahmsian +braid +braided +braiding +braids +Braille +brain +Brainard +Brainards +brainchild +brained +braining +brains +brainstem +brainstems +brainstorm +brainstorms +brainwash +brainwashed +brainwashes +brainwashing +brainy +brake +braked +brakeman +brakes +braking +bramble +brambles +brambly +bran +branch +branched +branches +branching +branchings +Branchville +brand +branded +Brandeis +Brandel +Brandenburg +branding +brandish +brandishes +brandishing +Brandon +brands +Brandt +brandy +brandywine +Braniff +Brannon +bras +brash +brashly +brashness +Brasilia +brass +brasses +brassiere +Brasstown +brassy +brat +brats +Braun +bravado +brave +braved +bravely +braveness +braver +bravery +braves +bravest +braving +bravo +bravos +brawl +brawler +brawling +brawn +bray +brayed +brayer +braying +brays +braze +brazed +brazen +brazenly +brazenness +brazes +brazier +braziers +Brazil +Brazilian +brazing +Brazzaville +breach +breached +breacher +breachers +breaches +breaching +bread +breadboard +breadboards +breadbox +breadboxes +breaded +breading +breads +breadth +breadwinner +breadwinners +break +breakable +breakables +breakage +breakaway +breakdown +breakdowns +breaker +breakers +breakfast +breakfasted +breakfaster +breakfasters +breakfasting +breakfasts +breaking +breakpoint +breakpoints +breaks +breakthrough +breakthroughes +breakthroughs +breakup +breakwater +breakwaters +breast +breasted +breasts +breastwork +breastworks +breath +breathable +breathe +breathed +breather +breathers +breathes +breathing +breathless +breathlessly +breaths +breathtaking +breathtakingly +breathy +bred +breech +breeches +breed +breeder +breeding +breeds +breeze +breezes +breezily +breezy +Bremen +bremsstrahlung +Brenda +Brendan +Brennan +Brenner +Brent +Bresenham +Brest +brethren +Breton +Bretons +Brett +breve +brevet +breveted +breveting +brevets +brevity +brew +brewed +brewer +breweries +brewers +brewery +brewing +brews +Brewster +Brian +briar +briars +bribe +bribed +briber +bribers +bribery +bribes +bribing +Brice +brick +brickbat +bricked +bricker +bricklayer +bricklayers +bricklaying +bricks +bridal +bride +bridegroom +brides +bridesmaid +bridesmaids +Bridewell +bridge +bridgeable +bridged +bridgehead +bridgeheads +Bridgeport +bridges +Bridget +Bridgetown +Bridgewater +bridgework +bridging +bridle +bridled +bridles +bridling +Brie +brief +briefcase +briefcases +briefed +briefer +briefest +briefing +briefings +briefly +briefness +briefs +Brien +brier +brig +brigade +brigades +brigadier +brigadiers +Brigadoon +brigantine +Briggs +Brigham +bright +brighten +brightened +brightener +brighteners +brightening +brightens +brighter +brightest +brightly +brightness +Brighton +brigs +brilliance +brilliancy +brilliant +brilliantly +Brillouin +brim +brimful +brimmed +brimming +brimstone +Brindisi +brindle +brindled +brine +bring +bringer +bringers +bringing +brings +brink +Brinkley +brinkmanship +briny +Brisbane +brisk +brisker +briskly +briskness +bristle +bristled +bristles +bristling +Bristol +Britain +Britannic +Britannica +britches +British +Britisher +Britishly +Briton +Britons +Brittany +Britten +brittle +brittleness +broach +broached +broaches +broaching +broad +broadband +broadcast +broadcasted +broadcaster +broadcasters +broadcasting +broadcastings +broadcasts +broaden +broadened +broadener +broadeners +broadening +broadenings +broadens +broader +broadest +broadly +broadness +broadside +Broadway +brocade +brocaded +broccoli +brochure +brochures +Brock +Broglie +broil +broiled +broiler +broilers +broiling +broils +broke +broken +brokenly +brokenness +broker +brokerage +brokers +Bromfield +bromide +bromides +bromine +Bromley +bronchi +bronchial +bronchiole +bronchioles +bronchitis +bronchus +Brontosaurus +Bronx +bronze +bronzed +bronzes +brooch +brooches +brood +brooder +brooding +broods +brook +Brookdale +Brooke +brooked +Brookfield +Brookhaven +Brookline +Brooklyn +Brookmont +brooks +broom +brooms +broomstick +broomsticks +broth +brothel +brothels +brother +brotherhood +brotherliness +brotherly +brothers +brought +brow +browbeat +browbeaten +browbeating +browbeats +brown +Browne +browned +Brownell +browner +brownest +Brownian +brownie +brownies +browning +brownish +brownness +browns +brows +browse +browsing +Bruce +Bruckner +Bruegel +bruise +bruised +bruises +bruising +Brumidi +brunch +brunches +brunette +Brunhilde +Bruno +Brunswick +brunt +brush +brushed +brushes +brushfire +brushfires +brushing +brushlike +brushy +brusque +brusquely +Brussels +brutal +brutalities +brutality +brutalize +brutalized +brutalizes +brutalizing +brutally +brute +brutes +brutish +Bruxelles +Bryan +Bryant +Bryce +Bryn +bubble +bubbled +bubbles +bubbling +bubbly +Buchanan +Bucharest +Buchenwald +Buchwald +buck +buckboard +buckboards +bucked +bucket +buckets +bucking +buckle +buckled +buckler +buckles +Buckley +buckling +Bucknell +bucks +buckshot +buckskin +buckskins +buckwheat +Bucky +bucolic +bud +Budapest +Budd +budded +Buddha +Buddhism +Buddhist +Buddhists +buddies +budding +buddy +budge +budged +budges +budget +budgetary +budgeted +budgeter +budgeters +budgeting +budgets +budging +buds +Budweiser +Budweisers +Buehring +Buena +Buenos +buff +buffalo +buffaloes +buffer +buffered +buffering +buffers +buffet +buffeted +buffeting +buffetings +buffets +buffoon +buffoons +buffs +bug +bugaboo +Bugatti +bugeyed +bugged +bugger +buggers +buggies +bugging +buggy +bugle +bugled +bugler +bugles +bugling +bugs +Buick +build +builder +builders +building +buildings +builds +buildup +buildups +built +builtin +Bujumbura +bulb +Bulba +bulbs +Bulgaria +Bulgarian +bulge +bulged +bulging +bulk +bulked +bulkhead +bulkheads +bulks +bulky +bull +bulldog +bulldogs +bulldoze +bulldozed +bulldozer +bulldozes +bulldozing +bulled +bullet +bulletin +bulletins +bullets +bullfrog +bullied +bullies +bulling +bullion +bullish +bullock +bulls +bullseye +bully +bullying +bulwark +bum +bumble +bumblebee +bumblebees +bumbled +bumbler +bumblers +bumbles +bumbling +Bumbry +bummed +bumming +bump +bumped +bumper +bumpers +bumping +bumps +bumptious +bumptiously +bumptiousness +bums +bun +bunch +bunched +bunches +bunching +Bundestag +bundle +bundled +bundles +bundling +Bundoora +Bundy +bungalow +bungalows +bungle +bungled +bungler +bunglers +bungles +bungling +bunion +bunions +bunk +bunker +bunkered +bunkers +bunkhouse +bunkhouses +bunkmate +bunkmates +bunks +bunnies +bunny +buns +Bunsen +bunt +bunted +bunter +bunters +bunting +bunts +Bunyan +buoy +buoyancy +buoyant +buoyed +buoys +Burbank +Burch +burden +burdened +burdening +burdens +burdensome +bureau +bureaucracies +bureaucracy +bureaucrat +bureaucratic +bureaucrats +bureaus +burgeon +burgeoned +burgeoning +burgess +burgesses +burgher +burghers +burglar +burglaries +burglarize +burglarized +burglarizes +burglarizing +burglarproof +burglarproofed +burglarproofing +burglarproofs +burglars +burglary +Burgundian +Burgundies +Burgundy +burial +buried +buries +Burke +Burkes +burl +burlesque +burlesques +Burlingame +Burlington +burly +Burma +Burmese +burn +Burne +burned +burner +burners +Burnes +Burnett +Burnham +burning +burningly +burnings +burnish +burnished +burnishes +burnishing +burns +Burnside +Burnsides +burnt +burntly +burntness +burp +burped +burping +burps +Burr +Burroughs +burrow +burrowed +burrower +burrowing +burrows +burrs +bursa +bursitis +burst +burstiness +bursting +bursts +bursty +Burt +Burton +Burtt +Burundi +bury +burying +bus +busboy +busboys +Busch +bused +buses +bush +bushel +bushels +bushes +bushing +Bushnell +bushwhack +bushwhacked +bushwhacking +bushwhacks +bushy +busied +busier +busiest +busily +business +businesses +businesslike +businessman +businessmen +busing +buss +bussed +busses +bussing +bust +bustard +bustards +busted +buster +bustle +bustling +busts +busy +but +butane +butcher +butchered +butchers +butchery +butler +butlers +butt +butte +butted +butter +butterball +buttercup +buttered +butterer +butterers +butterfat +Butterfield +butterflies +butterfly +buttering +buttermilk +butternut +butters +buttery +buttes +butting +buttock +buttocks +button +buttoned +buttonhole +buttonholes +buttoning +buttons +buttress +buttressed +buttresses +buttressing +Buttrick +butts +butyl +butyrate +buxom +Buxtehude +Buxton +buy +buyer +buyers +buying +buys +buzz +Buzzard +buzzards +buzzed +buzzer +buzzes +buzzing +buzzword +buzzwords +buzzy +by +bye +Byers +bygone +bylaw +bylaws +byline +bylines +bypass +bypassed +bypasses +bypassing +byproduct +byproducts +Byrd +Byrne +Byron +Byronic +Byronism +Byronize +Byronizes +bystander +bystanders +byte +bytes +byway +byways +byword +bywords +Byzantine +Byzantinize +Byzantinizes +Byzantium +cab +cabal +cabana +cabaret +cabbage +cabbages +cabdriver +cabin +cabinet +cabinets +cabins +cable +cabled +cables +cabling +caboose +Cabot +cabs +cache +cached +caches +caching +cackle +cackled +cackler +cackles +cackling +cacti +cactus +cadaver +cadence +cadenced +Cadillac +Cadillacs +cadres +Cady +Caesar +Caesarian +Caesarize +Caesarizes +cafe +cafes +cafeteria +cage +caged +cager +cagers +cages +caging +Cahill +caiman +Cain +Caine +cairn +Cairo +cajole +cajoled +cajoles +cajoling +Cajun +Cajuns +cake +caked +cakes +caking +Calais +calamities +calamitous +calamity +Calceolaria +calcify +calcium +CALCOMP +CalComp +Calcomp +calculate +calculated +calculates +calculating +calculation +calculations +calculative +calculator +calculators +calculi +calculus +Calcutta +Calder +caldera +Caldwell +Caleb +calendar +calendars +calf +calfskin +Calgary +Calhoun +caliber +calibers +calibrate +calibrated +calibrates +calibrating +calibration +calibrations +calico +California +Californian +Californians +Caligula +caliph +caliphs +Calkins +call +callable +Callaghan +Callahan +Callan +called +caller +callers +calling +calliope +Callisto +callous +calloused +callously +callousness +calls +callus +calm +calmed +calmer +calmest +calming +calmingly +calmly +calmness +calms +caloric +calorie +calories +calorimeter +calorimetric +calorimetry +Caltech +calumny +Calvary +calve +Calvert +calves +Calvin +Calvinist +Calvinize +Calvinizes +calypso +cam +Cambodia +Cambrian +Cambridge +Camden +came +camel +Camelot +camels +Camembert +camera +cameraman +cameramen +cameras +Cameron +Cameroon +Cameroun +Camilla +Camille +Camino +camouflage +camouflaged +camouflages +camouflaging +camp +campaign +campaigned +campaigner +campaigners +campaigning +campaigns +Campbell +Campbellsport +camped +camper +campers +campfire +campground +camping +camps +campsite +campus +campuses +can +Canaan +Canada +Canadian +Canadianization +Canadianizations +Canadianize +Canadianizes +Canadians +canal +canals +canaries +canary +Canaveral +Canberra +cancel +canceled +canceling +cancellation +cancellations +cancels +cancer +cancerous +cancers +Candace +candid +candidacy +candidate +candidates +Candide +candidly +candidness +candied +candies +candle +candlelight +candler +candles +candlestick +candlesticks +Candlewick +candor +candy +cane +caner +Canfield +canine +Canis +canister +canker +cankerworm +cannabis +canned +cannel +canner +canners +cannery +cannibal +cannibalize +cannibalized +cannibalizes +cannibalizing +cannibals +canning +cannister +cannisters +cannon +cannonball +cannons +cannot +canny +canoe +canoes +Canoga +canon +canonic +canonical +canonicalization +canonicalize +canonicalized +canonicalizes +canonicalizing +canonically +canonicals +canons +Canopus +canopy +cans +cant +Cantabrigian +cantaloupe +cantankerous +cantankerously +canteen +Canterbury +cantilever +canto +canton +Cantonese +cantons +cantor +cantors +Canute +canvas +canvases +canvass +canvassed +canvasser +canvassers +canvasses +canvassing +canyon +canyons +cap +capabilities +capability +capable +capably +capacious +capaciously +capaciousness +capacitance +capacitances +capacities +capacitive +capacitor +capacitors +capacity +cape +caper +capers +capes +Capet +Capetown +capillary +Capistrano +capita +capital +capitalism +capitalist +capitalists +capitalization +capitalizations +capitalize +capitalized +capitalizer +capitalizers +capitalizes +capitalizing +capitally +capitals +Capitan +capitol +Capitoline +capitols +capped +capping +Cappy +caprice +capricious +capriciously +capriciousness +Capricorn +caps +Capsicum +capstan +capstone +capsule +captain +captained +captaining +captains +caption +captions +captivate +captivated +captivates +captivating +captivation +captive +captives +captivity +captor +captors +capture +captured +capturer +capturers +captures +capturing +Caputo +capybara +car +Caracas +caramel +caravan +caravans +caraway +carbohydrate +carbolic +Carboloy +carbon +carbonate +carbonates +carbonation +Carbondale +Carbone +Carbones +carbonic +carbonization +carbonize +carbonized +carbonizer +carbonizers +carbonizes +carbonizing +carbons +carborundum +carbuncle +carcass +carcasses +carcinogen +carcinogenic +carcinoma +card +cardboard +carder +cardiac +Cardiff +cardinal +cardinalities +cardinality +cardinally +cardinals +Cardiod +cardiology +cardiovascular +cards +care +cared +careen +career +careers +carefree +careful +carefully +carefulness +careless +carelessly +carelessness +cares +caress +caressed +caresser +caresses +caressing +caret +caretaker +Carey +Cargill +cargo +cargoes +Carib +Caribbean +caribou +caricature +caring +Carl +Carla +Carleton +Carletonian +Carlin +Carlisle +Carlo +carload +Carlsbad +Carlsbads +Carlson +Carlton +Carlyle +Carmela +Carmen +Carmichael +carnage +carnal +carnation +Carnegie +carnival +carnivals +carnivorous +carnivorously +carol +Carolina +Carolinas +Caroline +Carolingian +Carolinian +Carolinians +carols +Carolyn +carp +Carpathia +Carpathians +carpenter +carpenters +carpentry +carpet +carpeted +carpeting +carpets +carport +Carr +Carrara +carriage +carriages +Carrie +carried +carrier +carriers +carries +carrion +Carroll +carrot +carrots +Carruthers +carry +carrying +carryover +carryovers +cars +Carson +cart +carted +cartel +carter +carters +Cartesian +Carthage +Carthaginian +cartilage +carting +cartographer +cartographic +cartography +carton +cartons +cartoon +cartoons +cartridge +cartridges +carts +cartwheel +Carty +Caruso +carve +carved +carver +carves +carving +carvings +Casanova +cascadable +cascade +cascaded +cascades +cascading +case +cased +casement +casements +cases +casework +Casey +cash +cashed +casher +cashers +cashes +cashew +cashier +cashiers +cashing +cashmere +casing +casings +casino +cask +casket +caskets +casks +Caspian +Cassandra +casserole +casseroles +cassette +Cassiopeia +Cassite +Cassites +Cassius +cassock +cast +caste +caster +casters +castes +castigate +Castillo +casting +castle +castled +castles +castor +Castro +Castroism +casts +casual +casually +casualness +casuals +casualties +casualty +cat +cataclysmic +Catalan +Catalina +catalog +cataloged +cataloger +cataloging +catalogs +Catalonia +catalyst +catalysts +catalytic +catapult +cataract +catastrophe +catastrophes +catastrophic +Catawba +catch +catchable +catcher +catchers +catches +catching +categorical +categorically +categories +categorization +categorize +categorized +categorizer +categorizers +categorizes +categorizing +category +cater +catered +caterer +catering +caterpillar +caterpillars +caters +cathedral +cathedrals +Catherine +Catherwood +catheter +catheters +cathode +cathodes +Catholic +Catholicism +Catholicisms +Catholics +Cathy +catlike +catnip +cats +Catskill +Catskills +catsup +cattail +cattle +cattleman +cattlemen +Caucasian +Caucasians +Caucasus +Cauchy +caucus +caught +cauldron +cauldrons +cauliflower +caulk +causal +causality +causally +causation +causations +cause +caused +causer +causes +causeway +causeways +causing +caustic +causticly +caustics +caution +cautioned +cautioner +cautioners +cautioning +cautionings +cautions +cautious +cautiously +cautiousness +cavalier +cavalierly +cavalierness +cavalry +cave +caveat +caveats +caved +caveman +cavemen +Cavendish +cavern +cavernous +caverns +caves +caviar +cavil +Caviness +caving +cavities +cavity +caw +cawing +Cayley +Cayuga +cease +ceased +ceaseless +ceaselessly +ceaselessness +ceases +ceasing +Cecil +Cecilia +Cecropia +cedar +cede +ceded +ceding +Cedric +ceiling +ceilings +Celanese +Celebes +celebrate +celebrated +celebrates +celebrating +celebration +celebrations +celebrities +celebrity +celerity +celery +Celeste +celestial +celestially +Celia +cell +cellar +cellars +celled +cellist +cellists +cellophane +cells +cellular +cellulose +Celsius +Celt +Celtic +Celticize +Celticizes +cement +cemented +cementing +cements +cemeteries +cemetery +Cenozoic +censor +censored +censoring +censors +censorship +censure +censured +censurer +censures +census +censuses +cent +centaur +centenary +centennial +center +centered +centering +centerpiece +centerpieces +centers +centigrade +centimeter +centimeters +centipede +centipedes +central +Centralia +centralism +centralist +centralization +centralize +centralized +centralizes +centralizing +centrally +CENTREX +Centrex +centrifugal +centrifuge +centripetal +centrist +centroid +cents +centuries +century +Cepheus +ceramic +Cerberus +cereal +cereals +cerebellum +cerebral +ceremonial +ceremonially +ceremonialness +ceremonies +ceremony +Ceres +CERN +certain +certainly +certainties +certainty +certifiable +certificate +certificates +certification +certifications +certified +certifier +certifiers +certifies +certify +certifying +Cervantes +Cesare +cessation +cessations +Cessna +Cetus +Ceylon +Cezanne +Cezannes +Chablis +Chablises +Chad +Chadwick +chafe +chafer +chaff +chaffer +Chaffey +chaffing +chafing +chagrin +chain +chained +chaining +chains +chair +chaired +chairing +chairlady +chairman +chairmen +chairperson +chairpersons +chairs +chairwoman +chairwomen +chalice +chalices +chalk +chalked +chalking +chalks +challenge +challenged +challenger +challengers +challenges +challenging +Chalmers +chamber +chambered +chamberlain +chamberlains +chambermaid +Chambers +chameleon +champagne +Champaign +champion +championed +championing +champions +championship +championships +Champlain +chance +chanced +chancellor +Chancellorsville +chancery +chances +chancing +chandelier +chandeliers +Chandigarh +Chang +change +changeability +changeable +changeably +changed +changeover +changer +changers +changes +changing +channel +channeled +channeling +channelled +channeller +channellers +channelling +channels +Channing +chant +chanted +chanter +chanticleer +chanticleers +Chantilly +chanting +chants +Chao +chaos +chaotic +chap +chapel +chapels +chaperon +chaperone +chaperoned +chaplain +chaplains +Chaplin +Chapman +chaps +chapter +chapters +char +character +characteristic +characteristically +characteristics +characterizable +characterization +characterizations +characterize +characterized +characterizer +characterizers +characterizes +characterizing +characters +charcoal +charcoaled +charge +chargeable +charged +charger +chargers +charges +charging +chariot +chariots +charisma +charismatic +charitable +charitableness +charities +charity +Charlemagne +Charlemagnes +Charles +Charleston +Charley +Charlie +Charlotte +Charlottesville +charm +charmed +charmer +charmers +charming +charmingly +charms +Charon +chars +chart +Charta +chartable +charted +charter +chartered +chartering +charters +charting +chartings +Chartres +chartreuse +charts +Charybdis +chase +chased +chaser +chasers +chases +chasing +chasm +chasms +chassis +chaste +chastely +chasteness +chastise +chastised +chastiser +chastisers +chastises +chastising +chastity +chat +chateau +chateaus +Chatham +Chattahoochee +Chattanooga +chattel +chatter +chattered +chatterer +chattering +chatters +chatting +chatty +Chaucer +chauffeur +chauffeured +Chauncey +Chautauqua +cheap +cheapen +cheapened +cheapening +cheapens +cheaper +cheapest +cheaply +cheapness +cheat +cheated +cheater +cheaters +cheating +cheats +check +checkable +checkbook +checkbooks +checked +checker +checkerboard +checkerboarded +checkerboarding +checkers +checking +checklist +checkout +checkpoint +checkpoints +checks +checksum +checksummed +checksumming +checksums +checkup +cheek +cheekbone +cheeks +cheeky +cheer +cheered +cheerer +cheerful +cheerfully +cheerfulness +cheerily +cheeriness +cheering +cheerleader +cheerless +cheerlessly +cheerlessness +cheers +cheery +cheese +cheesecloth +cheeses +cheesy +cheetah +chef +chefs +Chekhov +Chelsea +chemical +chemically +chemicals +chemise +chemist +chemistries +chemistry +chemists +Chen +Cheney +Cheng +cherish +cherished +cherishes +cherishing +Cheriton +Cherokee +Cherokees +cherries +cherry +cherub +cherubim +cherubs +Cheryl +Chesapeake +Cheshire +chess +chest +Chester +Chesterfield +Chesterton +chestnut +chestnuts +chests +Chevrolet +Chevy +chew +chewed +chewer +chewers +chewing +chews +Cheyenne +Cheyennes +Chiang +chic +Chicago +Chicagoan +Chicagoans +Chicana +Chicanas +chicanery +Chicano +Chicanos +chick +chickadee +chickadees +Chickasaws +chicken +chickens +chicks +chide +chided +chides +chiding +chief +chiefly +chiefs +chieftain +chieftains +chiffon +child +childbirth +childhood +childish +childishly +childishness +childlike +children +Chile +Chilean +Chiles +chili +chill +chilled +chiller +chillers +chillier +chilliness +chilling +chillingly +chills +chilly +chime +chimera +chimes +chimney +chimneys +chimpanzee +chin +China +Chinaman +Chinamen +Chinas +Chinatown +Chinese +Ching +chink +chinked +chinks +chinned +chinner +chinners +chinning +Chinook +chins +chintz +chip +chipmunk +chipmunks +Chippendale +Chippewa +chips +chiropractor +chirp +chirped +chirping +chirps +chisel +chiseled +chiseler +chisels +Chisholm +chit +chivalrous +chivalrously +chivalrousness +chivalry +Chloe +chlorine +chloroform +chlorophyll +chloroplast +chloroplasts +chock +chocks +chocolate +chocolates +Choctaw +Choctaws +choice +choices +choicest +choir +choirs +choke +choked +choker +chokers +chokes +choking +cholera +Chomsky +choose +chooser +choosers +chooses +choosing +chop +Chopin +chopped +chopper +choppers +chopping +choppy +chops +choral +chord +chordate +chorded +chording +chords +chore +choreograph +choreography +chores +choring +chortle +chorus +chorused +choruses +chose +chosen +Chou +chowder +Chris +Christ +christen +Christendom +christened +christening +christens +Christensen +Christenson +Christian +Christiana +Christianity +Christianization +Christianizations +Christianize +Christianizer +Christianizers +Christianizes +Christianizing +Christians +Christiansen +Christianson +Christie +Christina +Christine +Christlike +Christmas +Christoffel +Christoph +Christopher +Christy +chromatogram +chromatograph +chromatography +chrome +chromium +chromosphere +chronic +chronicle +chronicled +chronicler +chroniclers +chronicles +chronograph +chronography +chronological +chronologically +chronologies +chronology +chrysanthemum +Chrysler +chubbier +chubbiest +chubbiness +chubby +chuck +chuckle +chuckled +chuckles +chucks +chum +Chungking +chunk +chunks +chunky +church +churches +churchgoer +churchgoing +Churchill +Churchillian +churchly +churchman +churchmen +churchwoman +churchwomen +churchyard +churchyards +churn +churned +churning +churns +chute +chutes +chutzpah +cicada +Cicero +Ciceronian +Ciceronianize +Ciceronianizes +cider +cigar +cigarette +cigarettes +cigars +cilia +Cincinnati +cinder +Cinderella +cinders +Cindy +cinema +cinematic +Cinerama +cinnamon +cipher +ciphers +ciphertext +ciphertexts +circa +Circe +circle +circled +circles +circlet +circling +circuit +circuitous +circuitously +circuitry +circuits +circulant +circular +circularity +circularly +circulate +circulated +circulates +circulating +circulation +circumcise +circumcision +circumference +circumflex +circumlocution +circumlocutions +circumnavigate +circumnavigated +circumnavigates +circumpolar +circumscribe +circumscribed +circumscribing +circumscription +circumspect +circumspection +circumspectly +circumstance +circumstanced +circumstances +circumstantial +circumstantially +circumvent +circumventable +circumvented +circumventing +circumvents +circus +circuses +cistern +cisterns +citadel +citadels +citation +citations +cite +cited +cites +cities +citing +citizen +citizens +citizenship +Citroen +citrus +city +cityscape +citywide +civet +civic +civics +civil +civilian +civilians +civility +civilization +civilizations +civilize +civilized +civilizes +civilizing +civilly +clad +cladding +claim +claimable +claimant +claimants +claimed +claiming +claims +Claire +clairvoyant +clairvoyantly +clam +clamber +clambered +clambering +clambers +clamor +clamored +clamoring +clamorous +clamors +clamp +clamped +clamping +clamps +clams +clan +clandestine +clang +clanged +clanging +clangs +clank +clannish +clap +clapboard +Clapeyron +clapping +claps +Clara +Clare +Claremont +Clarence +Clarendon +clarification +clarifications +clarified +clarifies +clarify +clarifying +clarinet +clarity +Clark +Clarke +Clarridge +clash +clashed +clashes +clashing +clasp +clasped +clasping +clasps +class +classed +classes +classic +classical +classically +classics +classifiable +classification +classifications +classified +classifier +classifiers +classifies +classify +classifying +classmate +classmates +classroom +classrooms +classy +clatter +clattered +clattering +Claude +Claudia +Claudio +Claus +clause +Clausen +clauses +Clausius +claustrophobia +claustrophobic +claw +clawed +clawing +claws +clay +clays +Clayton +clean +cleaned +cleaner +cleaners +cleanest +cleaning +cleanliness +cleanly +cleanness +cleans +cleanse +cleansed +cleanser +cleansers +cleanses +cleansing +cleanup +clear +clearance +clearances +cleared +clearer +clearest +clearing +clearings +clearly +clearness +clears +Clearwater +cleavage +cleave +cleaved +cleaver +cleavers +cleaves +cleaving +cleft +clefts +clemency +Clemens +clement +Clemente +Clemson +clench +clenched +clenches +clergy +clergyman +clergymen +clerical +clerk +clerked +clerking +clerks +Cleveland +clever +cleverer +cleverest +cleverly +cleverness +cliche +cliches +click +clicked +clicking +clicks +client +clientele +clients +cliff +Clifford +cliffs +Clifton +climate +climates +climatic +climatically +climatology +climax +climaxed +climaxes +climb +climbed +climber +climbers +climbing +climbs +clime +climes +clinch +clinched +clincher +clinches +cling +clinging +clings +clinic +clinical +clinically +clinician +clinics +clink +clinked +clinker +Clint +Clinton +Clio +clip +clipboard +clipped +clipper +clippers +clipping +clippings +clips +clique +cliques +clitoris +Clive +cloak +cloakroom +cloaks +clobber +clobbered +clobbering +clobbers +clock +clocked +clocker +clockers +clocking +clockings +clocks +clockwatcher +clockwise +clockwork +clod +clods +clog +clogged +clogging +clogs +cloister +cloisters +clone +cloned +clones +cloning +close +closed +closely +closeness +closenesses +closer +closers +closes +closest +closet +closeted +closets +closeup +closing +closure +closures +clot +cloth +clothe +clothed +clothes +clotheshorse +clothesline +clothing +Clotho +clotting +cloture +cloud +cloudburst +clouded +cloudier +cloudiest +cloudiness +clouding +cloudless +clouds +cloudy +clout +clove +clover +cloves +clown +clowning +clowns +club +clubbed +clubbing +clubhouse +clubroom +clubs +cluck +clucked +clucking +clucks +clue +clues +Cluj +clump +clumped +clumping +clumps +clumsily +clumsiness +clumsy +clung +cluster +clustered +clustering +clusterings +clusters +clutch +clutched +clutches +clutching +clutter +cluttered +cluttering +clutters +Clyde +Clytemnestra +coach +coached +coacher +coaches +coaching +coachman +coachmen +coagulate +coal +coalesce +coalesced +coalesces +coalescing +coalition +coals +coarse +coarsely +coarsen +coarsened +coarseness +coarser +coarsest +coast +coastal +coasted +coaster +coasters +coasting +coastline +coasts +coat +coated +Coates +coating +coatings +coats +coattail +coauthor +coax +coaxed +coaxer +coaxes +coaxial +coaxing +cobalt +Cobb +cobble +cobbler +cobblers +cobblestone +COBOL +Cobol +cobra +cobweb +cobwebs +coca +cocaine +Cochise +Cochran +Cochrane +cock +cocked +cocking +cockpit +cockroach +cocks +cocktail +cocktails +cocky +coco +cocoa +coconut +coconuts +cocoon +cocoons +cod +Coddington +coddle +code +coded +codeine +coder +coders +codes +codeword +codewords +codfish +codicil +codification +codifications +codified +codifier +codifiers +codifies +codify +codifying +coding +codings +codpiece +Cody +coed +coeditor +coeducation +coefficient +coefficients +coequal +coerce +coerced +coerces +coercible +coercing +coercion +coercive +coexist +coexisted +coexistence +coexisting +coexists +cofactor +coffee +coffeecup +coffeepot +coffees +coffer +coffers +Coffey +coffin +coffins +Coffman +cog +cogent +cogently +cogitate +cogitated +cogitates +cogitating +cogitation +cognac +cognition +cognitive +cognitively +cognizance +cognizant +cogs +cohabitation +cohabitations +Cohen +cohere +cohered +coherence +coherent +coherently +coheres +cohering +cohesion +cohesive +cohesively +cohesiveness +Cohn +cohort +coil +coiled +coiling +coils +coin +coinage +coincide +coincided +coincidence +coincidences +coincident +coincidental +coincides +coinciding +coined +coiner +coining +coins +coke +cokes +colander +Colby +cold +colder +coldest +coldly +coldness +colds +Cole +Coleman +Coleridge +Colette +Colgate +colicky +coliform +coliseum +collaborate +collaborated +collaborates +collaborating +collaboration +collaborations +collaborative +collaborator +collaborators +collagen +collapse +collapsed +collapses +collapsible +collapsing +collar +collarbone +collared +collaring +collars +collate +collateral +colleague +colleagues +collect +collected +collectible +collecting +collection +collections +collective +collectively +collectives +collector +collectors +collects +college +colleges +collegian +collegiate +collide +collided +collides +colliding +collie +Collier +collies +Collins +collision +collisions +colloidal +colloquia +colloquial +colloquium +colloquy +collusion +Cologne +Colombia +Colombian +Colombians +Colombo +colon +colonel +colonels +colonial +colonially +colonials +colonies +colonist +colonists +colonization +colonize +colonized +colonizer +colonizers +colonizes +colonizing +colons +colony +color +Colorado +colored +colorer +colorers +colorful +coloring +colorings +colorless +colors +colossal +Colosseum +colt +colts +Columbia +Columbian +Columbus +column +columnize +columnized +columnizes +columnizing +columns +Comanche +comb +combat +combatant +combatants +combated +combating +combative +combats +combed +comber +combers +combination +combinational +combinations +combinator +combinatorial +combinatorially +combinatoric +combinatorics +combinators +combine +combined +combines +combing +combings +combining +combs +combustible +combustion +Comdex +come +comeback +comedian +comedians +comedic +comedies +comedy +comeliness +comely +comer +comers +comes +comestible +comet +cometary +comets +comfort +comfortabilities +comfortability +comfortable +comfortably +comforted +comforter +comforters +comforting +comfortingly +comforts +comic +comical +comically +comics +Cominform +coming +comings +comma +command +commandant +commandants +commanded +commandeer +commander +commanders +commanding +commandingly +commandment +commandments +commando +commands +commas +commemorate +commemorated +commemorates +commemorating +commemoration +commemorative +commence +commenced +commencement +commencements +commences +commencing +commend +commendation +commendations +commended +commending +commends +commensurate +comment +commentaries +commentary +commentator +commentators +commented +commenting +comments +commerce +commercial +commercially +commercialness +commercials +commission +commissioned +commissioner +commissioners +commissioning +commissions +commit +commitment +commitments +commits +committed +committee +committeeman +committeemen +committees +committeewoman +committeewomen +committing +commodities +commodity +commodore +commodores +common +commonalities +commonality +commoner +commoners +commonest +commonly +commonness +commonplace +commonplaces +commons +commonwealth +commonwealths +commotion +communal +communally +commune +communes +communicant +communicants +communicate +communicated +communicates +communicating +communication +communications +communicative +communicator +communicators +communion +communist +communists +communities +community +commutative +commutativity +commute +commuted +commuter +commuters +commutes +commuting +compact +compacted +compacter +compactest +compacting +compaction +compactly +compactness +compactor +compactors +compacts +companies +companion +companionable +companions +companionship +company +comparability +comparable +comparably +comparative +comparatively +comparatives +comparator +comparators +compare +compared +compares +comparing +comparison +comparisons +compartment +compartmentalize +compartmentalized +compartmentalizes +compartmentalizing +compartmented +compartments +compass +compassion +compassionate +compassionately +compatibilities +compatibility +compatible +compatibles +compatibly +compel +compelled +compelling +compellingly +compels +compendium +compensate +compensated +compensates +compensating +compensation +compensations +compensatory +compete +competed +competence +competency +competent +competently +competes +competing +competition +competitions +competitive +competitively +competitor +competitors +compilation +compilations +compile +compiled +compiler +compilers +compiles +compiling +complacency +complain +complained +complainer +complainers +complaining +complains +complaint +complaints +complement +complementary +complemented +complementer +complementers +complementing +complements +complete +completed +completely +completeness +completes +completing +completion +completions +complex +complexes +complexion +complexities +complexity +complexly +compliance +compliant +complicate +complicated +complicates +complicating +complication +complications +complicator +complicators +complicity +complied +compliment +complimentary +complimented +complimenter +complimenters +complimenting +compliments +comply +complying +component +componentry +components +componentwise +compose +composed +composedly +composer +composers +composes +composing +composite +composites +composition +compositional +compositions +compost +composure +compound +compounded +compounding +compounds +comprehend +comprehended +comprehending +comprehends +comprehensibility +comprehensible +comprehension +comprehensive +comprehensively +compress +compressed +compresses +compressible +compressing +compression +compressive +compressor +comprise +comprised +comprises +comprising +compromise +compromised +compromiser +compromisers +compromises +compromising +compromisingly +Compton +comptroller +comptrollers +compulsion +compulsions +compulsive +compulsory +compunction +Compuserve +computability +computable +computation +computational +computationally +computations +compute +computed +computer +computerize +computerized +computerizes +computerizing +computers +computes +computing +comrade +comradely +comrades +comradeship +con +Conakry +Conant +concatenate +concatenated +concatenates +concatenating +concatenation +concatenations +concave +conceal +concealed +concealer +concealers +concealing +concealment +conceals +concede +conceded +concedes +conceding +conceit +conceited +conceits +conceivable +conceivably +conceive +conceived +conceives +conceiving +concentrate +concentrated +concentrates +concentrating +concentration +concentrations +concentrator +concentrators +concentric +concept +conception +conceptions +concepts +conceptual +conceptualization +conceptualizations +conceptualize +conceptualized +conceptualizes +conceptualizing +conceptually +concern +concerned +concernedly +concerning +concerns +concert +concerted +concertmaster +concerto +concerts +concession +concessions +conciliate +conciliatory +concise +concisely +conciseness +conclave +conclude +concluded +concludes +concluding +conclusion +conclusions +conclusive +conclusively +concoct +concomitant +concord +concordant +Concorde +Concordia +concourse +concrete +concretely +concreteness +concretes +concretion +concubine +concur +concurred +concurrence +concurrencies +concurrency +concurrent +concurrently +concurring +concurs +concussion +condemn +condemnation +condemnations +condemned +condemner +condemners +condemning +condemns +condensation +condense +condensed +condenser +condenses +condensing +condescend +condescending +condition +conditional +conditionally +conditionals +conditioned +conditioner +conditioners +conditioning +conditions +condom +condone +condoned +condones +condoning +conduce +conducive +conduciveness +conduct +conductance +conducted +conducting +conduction +conductive +conductivity +conductor +conductors +conducts +conduit +cone +cones +Conestoga +confectionery +confederacy +confederate +confederates +confederation +confederations +confer +conferee +conference +conferences +conferred +conferrer +conferrers +conferring +confers +confess +confessed +confesses +confessing +confession +confessions +confessor +confessors +confidant +confidants +confide +confided +confidence +confidences +confident +confidential +confidentiality +confidentially +confidently +confides +confiding +confidingly +configurable +configuration +configurations +configure +configured +configures +configuring +confine +confined +confinement +confinements +confiner +confines +confining +confirm +confirmation +confirmations +confirmatory +confirmed +confirming +confirms +confiscate +confiscated +confiscates +confiscating +confiscation +confiscations +conflagration +conflict +conflicted +conflicting +conflicts +confluent +confocal +conform +conformal +conformance +conformed +conforming +conformity +conforms +confound +confounded +confounding +confounds +confront +confrontation +confrontations +confronted +confronter +confronters +confronting +confronts +Confucian +Confucianism +Confucius +confuse +confused +confuser +confusers +confuses +confusing +confusingly +confusion +confusions +congenial +congenially +congenital +congest +congested +congestion +congestive +conglomerate +Congo +Congolese +congratulate +congratulated +congratulation +congratulations +congratulatory +congregate +congregated +congregates +congregating +congregation +congregations +congress +congresses +congressional +congressionally +congressman +congressmen +congresswoman +congresswomen +congruence +congruent +conic +conifer +coniferous +conjecture +conjectured +conjectures +conjecturing +conjoined +conjugal +conjugate +conjunct +conjuncted +conjunction +conjunctions +conjunctive +conjunctively +conjuncts +conjuncture +conjure +conjured +conjurer +conjures +conjuring +Conklin +Conley +Connally +connect +connected +connectedness +Connecticut +connecting +connection +connectionless +connections +connective +connectives +connectivity +connector +connectors +connects +Connelly +Conner +Connie +connivance +connive +connoisseur +connoisseurs +Connors +connotation +connotative +connote +connoted +connotes +connoting +connubial +conquer +conquerable +conquered +conquerer +conquerers +conquering +conqueror +conquerors +conquers +conquest +conquests +Conrad +Conrail +conscience +consciences +conscientious +conscientiously +conscious +consciously +consciousness +conscript +conscription +consecrate +consecration +consecutive +consecutively +consensual +consensus +consent +consented +consenter +consenters +consenting +consents +consequence +consequences +consequent +consequential +consequentialities +consequentiality +consequently +consequents +conservation +conservationist +conservationists +conservations +conservatism +conservative +conservatively +conservatives +conservator +conserve +conserved +conserves +conserving +consider +considerable +considerably +considerate +considerately +consideration +considerations +considered +considering +considers +consign +consigned +consigning +consigns +consist +consisted +consistency +consistent +consistently +consisting +consists +consolable +consolation +consolations +console +consoled +consoler +consolers +consoles +consolidate +consolidated +consolidates +consolidating +consolidation +consoling +consolingly +consonant +consonants +consort +consorted +consorting +consortium +consorts +conspicuous +conspicuously +conspiracies +conspiracy +conspirator +conspirators +conspire +conspired +conspires +conspiring +constable +constables +Constance +constancy +constant +Constantine +Constantinople +constantly +constants +constellation +constellations +consternation +constituencies +constituency +constituent +constituents +constitute +constituted +constitutes +constituting +constitution +constitutional +constitutionality +constitutionally +constitutions +constitutive +constrain +constrained +constraining +constrains +constraint +constraints +constrict +construct +constructed +constructibility +constructible +constructing +construction +constructions +constructive +constructively +constructor +constructors +constructs +construe +construed +construing +consul +consular +consulate +consulates +consuls +consult +consultant +consultants +consultation +consultations +consultative +consulted +consulting +consults +consumable +consume +consumed +consumer +consumers +consumes +consuming +consummate +consummated +consummately +consummation +consumption +consumptions +consumptive +consumptively +contact +contacted +contacting +contacts +contagion +contagious +contagiously +contain +containable +contained +container +containers +containing +containment +containments +contains +contaminate +contaminated +contaminates +contaminating +contamination +contemplate +contemplated +contemplates +contemplating +contemplation +contemplations +contemplative +contemporaries +contemporariness +contemporary +contempt +contemptible +contemptuous +contemptuously +contend +contended +contender +contenders +contending +contends +content +contented +contenting +contention +contentions +contently +contentment +contents +contest +contestable +contestant +contested +contester +contesters +contesting +contests +context +contexts +contextual +contextually +contiguity +contiguous +contiguously +continent +continental +continentally +continents +contingencies +contingency +contingent +contingents +continual +continually +continuance +continuances +continuation +continuations +continue +continued +continues +continuing +continuities +continuity +continuous +continuously +continuum +contortions +contour +contoured +contouring +contours +contraband +contraception +contraceptive +contract +contracted +contracting +contraction +contractions +contractor +contractors +contracts +contractual +contractually +contradict +contradicted +contradicting +contradiction +contradictions +contradictory +contradicts +contradistinction +contradistinctions +contrapositive +contrapositives +contraption +contraptions +contrariness +contrary +contrast +contrasted +contraster +contrasters +contrasting +contrastingly +contrasts +contribute +contributed +contributes +contributing +contribution +contributions +contributor +contributorily +contributors +contributory +contrite +contrition +contrivance +contrivances +contrive +contrived +contriver +contrives +contriving +control +controllability +controllable +controllably +controlled +controller +controllers +controlling +controls +controversial +controversies +controversy +controvertible +contumacious +contumacy +conundrum +conundrums +Convair +convalescent +convect +convene +convened +convenes +convenience +conveniences +convenient +conveniently +convening +convent +convention +conventional +conventionally +conventions +convents +converge +converged +convergence +convergent +converges +converging +conversant +conversantly +conversation +conversational +conversationally +conversations +converse +conversed +conversely +converses +conversing +conversion +conversions +convert +converted +converter +converters +convertibility +convertible +converting +converts +convex +convey +conveyance +conveyances +conveyed +conveyer +conveyers +conveying +conveyor +conveys +convict +convicted +convicting +conviction +convictions +convicts +convince +convinced +convincer +convincers +convinces +convincing +convincingly +convivial +convoke +convoluted +convolution +convoy +convoyed +convoying +convoys +convulse +convulsion +convulsions +Conway +coo +cooing +cook +cookbook +Cooke +cooked +cookery +cookie +cookies +cooking +cooks +cooky +cool +cooled +cooler +coolers +coolest +Cooley +Coolidge +coolie +coolies +cooling +coolly +coolness +cools +coon +coons +coop +cooped +cooper +cooperate +cooperated +cooperates +cooperating +cooperation +cooperations +cooperative +cooperatively +cooperatives +cooperator +cooperators +coopers +coops +coordinate +coordinated +coordinates +coordinating +coordination +coordinations +coordinator +coordinators +Coors +cop +cope +coped +Copeland +Copenhagen +Copernican +Copernicus +copes +copied +copier +copiers +copies +coping +copings +copious +copiously +copiousness +coplanar +copper +Copperfield +copperhead +coppers +copra +coprocessor +cops +copse +copy +copying +copyright +copyrightable +copyrighted +copyrights +copywriter +coquette +coral +Corbett +Corcoran +cord +corded +corder +cordial +cordiality +cordially +cords +core +cored +corer +corers +cores +Corey +coriander +coring +Corinth +Corinthian +Corinthianize +Corinthianizes +Corinthians +Coriolanus +cork +corked +corker +corkers +corking +corks +corkscrew +cormorant +corn +cornea +Cornelia +Cornelian +Cornelius +Cornell +corner +cornered +corners +cornerstone +cornerstones +cornet +cornfield +cornfields +corning +Cornish +cornmeal +corns +cornstarch +cornucopia +Cornwall +Cornwallis +corny +corollaries +corollary +Coronado +coronaries +coronary +coronation +coroner +coronet +coronets +coroutine +coroutines +corporal +corporals +corporate +corporately +corporation +corporations +corps +corpse +corpses +corpulent +corpus +corpuscular +corral +correct +correctable +corrected +correcting +correction +corrections +corrective +correctively +correctives +correctly +correctness +corrector +corrects +correlate +correlated +correlates +correlating +correlation +correlations +correlative +correspond +corresponded +correspondence +correspondences +correspondent +correspondents +corresponding +correspondingly +corresponds +corridor +corridors +corrigenda +corrigendum +corrigible +corroborate +corroborated +corroborates +corroborating +corroboration +corroborations +corroborative +corrode +corrosion +corrosive +corrugate +corrupt +corrupted +corrupter +corruptible +corrupting +corruption +corruptions +corrupts +corset +Corsica +Corsican +cortex +Cortez +cortical +Cortland +Corvallis +Corvus +Corydoras +Cosgrove +cosine +cosines +cosmetic +cosmetics +cosmic +cosmology +cosmopolitan +cosmos +cosponsor +Cossack +cost +Costa +costed +Costello +costing +costly +costs +costume +costumed +costumer +costumes +costuming +cosy +cot +cotangent +cotillion +cots +cottage +cottager +cottages +cotton +cottonmouth +cottons +cottonseed +cottonwood +Cottrell +cotyledon +cotyledons +couch +couched +couches +couching +cougar +cough +coughed +coughing +coughs +could +coulomb +Coulter +council +councillor +councillors +councilman +councilmen +councils +councilwoman +councilwomen +counsel +counseled +counseling +counselled +counselling +counsellor +counsellors +counselor +counselors +counsels +count +countable +countably +counted +countenance +counter +counteract +counteracted +counteracting +counteractive +counterargument +counterattack +counterbalance +counterclockwise +countered +counterexample +counterexamples +counterfeit +counterfeited +counterfeiter +counterfeiting +counterflow +countering +counterintuitive +counterman +countermeasure +countermeasures +countermen +counterpart +counterparts +counterpoint +counterpointing +counterpoise +counterproductive +counterproposal +counterrevolution +counters +countersink +countersunk +countess +counties +counting +countless +countries +country +countryman +countrymen +countryside +countrywide +counts +county +countywide +couple +coupled +coupler +couplers +couples +coupling +couplings +coupon +coupons +courage +courageous +courageously +courier +couriers +course +coursed +courser +courses +coursing +court +courted +courteous +courteously +courter +courters +courtesan +courtesies +courtesy +courthouse +courthouses +courtier +courtiers +courting +courtly +Courtney +courtroom +courtrooms +courts +courtship +courtyard +courtyards +cousin +cousins +covalent +covariant +cove +covenant +covenants +Covent +Coventry +cover +coverable +coverage +covered +covering +coverings +coverlet +coverlets +covers +covert +covertly +coves +covet +coveted +coveting +covetous +covetousness +covets +cow +Cowan +coward +cowardice +cowardly +cowboy +cowboys +cowed +cower +cowered +cowerer +cowerers +cowering +coweringly +cowers +cowherd +cowhide +cowing +cowl +cowlick +cowling +cowls +coworker +cows +cowslip +cowslips +coyote +coyotes +coypu +cozier +coziness +cozy +crab +crabapple +crabs +crack +cracked +cracker +crackers +cracking +crackle +crackled +crackles +crackling +crackpot +cracks +cradle +cradled +cradles +craft +crafted +crafter +craftiness +crafting +crafts +craftsman +craftsmen +craftspeople +craftsperson +crafty +crag +craggy +crags +Craig +cram +Cramer +cramming +cramp +cramps +crams +cranberries +cranberry +Crandall +crane +cranes +Cranford +crania +cranium +crank +crankcase +cranked +crankier +crankiest +crankily +cranking +cranks +crankshaft +cranky +cranny +Cranston +crash +crashed +crasher +crashers +crashes +crashing +crass +crate +crater +craters +crates +cravat +cravats +crave +craved +craven +craves +craving +Crawford +crawl +crawled +crawler +crawlers +crawling +crawls +Cray +crayon +Crays +craze +crazed +crazes +crazier +craziest +crazily +craziness +crazing +crazy +creak +creaked +creaking +creaks +creaky +cream +creamed +creamer +creamers +creamery +creaming +creams +creamy +crease +creased +creases +creasing +create +created +creates +creating +creation +creations +creative +creatively +creativeness +creativity +creator +creators +creature +creatures +credence +credential +credibility +credible +credibly +credit +creditable +creditably +credited +crediting +creditor +creditors +credits +credulity +credulous +credulousness +Cree +creed +creeds +creek +creeks +creep +creeper +creepers +creeping +creeps +creepy +Creighton +cremate +cremated +cremates +cremating +cremation +cremations +crematory +Creole +Creon +crepe +crept +crescent +crescents +crest +crested +crestfallen +crests +Crestview +Cretaceous +Cretaceously +Cretan +Crete +cretin +crevice +crevices +crew +crewcut +crewed +crewing +crews +crib +cribs +cricket +crickets +cried +crier +criers +cries +crime +Crimea +Crimean +crimes +criminal +criminally +criminals +criminate +crimson +crimsoning +cringe +cringed +cringes +cringing +cripple +crippled +cripples +crippling +crises +crisis +crisp +Crispin +crisply +crispness +crisscross +criteria +criterion +critic +critical +critically +criticism +criticisms +criticize +criticized +criticizes +criticizing +critics +critique +critiques +critiquing +critter +croak +croaked +croaking +croaks +Croatia +Croatian +crochet +crochets +crock +crockery +Crockett +crocks +crocodile +crocus +croft +Croix +Cromwell +Cromwellian +crook +crooked +crooks +crop +cropped +cropper +croppers +cropping +crops +Crosby +cross +crossable +crossbar +crossbars +crossed +crosser +crossers +crosses +crossing +crossings +crossly +crossover +crossovers +crosspoint +crossroad +crosstalk +crosswalk +crossword +crosswords +crotch +crotchety +crouch +crouched +crouching +crow +crowd +crowded +crowder +crowding +crowds +crowed +crowing +Crowley +crown +crowned +crowning +crowns +crows +Croydon +crucial +crucially +crucible +crucified +crucifies +crucifix +crucifixion +crucify +crucifying +crud +cruddy +crude +crudely +crudeness +cruder +crudest +cruel +crueler +cruelest +cruelly +cruelty +Cruickshank +cruise +cruiser +cruisers +cruises +cruising +crumb +crumble +crumbled +crumbles +crumbling +crumbly +crumbs +crummy +crumple +crumpled +crumples +crumpling +crunch +crunched +crunches +crunchier +crunchiest +crunching +crunchy +crusade +crusader +crusaders +crusades +crusading +crush +crushable +crushed +crusher +crushers +crushes +crushing +crushingly +Crusoe +crust +crustacean +crustaceans +crusts +crutch +crutches +crux +cruxes +Cruz +cry +crying +cryogenic +crypt +cryptanalysis +cryptanalyst +cryptanalytic +cryptic +cryptogram +cryptographer +cryptographic +cryptographically +cryptography +cryptologist +cryptology +crystal +crystalline +crystallize +crystallized +crystallizes +crystallizing +crystals +cub +Cuba +Cuban +Cubanize +Cubanizes +Cubans +cubbyhole +cube +cubed +cubes +cubic +cubs +cuckoo +cuckoos +cucumber +cucumbers +cuddle +cuddled +cuddly +cudgel +cudgels +cue +cued +cues +cuff +cufflink +cuffs +cuisine +Culbertson +culinary +cull +culled +culler +culling +culls +culminate +culminated +culminates +culminating +culmination +culpa +culpable +culprit +culprits +cult +cultivable +cultivate +cultivated +cultivates +cultivating +cultivation +cultivations +cultivator +cultivators +cults +cultural +culturally +culture +cultured +cultures +culturing +Culver +Culvers +Cumberland +cumbersome +Cummings +Cummins +cumulative +cumulatively +Cunard +cunnilingus +cunning +Cunningham +cunningly +cup +cupboard +cupboards +Cupertino +cupful +Cupid +cupped +cupping +cups +curable +curably +curb +curbing +curbs +curd +curdle +cure +cured +cures +curfew +curfews +curing +curiosities +curiosity +curious +curiouser +curiousest +curiously +curl +curled +curler +curlers +curlicue +curling +curls +curly +Curran +currant +currants +currencies +currency +current +currently +currentness +currents +curricular +curriculum +curriculums +curried +curries +curry +currying +curs +curse +cursed +curses +cursing +cursive +cursor +cursorily +cursors +cursory +curt +curtail +curtailed +curtails +curtain +curtained +curtains +curtate +Curtis +curtly +curtness +curtsies +curtsy +curvaceous +curvature +curve +curved +curves +curvilinear +curving +Cushing +cushion +cushioned +cushioning +cushions +Cushman +cusp +cusps +custard +Custer +custodial +custodian +custodians +custody +custom +customarily +customary +customer +customers +customizable +customization +customizations +customize +customized +customizer +customizers +customizes +customizing +customs +cut +cutaneous +cutback +cute +cutest +cutlass +cutlet +cutoff +cutout +cutover +cuts +cutter +cutters +cutthroat +cutting +cuttingly +cuttings +cuttlefish +Cuvier +Cuzco +Cyanamid +cyanide +cybernetic +cybernetics +cyberspace +Cyclades +cycle +cycled +cycles +cyclic +cyclically +cycling +cycloid +cycloidal +cycloids +cyclone +cyclones +Cyclops +cyclotron +cyclotrons +Cygnus +cylinder +cylinders +cylindrical +cymbal +cymbals +cynic +cynical +cynically +Cynthia +cypress +Cyprian +Cypriot +Cyprus +Cyril +Cyrillic +Cyrus +cyst +cysts +cytology +cytoplasm +czar +Czech +Czechization +Czechizations +Czechoslovakia +Czerniak +dabble +dabbled +dabbler +dabbles +dabbling +Dacca +Dacron +dactyl +dactylic +dad +Dada +Dadaism +Dadaist +Dadaistic +daddy +Dade +dads +Daedalus +daemon +daemons +daffodil +daffodils +dagger +Dahl +dahlia +Dahomey +Dailey +dailies +daily +Daimler +daintily +daintiness +dainty +dairy +Dairylea +daisies +daisy +Dakar +Dakota +dale +dales +Daley +Dalhousie +Dali +Dallas +Dalton +Daly +Dalzell +dam +damage +damaged +damager +damagers +damages +damaging +Damascus +damask +dame +damming +damn +damnation +damned +damning +damns +Damocles +Damon +damp +dampen +dampens +damper +damping +dampness +dams +damsel +damsels +Dan +Dana +Danbury +dance +danced +dancer +dancers +dances +dancing +dandelion +dandelions +dandy +Dane +Danes +danger +dangerous +dangerously +dangers +dangle +dangled +dangles +dangling +Daniel +Daniels +Danielson +Danish +Danization +Danizations +Danize +Danizes +Danny +Dante +Danube +Danubian +Danville +Danzig +Daphne +Dar +dare +dared +darer +darers +dares +daresay +daring +daringly +Darius +dark +darken +darker +darkest +darkly +darkness +darkroom +Darlene +darling +darlings +Darlington +darn +darned +darner +darning +darns +DARPA +Darrell +Darrow +Darry +dart +darted +darter +darting +Dartmouth +darts +Darwin +Darwinian +Darwinism +Darwinistic +Darwinize +Darwinizes +dash +dashboard +dashed +dasher +dashers +dashes +dashing +dashingly +data +database +databases +datagram +datagrams +Datamation +Datamedia +date +dated +dateline +dater +dates +dating +dative +Datsun +datum +Daugherty +daughter +daughterly +daughters +daunt +daunted +dauntless +Dave +David +Davidson +Davie +Davies +Davinich +Davis +Davison +Davy +dawn +dawned +dawning +dawns +Dawson +day +daybreak +daydream +daydreaming +daydreams +daylight +daylights +days +daytime +Dayton +Daytona +daze +dazed +dazzle +dazzled +dazzler +dazzles +dazzling +dazzlingly +De +deacon +deacons +deactivate +dead +deaden +deadline +deadlines +deadlock +deadlocked +deadlocking +deadlocks +deadly +deadness +deadwood +deaf +deafen +deafer +deafest +deafness +deal +dealer +dealers +dealership +dealing +dealings +deallocate +deallocated +deallocating +deallocation +deallocations +deals +dealt +dean +Deane +Deanna +deans +dear +Dearborn +dearer +dearest +dearly +dearness +dearth +dearths +death +deathbed +deathly +deaths +debacle +debar +debase +debatable +debate +debated +debater +debaters +debates +debating +debauch +debauchery +Debbie +Debby +debilitate +debilitated +debilitates +debilitating +debility +debit +debited +Deborah +Debra +debrief +debris +debt +debtor +debts +debug +debugged +debugger +debuggers +debugging +debugs +debunk +Debussy +debutante +DEC +decade +decadence +decadent +decadently +decades +decal +decathlon +Decatur +decay +decayed +decaying +decays +Decca +decease +deceased +deceases +deceasing +decedent +deceit +deceitful +deceitfully +deceitfulness +deceive +deceived +deceiver +deceivers +deceives +deceiving +decelerate +decelerated +decelerates +decelerating +deceleration +December +Decembers +decencies +decency +decennial +decent +decently +decentralization +decentralized +deception +deceptions +deceptive +deceptively +decertify +decibel +decidability +decidable +decide +decided +decidedly +decides +deciding +deciduous +decimal +decimals +decimate +decimated +decimates +decimating +decimation +decipher +deciphered +decipherer +deciphering +deciphers +decision +decisions +decisive +decisively +decisiveness +deck +decked +Decker +decking +deckings +decks +declaration +declarations +declarative +declaratively +declaratives +declarator +declaratory +declare +declared +declarer +declarers +declares +declaring +declassify +declination +declinations +decline +declined +decliner +decliners +declines +declining +DECnet +decode +decoded +decoder +decoders +decodes +decoding +decodings +decolletage +decollimate +decompile +decomposability +decomposable +decompose +decomposed +decomposes +decomposing +decomposition +decompositions +decompress +decompression +decorate +decorated +decorates +decorating +decoration +decorations +decorative +decorum +decouple +decoupled +decouples +decoupling +decoy +decoys +decrease +decreased +decreases +decreasing +decreasingly +decree +decreed +decreeing +decrees +decrement +decremented +decrementing +decrements +decrypt +decrypted +decrypting +decryption +decrypts +DECstation +DECsystem +DECtape +dedicate +dedicated +dedicates +dedicating +dedication +deduce +deduced +deducer +deduces +deducible +deducing +deduct +deducted +deductible +deducting +deduction +deductions +deductive +Dee +deed +deeded +deeding +deeds +deem +deemed +deeming +deemphasize +deemphasized +deemphasizes +deemphasizing +deems +deep +deepen +deepened +deepening +deepens +deeper +deepest +deeply +deeps +deer +Deere +deface +default +defaulted +defaulter +defaulting +defaults +defeat +defeated +defeating +defeats +defecate +defect +defected +defecting +defection +defections +defective +defects +defend +defendant +defendants +defended +defender +defenders +defending +defends +defenestrate +defenestrated +defenestrates +defenestrating +defenestration +defense +defenseless +defenses +defensible +defensive +defer +deference +deferment +deferments +deferrable +deferred +deferrer +deferrers +deferring +defers +defiance +defiant +defiantly +deficiencies +deficiency +deficient +deficit +deficits +defied +defies +defile +defiling +definable +define +defined +definer +defines +defining +definite +definitely +definiteness +definition +definitional +definitions +definitive +deflate +deflater +deflect +defocus +Defoe +deforest +deforestation +deform +deformation +deformations +deformed +deformities +deformity +defraud +defray +defrost +deftly +defunct +defy +defying +degeneracy +degenerate +degenerated +degenerates +degenerating +degeneration +degenerative +degradable +degradation +degradations +degrade +degraded +degrades +degrading +degree +degrees +dehumidify +dehydrate +deify +deign +deigned +deigning +deigns +Deimos +Deirdre +Deirdres +deities +deity +dejected +dejectedly +DeKalb +DeKastere +Del +Delaney +Delano +Delaware +delay +delayed +delaying +delays +delegate +delegated +delegates +delegating +delegation +delegations +delete +deleted +deleter +deleterious +deletes +deleting +deletion +deletions +Delft +Delhi +Delia +deliberate +deliberated +deliberately +deliberateness +deliberates +deliberating +deliberation +deliberations +deliberative +deliberator +deliberators +delicacies +delicacy +delicate +delicately +delicatessen +delicious +deliciously +delight +delighted +delightedly +delightful +delightfully +delighting +delights +Delilah +delimit +delimitation +delimited +delimiter +delimiters +delimiting +delimits +delineament +delineate +delineated +delineates +delineating +delineation +delinquency +delinquent +delirious +deliriously +delirium +deliver +deliverable +deliverables +deliverance +delivered +deliverer +deliverers +deliveries +delivering +delivers +delivery +dell +Della +dells +Dellwood +Delmarva +Delphi +Delphic +Delphically +Delphinus +delta +deltas +delude +deluded +deludes +deluding +deluge +deluged +deluges +delusion +delusions +deluxe +delve +delves +delving +demagnify +demagogue +demand +demanded +demander +demanding +demandingly +demands +demarcate +demeanor +demented +demerit +Demeter +demigod +demise +demo +democracies +democracy +democrat +democratic +democratically +democrats +demodulate +demodulator +demographic +demolish +demolished +demolishes +demolition +demon +demoniac +demonic +demons +demonstrable +demonstrate +demonstrated +demonstrates +demonstrating +demonstration +demonstrations +demonstrative +demonstratively +demonstrator +demonstrators +demoralize +demoralized +demoralizes +demoralizing +DeMorgan +demote +demountable +Dempsey +demultiplex +demultiplexed +demultiplexer +demultiplexers +demultiplexing +demur +demythologize +den +denature +Deneb +Denebola +Deneen +deniable +denial +denials +denied +denier +denies +denigrate +denigrated +denigrates +denigrating +denizen +Denmark +Dennis +Denny +denominate +denomination +denominations +denominator +denominators +denotable +denotation +denotational +denotationally +denotations +denotative +denote +denoted +denotes +denoting +denounce +denounced +denounces +denouncing +dens +dense +densely +denseness +denser +densest +densities +density +dent +dental +dentally +dented +denting +dentist +dentistry +dentists +Denton +dents +denture +denude +denumerable +denunciate +denunciation +Denver +deny +denying +deodorant +deoxyribonucleic +depart +departed +departing +department +departmental +departments +departs +departure +departures +depend +dependability +dependable +dependably +depended +dependence +dependencies +dependency +dependent +dependently +dependents +depending +depends +depict +depicted +depicting +depicts +deplete +depleted +depletes +depleting +depletion +depletions +deplorable +deplore +deplored +deplores +deploring +deploy +deployed +deploying +deployment +deployments +deploys +deport +deportation +deportee +deportment +depose +deposed +deposes +deposit +depositary +deposited +depositing +deposition +depositions +depositor +depositors +depository +deposits +depot +depots +deprave +depraved +depravity +deprecate +depreciate +depreciated +depreciates +depreciation +depress +depressed +depresses +depressing +depression +depressions +deprivation +deprivations +deprive +deprived +deprives +depriving +depth +depths +deputies +deputy +dequeue +dequeued +dequeues +dequeuing +derail +derailed +derailing +derails +derby +Derbyshire +dereference +deregulate +deregulated +Derek +deride +derision +derivable +derivation +derivations +derivative +derivatives +derive +derived +derives +deriving +derogatory +derrick +derriere +dervish +Des +Descartes +descend +descendant +descendants +descended +descendent +descender +descenders +descending +descends +descent +descents +describable +describe +described +describer +describes +describing +description +descriptions +descriptive +descriptively +descriptives +descriptor +descriptors +descry +desecrate +desegregate +desert +deserted +deserter +deserters +deserting +desertion +desertions +deserts +deserve +deserved +deserves +deserving +deservingly +deservings +desiderata +desideratum +design +designate +designated +designates +designating +designation +designations +designator +designators +designed +designer +designers +designing +designs +desirability +desirable +desirably +desire +desired +desires +desiring +desirous +desist +desk +desks +desktop +Desmond +desolate +desolately +desolation +desolations +despair +despaired +despairing +despairingly +despairs +despatch +despatched +desperado +desperate +desperately +desperation +despicable +despise +despised +despises +despising +despite +despoil +despondent +despot +despotic +despotism +despots +dessert +desserts +desiccate +destabilize +destination +destinations +destine +destined +destinies +destiny +destitute +destitution +destroy +destroyed +destroyer +destroyers +destroying +destroys +destruct +destruction +destructions +destructive +destructively +destructiveness +destructor +destuff +destuffing +destuffs +desuetude +desultory +desynchronize +detach +detached +detacher +detaches +detaching +detachment +detachments +detail +detailed +detailing +details +detain +detained +detaining +detains +detect +detectable +detectably +detected +detecting +detection +detections +detective +detectives +detector +detectors +detects +detente +detention +deter +detergent +deteriorate +deteriorated +deteriorates +deteriorating +deterioration +determinable +determinacy +determinant +determinants +determinate +determinately +determination +determinations +determinative +determine +determined +determiner +determiners +determines +determining +determinism +deterministic +deterministically +deterred +deterrent +deterring +detest +detestable +detested +detour +detract +detractor +detractors +detracts +detriment +detrimental +Detroit +deuce +deus +deuterium +Deutsch +devastate +devastated +devastates +devastating +devastation +develop +developed +developer +developers +developing +development +developmental +developments +develops +deviant +deviants +deviate +deviated +deviates +deviating +deviation +deviations +device +devices +devil +devilish +devilishly +devils +devious +devise +devised +devises +devising +devisings +devoid +devolve +Devon +Devonshire +devote +devoted +devotedly +devotee +devotees +devotes +devoting +devotion +devotions +devour +devoured +devourer +devours +devout +devoutly +devoutness +dew +dewdrop +dewdrops +Dewey +Dewitt +dewy +Dexedrine +dexterity +Dhabi +diabetes +diabetic +diabolic +diachronic +diacritical +diadem +diagnosable +diagnose +diagnosed +diagnoses +diagnosing +diagnosis +diagnostic +diagnostician +diagnostics +diagonal +diagonally +diagonals +diagram +diagrammable +diagrammatic +diagrammatically +diagrammed +diagrammer +diagrammers +diagramming +diagrams +dial +dialect +dialectic +dialects +dialed +dialer +dialers +dialing +dialog +dialogs +dialogue +dialogues +dials +dialup +dialysis +diamagnetic +diameter +diameters +diametric +diametrically +diamond +diamonds +Diana +Diane +Dianne +diaper +diapers +diaphragm +diaphragms +diaries +diarrhea +diary +diatribe +diatribes +dibble +dice +dichotomize +dichotomy +dickens +Dickerson +Dickinson +Dickson +dicky +dictate +dictated +dictates +dictating +dictation +dictations +dictator +dictatorial +dictators +dictatorship +diction +dictionaries +dictionary +dictum +dictums +did +didactic +diddle +Dido +die +Diebold +died +Diego +diehard +dielectric +dielectrics +diem +dies +diesel +diet +dietary +dieter +dieters +dietetic +dietician +dietitian +dietitians +Dietrich +diets +Dietz +differ +differed +difference +differences +different +differentiable +differential +differentials +differentiate +differentiated +differentiates +differentiating +differentiation +differentiations +differentiators +differently +differer +differers +differing +differs +difficult +difficulties +difficultly +difficulty +diffract +diffuse +diffused +diffusely +diffuser +diffusers +diffuses +diffusible +diffusing +diffusion +diffusions +diffusive +dig +digest +digested +digestible +digesting +digestion +digestive +digests +digger +diggers +digging +diggings +digit +digital +digitalis +digitally +digitization +digitize +digitized +digitizes +digitizing +digits +dignified +dignify +dignitary +dignities +dignity +digram +digress +digressed +digresses +digressing +digression +digressions +digressive +digs +dihedral +Dijkstra +Dijon +dike +dikes +dilapidate +dilatation +dilate +dilated +dilates +dilating +dilation +dildo +dilemma +dilemmas +diligence +diligent +diligently +dill +Dillon +dilogarithm +dilute +diluted +dilutes +diluting +dilution +dim +DiMaggio +dime +dimension +dimensional +dimensionality +dimensionally +dimensioned +dimensioning +dimensions +dimes +diminish +diminished +diminishes +diminishing +diminution +diminutive +dimly +dimmed +dimmer +dimmers +dimmest +dimming +dimness +dimple +dims +din +Dinah +dine +dined +diner +diners +dines +ding +dinghy +dinginess +dingo +dingy +dining +dinner +dinners +dinnertime +dinnerware +dinosaur +dint +Diocletian +diode +diodes +Diogenes +Dion +Dionysian +Dionysus +Diophantine +diopter +diorama +dioxide +dip +diphtheria +diphthong +diploma +diplomacy +diplomas +diplomat +diplomatic +diplomats +dipole +dipped +dipper +dippers +dipping +dippings +dips +Dirac +dire +direct +directed +directing +direction +directional +directionality +directionally +directions +directive +directives +directly +directness +director +directorate +directories +directors +directory +directrices +directrix +directs +dirge +dirges +Dirichlet +dirt +dirtier +dirtiest +dirtily +dirtiness +dirts +dirty +Dis +disabilities +disability +disable +disabled +disabler +disablers +disables +disabling +disadvantage +disadvantageous +disadvantages +disaffected +disaffection +disagree +disagreeable +disagreed +disagreeing +disagreement +disagreements +disagrees +disallow +disallowed +disallowing +disallows +disambiguate +disambiguated +disambiguates +disambiguating +disambiguation +disambiguations +disappear +disappearance +disappearances +disappeared +disappearing +disappears +disappoint +disappointed +disappointing +disappointment +disappointments +disapproval +disapprove +disapproved +disapproves +disarm +disarmament +disarmed +disarming +disarms +disassemble +disassembled +disassembles +disassembling +disassembly +disaster +disasters +disastrous +disastrously +disband +disbanded +disbanding +disbands +disburse +disbursed +disbursement +disbursements +disburses +disbursing +disc +discard +discarded +discarding +discards +discern +discerned +discernibility +discernible +discernibly +discerning +discerningly +discernment +discerns +discharge +discharged +discharges +discharging +disciple +disciples +disciplinary +discipline +disciplined +disciplines +disciplining +disclaim +disclaimed +disclaimer +disclaims +disclose +disclosed +discloses +disclosing +disclosure +disclosures +discomfort +disconcert +disconcerting +disconcertingly +disconnect +disconnected +disconnecting +disconnection +disconnects +discontent +discontented +discontinuance +discontinue +discontinued +discontinues +discontinuities +discontinuity +discontinuous +discord +discordant +discount +discounted +discounting +discounts +discourage +discouraged +discouragement +discourages +discouraging +discourse +discourses +discover +discovered +discoverer +discoverers +discoveries +discovering +discovers +discovery +discredit +discredited +discreet +discreetly +discrepancies +discrepancy +discrete +discretely +discreteness +discretion +discretionary +discriminant +discriminate +discriminated +discriminates +discriminating +discrimination +discriminatory +discs +discuss +discussant +discussed +discusses +discussing +discussion +discussions +disdain +disdaining +disdains +disease +diseased +diseases +disembowel +disengage +disengaged +disengages +disengaging +disentangle +disentangling +disfigure +disfigured +disfigures +disfiguring +disgorge +disgrace +disgraced +disgraceful +disgracefully +disgraces +disgruntle +disgruntled +disguise +disguised +disguises +disgust +disgusted +disgustedly +disgustful +disgusting +disgustingly +disgusts +dish +dishearten +disheartening +dished +dishes +dishevel +dishing +dishonest +dishonestly +dishonesty +dishonor +dishonorable +dishonored +dishonoring +dishonors +dishwasher +dishwashers +dishwashing +dishwater +disillusion +disillusioned +disillusioning +disillusionment +disillusionments +disinclined +disingenuous +disinterested +disinterestedness +disjoint +disjointed +disjointly +disjointness +disjunct +disjunction +disjunctions +disjunctive +disjunctively +disjuncts +disk +diskette +diskettes +disks +dislike +disliked +dislikes +disliking +dislocate +dislocated +dislocates +dislocating +dislocation +dislocations +dislodge +dislodged +dismal +dismally +dismay +dismayed +dismaying +dismember +dismembered +dismemberment +dismembers +dismiss +dismissal +dismissals +dismissed +dismisser +dismissers +dismisses +dismissing +dismount +dismounted +dismounting +dismounts +Disney +Disneyland +disobedience +disobedient +disobey +disobeyed +disobeying +disobeys +disorder +disordered +disorderly +disorders +disorganized +disown +disowned +disowning +disowns +disparage +disparate +disparities +disparity +dispassionate +dispatch +dispatched +dispatcher +dispatchers +dispatches +dispatching +dispel +dispell +dispelled +dispelling +dispels +dispensary +dispensation +dispense +dispensed +dispenser +dispensers +dispenses +dispensing +dispersal +disperse +dispersed +disperses +dispersing +dispersion +dispersions +displace +displaced +displacement +displacements +displaces +displacing +display +displayable +displayed +displayer +displaying +displays +displease +displeased +displeases +displeasing +displeasure +disposable +disposal +disposals +dispose +disposed +disposer +disposes +disposing +disposition +dispositions +dispossessed +disproportionate +disprove +disproved +disproves +disproving +dispute +disputed +disputer +disputers +disputes +disputing +disqualification +disqualified +disqualifies +disqualify +disqualifying +disquiet +disquieting +Disraeli +disregard +disregarded +disregarding +disregards +disrespectful +disrupt +disrupted +disrupting +disruption +disruptions +disruptive +disrupts +dissatisfaction +dissatisfactions +dissatisfactory +dissatisfied +dissect +dissects +dissemble +disseminate +disseminated +disseminates +disseminating +dissemination +dissension +dissensions +dissent +dissented +dissenter +dissenters +dissenting +dissents +dissertation +dissertations +disservice +dissident +dissidents +dissimilar +dissimilarities +dissimilarity +dissipate +dissipated +dissipates +dissipating +dissipation +dissociate +dissociated +dissociates +dissociating +dissociation +dissolution +dissolutions +dissolve +dissolved +dissolves +dissolving +dissonant +dissuade +distaff +distal +distally +distance +distances +distant +distantly +distaste +distasteful +distastefully +distastes +distemper +distempered +distempers +distill +distillation +distilled +distiller +distillers +distillery +distilling +distills +distinct +distinction +distinctions +distinctive +distinctively +distinctiveness +distinctly +distinctness +distinguish +distinguishable +distinguished +distinguishes +distinguishing +distort +distorted +distorting +distortion +distortions +distorts +distract +distracted +distracting +distraction +distractions +distracts +distraught +distress +distressed +distresses +distressing +distribute +distributed +distributes +distributing +distribution +distributional +distributions +distributive +distributivity +distributor +distributors +district +districts +distrust +distrusted +disturb +disturbance +disturbances +disturbed +disturber +disturbing +disturbingly +disturbs +disuse +ditch +ditches +dither +ditto +ditty +Ditzel +diurnal +divan +divans +dive +dived +diver +diverge +diverged +divergence +divergences +divergent +diverges +diverging +divers +diverse +diversely +diversification +diversified +diversifies +diversify +diversifying +diversion +diversionary +diversions +diversities +diversity +divert +diverted +diverting +diverts +dives +divest +divested +divesting +divestiture +divests +divide +divided +dividend +dividends +divider +dividers +divides +dividing +divine +divinely +diviner +diving +divining +divinities +divinity +divisibility +divisible +division +divisional +divisions +divisive +divisor +divisors +divorce +divorced +divorcee +divulge +divulged +divulges +divulging +Dixie +Dixiecrats +Dixieland +Dixon +dizziness +dizzy +Djakarta +Dmitri +Dnieper +do +Dobbin +Dobbs +Doberman +Doc +docile +dock +docked +docket +docks +dockside +dockyard +doctor +doctoral +doctorate +doctorates +doctored +doctors +doctrinaire +doctrinal +doctrine +doctrines +document +documentaries +documentary +documentation +documentations +documented +documenter +documenters +documenting +documents +Dodd +dodecahedra +dodecahedral +dodecahedron +dodge +dodged +dodger +dodgers +dodging +Dodington +Dodson +doe +doer +doers +does +dog +Doge +dogged +doggedly +doggedness +dogging +doghouse +dogma +dogmas +dogmatic +dogmatism +dogs +Dogtown +Doherty +doing +doings +Dolan +doldrum +dole +doled +doleful +dolefully +doles +doll +dollar +dollars +dollies +dolls +dolly +Dolores +dolphin +dolphins +domain +domains +dome +domed +Domenico +domes +Domesday +domestic +domestically +domesticate +domesticated +domesticates +domesticating +domestication +domicile +dominance +dominant +dominantly +dominate +dominated +dominates +dominating +domination +domineer +domineering +Domingo +Dominic +Dominican +Dominicans +Dominick +dominion +Dominique +domino +don +Donahue +Donald +Donaldson +donate +donated +donates +donating +donation +done +Doneck +donkey +donkeys +Donna +Donnelly +Donner +donnybrook +donor +Donovan +dons +doodle +Dooley +Doolittle +doom +doomed +dooming +dooms +doomsday +door +doorbell +doorkeeper +doorman +doormen +doors +doorstep +doorsteps +doorway +doorways +dope +doped +doper +dopers +dopes +doping +Doppler +Dora +Dorado +Dorcas +Dorchester +Doreen +Doria +Doric +Doricize +Doricizes +Doris +dormant +dormitories +dormitory +Dorothea +Dorothy +Dorset +Dortmund +dosage +dose +dosed +doses +dossier +dossiers +Dostoevsky +dot +dote +doted +dotes +doting +dotingly +dots +dotted +dotting +double +doubled +Doubleday +doubleheader +doubler +doublers +doubles +doublet +doubleton +doublets +doubling +doubloon +doubly +doubt +doubtable +doubted +doubter +doubters +doubtful +doubtfully +doubting +doubtless +doubtlessly +doubts +Doug +dough +Dougherty +doughnut +doughnuts +Douglas +Douglass +dove +dover +doves +dovetail +Dow +dowager +dowel +Dowling +down +downcast +downed +downers +Downey +downfall +downfallen +downgrade +downhill +Downing +downlink +downlinks +download +downloaded +downloading +downloads +downplay +downplayed +downplaying +downplays +downpour +downright +Downs +downside +downstairs +downstream +downtown +downtowns +downtrodden +downturn +downward +downwards +downy +dowry +Doyle +doze +dozed +dozen +dozens +dozenth +dozes +dozing +drab +Draco +Draconian +draft +drafted +draftee +drafter +drafters +drafting +drafts +draftsman +draftsmen +drafty +drag +dragged +dragging +dragnet +dragon +dragonfly +dragonhead +dragons +dragoon +dragooned +dragoons +drags +drain +drainage +drained +drainer +draining +drains +drake +dram +drama +Dramamine +dramas +dramatic +dramatically +dramatics +dramatist +dramatists +drank +drape +draped +draper +draperies +drapers +drapery +drapes +drastic +drastically +draught +draughts +Dravidian +draw +drawback +drawbacks +drawbridge +drawbridges +drawer +drawers +drawing +drawings +drawl +drawled +drawling +drawls +drawn +drawnly +drawnness +draws +dread +dreaded +dreadful +dreadfully +dreading +dreadnought +dreads +dream +dreamboat +dreamed +dreamer +dreamers +dreamily +dreaming +dreamlike +dreams +dreamt +dreamy +dreariness +dreary +dredge +dregs +drench +drenched +drenches +drenching +dress +dressed +dresser +dressers +dresses +dressing +dressings +dressmaker +dressmakers +drew +Drexel +Dreyfuss +dried +drier +driers +dries +driest +drift +drifted +drifter +drifters +drifting +drifts +drill +drilled +driller +drilling +drills +drily +drink +drinkable +drinker +drinkers +drinking +drinks +drip +dripping +drippy +drips +Driscoll +drive +driven +driver +drivers +drives +driveway +driveways +driving +drizzle +drizzly +droll +dromedary +drone +drones +drool +droop +drooped +drooping +droops +droopy +drop +droplet +dropout +dropped +dropper +droppers +dropping +droppings +drops +drosophila +drought +droughts +drove +drover +drovers +droves +drown +drowned +drowning +drownings +drowns +drowsiness +drowsy +drubbing +drudge +drudgery +drug +druggist +druggists +drugs +drugstore +drum +drumhead +drummed +drummer +drummers +drumming +Drummond +drums +drunk +drunkard +drunkards +drunken +drunkenness +drunker +drunkly +drunks +Drury +dry +Dryden +drying +dryly +dual +dualism +dualities +duality +Duane +dub +dubbed +Dubhe +dubious +dubiously +dubiousness +Dublin +dubs +Dubuque +duchess +duchesses +duchy +duck +ducked +ducking +duckling +ducks +duct +ducts +dud +Dudley +due +duel +dueling +duels +dues +duet +Duffy +dug +Dugan +duke +dukes +dull +dulled +duller +Dulles +dullest +dulling +dullness +dulls +dully +Duluth +duly +dumb +dumbbell +dumbbells +dumber +dumbest +dumbly +dumbness +dummies +dummy +dump +dumped +dumper +dumping +dumps +Dumpty +Dunbar +Duncan +dunce +dunces +Dundee +dune +Dunedin +dunes +dung +dungeon +dungeons +Dunham +dunk +Dunkirk +Dunlap +Dunlop +Dunn +Dunne +dupe +duplex +duplicable +duplicate +duplicated +duplicates +duplicating +duplication +duplications +duplicator +duplicators +duplicity +DuPont +Dupont +DuPonts +Duponts +Duquesne +durabilities +durability +durable +durably +Durango +duration +durations +Durer +Durers +duress +Durham +during +Durkee +Durkin +Durrell +Durward +Dusenberg +Dusenbury +dusk +duskiness +dusky +Dusseldorf +dust +dustbin +dusted +duster +dusters +dustier +dustiest +Dustin +dusting +dusts +dusty +Dutch +dutchess +Dutchman +Dutchmen +duties +dutiful +dutifully +dutifulness +Dutton +duty +Dvorak +dwarf +dwarfed +dwarfs +dwarves +dwell +dwelled +dweller +dwellers +dwelling +dwellings +dwells +dwelt +Dwight +dwindle +dwindled +dwindling +Dwyer +dyad +dyadic +dye +dyed +dyeing +dyer +dyers +dyes +dying +Dyke +Dylan +dynamic +dynamically +dynamics +dynamism +dynamite +dynamited +dynamites +dynamiting +dynamo +dynastic +dynasties +dynasty +dyne +dysentery +dyspeptic +dystrophy +each +Eagan +eager +eagerly +eagerness +eagle +eagles +ear +eardrum +eared +earl +earlier +earliest +earliness +earls +early +earmark +earmarked +earmarking +earmarkings +earmarks +earn +earned +earner +earners +earnest +earnestly +earnestness +earning +earnings +earns +Earp +earphone +earring +earrings +ears +earsplitting +earth +earthen +earthenware +earthliness +earthling +earthly +Earthman +Earthmen +earthmover +earthquake +earthquakes +earths +earthworm +earthworms +earthy +ease +eased +easel +easement +easements +eases +easier +easiest +easily +easiness +easing +east +eastbound +easter +eastern +easterner +easterners +easternmost +Easthampton +Eastland +Eastman +eastward +eastwards +Eastwick +Eastwood +easy +easygoing +eat +eaten +eater +eaters +eating +eatings +Eaton +eats +eaves +eavesdrop +eavesdropped +eavesdropper +eavesdroppers +eavesdropping +eavesdrops +ebb +ebbing +ebbs +Eben +ebony +eccentric +eccentricities +eccentricity +eccentrics +Eccles +ecclesiastical +echelon +echo +echoed +echoes +echoing +eclectic +eclipse +eclipsed +eclipses +eclipsing +ecliptic +Ecole +ecology +econometric +Econometrica +economic +economical +economically +economics +economies +economist +economists +economize +economized +economizer +economizers +economizes +economizing +economy +ecosystem +ecstasy +ecstatic +Ecuador +Ecuadorian +Ed +Eddie +eddies +eddy +Eden +Edenization +Edenizations +Edenize +Edenizes +Edgar +edge +edged +Edgerton +edges +Edgewater +Edgewood +edging +edible +edict +edicts +edifice +edifices +Edinburgh +Edison +edit +edited +Edith +editing +edition +editions +editor +editorial +editorially +editorials +editors +edits +Edmonds +Edmondson +Edmonton +Edmund +Edna +Edsger +Eduard +Eduardo +educable +educate +educated +educates +educating +education +educational +educationally +educations +educator +educators +Edward +Edwardian +Edwardine +Edwards +Edwin +Edwina +eel +eelgrass +eels +eerie +eerily +effect +effected +effecting +effective +effectively +effectiveness +effector +effectors +effects +effectually +effectuate +effeminate +efficacy +efficiencies +efficiency +efficient +efficiently +Effie +effigy +effort +effortless +effortlessly +effortlessness +efforts +egalitarian +Egan +egg +egged +egghead +egging +eggplant +eggs +eggshell +ego +egocentric +egos +egotism +egotist +Egypt +Egyptian +Egyptianization +Egyptianizations +Egyptianize +Egyptianizes +Egyptians +Egyptize +Egyptizes +Egyptology +Ehrlich +Eichmann +Eiffel +eigenfunction +eigenstate +eigenvalue +eigenvalues +eigenvector +eight +eighteen +eighteens +eighteenth +eightfold +eighth +eighthes +eighties +eightieth +eights +eighty +Eileen +Einstein +Einsteinian +Eire +Eisenhower +Eisner +either +ejaculate +ejaculated +ejaculates +ejaculating +ejaculation +ejaculations +eject +ejected +ejecting +ejects +Ekberg +eke +eked +ekes +Ekstrom +Ektachrome +elaborate +elaborated +elaborately +elaborateness +elaborates +elaborating +elaboration +elaborations +elaborators +Elaine +elapse +elapsed +elapses +elapsing +elastic +elastically +elasticity +Elba +elbow +elbowing +elbows +elder +elderly +elders +eldest +Eldon +Eleanor +Eleazar +elect +elected +electing +election +elections +elective +electives +elector +electoral +electorate +electors +Electra +electric +electrical +electrically +electricalness +electrician +electricity +electrification +electrify +electrifying +electro +electrocardiogram +electrocardiograph +electrocute +electrocuted +electrocutes +electrocuting +electrocution +electrocutions +electrode +electrodes +electroencephalogram +electroencephalograph +electroencephalography +electrolysis +electrolyte +electrolytes +electrolytic +electromagnetic +electromechanical +electron +electronic +electronically +electronics +electrons +electrophoresis +electrophorus +elects +elegance +elegant +elegantly +elegy +element +elemental +elementals +elementary +elements +Elena +elephant +elephants +elevate +elevated +elevates +elevation +elevator +elevators +eleven +elevens +eleventh +elf +Elgin +Eli +elicit +elicited +eliciting +elicits +elide +eligibility +eligible +Elijah +eliminate +eliminated +eliminates +eliminating +elimination +eliminations +eliminator +eliminators +Elinor +Eliot +Elisabeth +Elisha +elision +elite +elitist +Elizabeth +Elizabethan +Elizabethanize +Elizabethanizes +Elizabethans +elk +Elkhart +elks +Ella +Ellen +Ellie +Elliot +Elliott +ellipse +ellipses +ellipsis +ellipsoid +ellipsoidal +ellipsoids +elliptic +elliptical +elliptically +Ellis +Ellison +Ellsworth +Ellwood +elm +Elmer +Elmhurst +Elmira +elms +Elmsford +Eloise +elope +eloquence +eloquent +eloquently +Elroy +else +Elsevier +elsewhere +Elsie +Elsinore +Elton +elucidate +elucidated +elucidates +elucidating +elucidation +elude +eluded +eludes +eluding +elusive +elusively +elusiveness +elves +Elvis +Ely +Elysee +Elysees +Elysium +em +emaciate +emaciated +emacs +emanate +emanating +emancipate +emancipation +Emanuel +emasculate +embalm +embargo +embargoes +embark +embarked +embarks +embarrass +embarrassed +embarrasses +embarrassing +embarrassment +embassies +embassy +embed +embedded +embedding +embeds +embellish +embellished +embellishes +embellishing +embellishment +embellishments +ember +embezzle +emblem +embodied +embodies +embodiment +embodiments +embody +embodying +embolden +embrace +embraced +embraces +embracing +embroider +embroidered +embroideries +embroiders +embroidery +embroil +embryo +embryology +embryos +emerald +emeralds +emerge +emerged +emergence +emergencies +emergency +emergent +emerges +emerging +emeritus +Emerson +Emery +emigrant +emigrants +emigrate +emigrated +emigrates +emigrating +emigration +Emil +Emile +Emilio +Emily +eminence +eminent +eminently +emissary +emission +emit +emits +emitted +emitter +emitting +Emma +Emmanuel +Emmett +Emory +emotion +emotional +emotionally +emotions +empathy +emperor +emperors +emphases +emphasis +emphasize +emphasized +emphasizes +emphasizing +emphatic +emphatically +empire +empires +empirical +empirically +empiricist +empiricists +employ +employable +employed +employee +employees +employer +employers +employing +employment +employments +employs +emporium +empower +empowered +empowering +empowers +empress +emptied +emptier +empties +emptiest +emptily +emptiness +empty +emptying +emulate +emulated +emulates +emulating +emulation +emulations +emulator +emulators +en +enable +enabled +enabler +enablers +enables +enabling +enact +enacted +enacting +enactment +enacts +enamel +enameled +enameling +enamels +encamp +encamped +encamping +encamps +encapsulate +encapsulated +encapsulates +encapsulating +encapsulation +encased +enchant +enchanted +enchanter +enchanting +enchantment +enchantress +enchants +encipher +enciphered +enciphering +enciphers +encircle +encircled +encircles +enclose +enclosed +encloses +enclosing +enclosure +enclosures +encode +encoded +encoder +encoders +encodes +encoding +encodings +encompass +encompassed +encompasses +encompassing +encore +encounter +encountered +encountering +encounters +encourage +encouraged +encouragement +encouragements +encourages +encouraging +encouragingly +encroach +encrust +encrypt +encrypted +encrypting +encryption +encryptions +encrypts +encumber +encumbered +encumbering +encumbers +encyclopedia +encyclopedias +encyclopedic +end +endanger +endangered +endangering +endangers +endear +endeared +endearing +endears +endeavor +endeavored +endeavoring +endeavors +ended +endemic +ender +enders +endgame +Endicott +ending +endings +endless +endlessly +endlessness +endorse +endorsed +endorsement +endorses +endorsing +endow +endowed +endowing +endowment +endowments +endows +endpoint +ends +endurable +endurably +endurance +endure +endured +endures +enduring +enduringly +enema +enemas +enemies +enemy +energetic +energies +energize +energy +enervate +enfeeble +Enfield +enforce +enforceable +enforced +enforcement +enforcer +enforcers +enforces +enforcing +enfranchise +Eng +engage +engaged +engagement +engagements +engages +engaging +engagingly +Engel +Engels +engender +engendered +engendering +engenders +engine +engineer +engineered +engineering +engineers +engines +England +Englander +Englanders +Engle +Englewood +English +Englishize +Englishizes +Englishman +Englishmen +engrave +engraved +engraver +engraves +engraving +engravings +engross +engrossed +engrossing +engulf +enhance +enhanced +enhancement +enhancements +enhances +enhancing +Enid +enigma +enigmatic +enjoin +enjoined +enjoining +enjoins +enjoy +enjoyable +enjoyably +enjoyed +enjoying +enjoyment +enjoys +enlarge +enlarged +enlargement +enlargements +enlarger +enlargers +enlarges +enlarging +enlighten +enlightened +enlightening +enlightenment +enlist +enlisted +enlistment +enlists +enliven +enlivened +enlivening +enlivens +enmities +enmity +ennoble +ennobled +ennobles +ennobling +ennui +Enoch +enormities +enormity +enormous +enormously +Enos +enough +enqueue +enqueued +enqueues +enquire +enquired +enquirer +enquires +enquiry +enrage +enraged +enrages +enraging +enrapture +enrich +enriched +enriches +enriching +Enrico +enroll +enrolled +enrolling +enrollment +enrollments +enrolls +ensemble +ensembles +ensign +ensigns +enslave +enslaved +enslaves +enslaving +ensnare +ensnared +ensnares +ensnaring +Ensolite +ensue +ensued +ensues +ensuing +ensure +ensured +ensurer +ensurers +ensures +ensuring +entail +entailed +entailing +entails +entangle +enter +entered +entering +enterprise +enterprises +enterprising +enters +entertain +entertained +entertainer +entertainers +entertaining +entertainingly +entertainment +entertainments +entertains +enthusiasm +enthusiasms +enthusiast +enthusiastic +enthusiastically +enthusiasts +entice +enticed +enticer +enticers +entices +enticing +entire +entirely +entireties +entirety +entities +entitle +entitled +entitles +entitling +entity +entomb +entrance +entranced +entrances +entrap +entreat +entreated +entreaty +entree +entrench +entrenched +entrenches +entrenching +entrepreneur +entrepreneurial +entrepreneurs +entries +entropy +entrust +entrusted +entrusting +entrusts +entry +enumerable +enumerate +enumerated +enumerates +enumerating +enumeration +enumerative +enumerator +enumerators +enunciation +envelop +envelope +enveloped +enveloper +envelopes +enveloping +envelops +envied +envies +envious +enviously +enviousness +environ +environing +environment +environmental +environments +environs +envisage +envisaged +envisages +envision +envisioned +envisioning +envisions +envoy +envoys +envy +enzyme +Eocene +epaulet +epaulets +ephemeral +Ephesian +Ephesians +Ephesus +Ephraim +epic +epicenter +epics +Epicurean +Epicurize +Epicurizes +Epicurus +epidemic +epidemics +epidermis +epigram +epileptic +epilogue +Epiphany +episcopal +Episcopalian +Episcopalianize +Episcopalianizes +episode +episodes +epistemological +epistemology +epistle +epistles +epitaph +epitaphs +epitaxial +epitaxially +epithet +epithets +epitomize +epitomized +epitomizes +epitomizing +epoch +epochs +epsilon +Epsom +Epstein +equal +equaled +equaling +equalities +equality +equalization +equalize +equalized +equalizer +equalizers +equalizes +equalizing +equally +equals +equate +equated +equates +equating +equation +equations +equator +equatorial +equators +equestrian +equidistant +equilateral +equilibrate +equilibria +equilibrium +equilibriums +equinox +equip +equipment +equipoise +equipped +equipping +equips +equitable +equitably +equity +equivalence +equivalences +equivalent +equivalently +equivalents +equivocal +equivocally +era +eradicate +eradicated +eradicates +eradicating +eradication +eras +erasable +erase +erased +eraser +erasers +erases +erasing +Erasmus +Erastus +erasure +Erato +Eratosthenes +ere +erect +erected +erecting +erection +erections +erector +erectors +erects +erg +ergo +ergodic +Eric +Erich +Erickson +Ericsson +Erie +Erik +Erikson +Eris +Erlang +Erlenmeyer +Erlenmeyers +ermine +ermines +Erne +Ernest +Ernestine +Ernie +Ernst +erode +Eros +erosion +erotic +erotica +err +errand +errant +errata +erratic +erratum +erred +erring +erringly +Errol +erroneous +erroneously +erroneousness +error +errors +errs +ersatz +Erskine +erudite +erupt +eruption +Ervin +Erwin +escalate +escalated +escalates +escalating +escalation +escapable +escapade +escapades +escape +escaped +escapee +escapees +escapes +escaping +Escherichia +eschew +eschewed +eschewing +eschews +escort +escorted +escorting +escorts +escrow +Eskimo +Eskimoized +Eskimoizeds +Eskimos +Esmark +esoteric +Espagnol +especial +especially +espionage +Esposito +espouse +espoused +espouses +espousing +esprit +espy +esquire +esquires +essay +essayed +essays +Essen +essence +essences +Essenize +Essenizes +essential +essentially +essentials +Essex +establish +established +establishes +establishing +establishment +establishments +estate +estates +esteem +esteemed +esteeming +esteems +Estella +Estes +Esther +esthetics +estimate +estimated +estimates +estimating +estimation +estimations +Estonia +Estonian +et +etch +etching +eternal +eternally +eternities +eternity +Ethan +Ethel +ether +ethereal +ethereally +Ethernet +Ethernets +ethers +ethic +ethical +ethically +ethics +Ethiopia +Ethiopians +ethnic +etiquette +Etruria +Etruscan +etymology +eucalyptus +Eucharist +Euclid +Euclidean +Eugene +Eugenia +Euler +Eulerian +Eumenides +Eunice +eunuch +eunuchs +euphemism +euphemisms +euphoria +euphoric +Euphrates +Eurasia +Eurasian +eureka +Euripides +Europa +Europe +European +Europeanization +Europeanizations +Europeanize +Europeanized +Europeanizes +Europeans +Eurydice +Euterpe +euthanasia +Eva +evacuate +evacuated +evacuation +evade +evaded +evades +evading +evaluate +evaluated +evaluates +evaluating +evaluation +evaluations +evaluative +evaluator +evaluators +Evangeline +Evans +Evanston +Evansville +evaporate +evaporated +evaporating +evaporation +evaporative +evasion +evasive +Eve +Evelyn +even +evened +evenhanded +evenhandedly +evenhandedness +evening +evenings +evenly +evenness +evens +Evensen +event +eventful +eventfully +events +eventual +eventualities +eventuality +eventually +ever +Eveready +Everest +Everett +Everglade +Everglades +evergreen +Everhart +everlasting +everlastingly +evermore +every +everybody +everyday +everyone +everything +everywhere +evict +evicted +evicting +eviction +evictions +evicts +evidence +evidenced +evidences +evidencing +evident +evidently +evil +eviller +evilly +evils +evince +evinced +evinces +evoke +evoked +evokes +evoking +evolute +evolutes +evolution +evolutionary +evolutions +evolve +evolved +evolves +evolving +ewe +Ewen +ewes +Ewing +ex +exacerbate +exacerbated +exacerbates +exacerbating +exacerbation +exacerbations +exact +exacted +exacting +exactingly +exaction +exactions +exactitude +exactly +exactness +exacts +exaggerate +exaggerated +exaggerates +exaggerating +exaggeration +exaggerations +exalt +exaltation +exalted +exalting +exalts +exam +examination +examinations +examine +examined +examiner +examiners +examines +examining +example +examples +exams +exasperate +exasperated +exasperates +exasperating +exasperation +excavate +excavated +excavates +excavating +excavation +excavations +exceed +exceeded +exceeding +exceedingly +exceeds +excel +excelled +excellence +excellences +excellency +excellent +excellently +excelling +excels +except +excepted +excepting +exception +exceptionable +exceptional +exceptionally +exceptions +excepts +excerpt +excerpted +excerpts +excess +excesses +excessive +excessively +exchange +exchangeable +exchanged +exchanges +exchanging +exchequer +exchequers +excise +excised +excises +excising +excision +excitable +excitation +excitations +excite +excited +excitedly +excitement +excites +exciting +excitingly +exciton +exclaim +exclaimed +exclaimer +exclaimers +exclaiming +exclaims +exclamation +exclamations +exclamatory +exclude +excluded +excludes +excluding +exclusion +exclusionary +exclusions +exclusive +exclusively +exclusiveness +exclusivity +excommunicate +excommunicated +excommunicates +excommunicating +excommunication +excrete +excreted +excretes +excreting +excretion +excretions +excretory +excruciate +excursion +excursions +excusable +excusably +excuse +excused +excuses +excusing +exec +executable +execute +executed +executes +executing +execution +executional +executioner +executions +executive +executives +executor +executors +exemplar +exemplary +exemplification +exemplified +exemplifier +exemplifiers +exemplifies +exemplify +exemplifying +exempt +exempted +exempting +exemption +exempts +exercise +exercised +exerciser +exercisers +exercises +exercising +exert +exerted +exerting +exertion +exertions +exerts +Exeter +exhale +exhaled +exhales +exhaling +exhaust +exhausted +exhaustedly +exhausting +exhaustion +exhaustive +exhaustively +exhausts +exhibit +exhibited +exhibiting +exhibition +exhibitions +exhibitor +exhibitors +exhibits +exhilarate +exhort +exhortation +exhortations +exhume +exigency +exile +exiled +exiles +exiling +exist +existed +existence +existent +existential +existentialism +existentialist +existentialists +existentially +existing +exists +exit +exited +exiting +exits +exodus +exorbitant +exorbitantly +exorcism +exorcist +exoskeleton +exotic +expand +expandable +expanded +expander +expanders +expanding +expands +expanse +expanses +expansible +expansion +expansionism +expansions +expansive +expect +expectancy +expectant +expectantly +expectation +expectations +expected +expectedly +expecting +expectingly +expects +expediency +expedient +expediently +expedite +expedited +expedites +expediting +expedition +expeditions +expeditious +expeditiously +expel +expelled +expelling +expels +expend +expendable +expended +expending +expenditure +expenditures +expends +expense +expenses +expensive +expensively +experience +experienced +experiences +experiencing +experiment +experimental +experimentally +experimentation +experimentations +experimented +experimenter +experimenters +experimenting +experiments +expert +expertise +expertly +expertness +experts +expiration +expirations +expire +expired +expires +expiring +explain +explainable +explained +explainer +explainers +explaining +explains +explanation +explanations +explanatory +expletive +explicit +explicitly +explicitness +explode +exploded +explodes +exploding +exploit +exploitable +exploitation +exploitations +exploited +exploiter +exploiters +exploiting +exploits +exploration +explorations +exploratory +explore +explored +explorer +explorers +explores +exploring +explosion +explosions +explosive +explosively +explosives +exponent +exponential +exponentially +exponentials +exponentiate +exponentiated +exponentiates +exponentiating +exponentiation +exponentiations +exponents +export +exportation +exported +exporter +exporters +exporting +exports +expose +exposed +exposer +exposers +exposes +exposing +exposition +expositions +expository +exposure +exposures +expound +expounded +expounder +expounding +expounds +express +expressed +expresses +expressibility +expressible +expressibly +expressing +expression +expressions +expressive +expressively +expressiveness +expressly +expulsion +expunge +expunged +expunges +expunging +expurgate +exquisite +exquisitely +exquisiteness +extant +extemporaneous +extend +extendable +extended +extending +extends +extensibility +extensible +extension +extensions +extensive +extensively +extent +extents +extenuate +extenuated +extenuating +extenuation +exterior +exteriors +exterminate +exterminated +exterminates +exterminating +extermination +external +externally +extinct +extinction +extinguish +extinguished +extinguisher +extinguishes +extinguishing +extirpate +extol +extort +extorted +extortion +extra +extract +extracted +extracting +extraction +extractions +extractor +extractors +extracts +extracurricular +extramarital +extraneous +extraneously +extraneousness +extraordinarily +extraordinariness +extraordinary +extrapolate +extrapolated +extrapolates +extrapolating +extrapolation +extrapolations +extras +extraterrestrial +extravagance +extravagant +extravagantly +extravaganza +extremal +extreme +extremely +extremes +extremist +extremists +extremities +extremity +extricate +extrinsic +extrovert +exuberance +exult +exultation +Exxon +eye +eyeball +eyebrow +eyebrows +eyed +eyeful +eyeglass +eyeglasses +eyeing +eyelash +eyelid +eyelids +eyepiece +eyepieces +eyer +eyers +eyes +eyesight +eyewitness +eyewitnesses +eying +Ezekiel +Ezra +Faber +Fabian +fable +fabled +fables +fabric +fabricate +fabricated +fabricates +fabricating +fabrication +fabrics +fabulous +fabulously +facade +facaded +facades +face +faced +faces +facet +faceted +facets +facial +facile +facilely +facilitate +facilitated +facilitates +facilitating +facilities +facility +facing +facings +facsimile +facsimiles +fact +faction +factions +factious +facto +factor +factored +factorial +factories +factoring +factorization +factorizations +factors +factory +facts +factual +factually +faculties +faculty +fade +faded +fadeout +fader +faders +fades +fading +Fafnir +fag +Fagin +fags +Fahey +Fahrenheit +Fahrenheits +fail +failed +failing +failings +fails +failsoft +failure +failures +fain +faint +fainted +fainter +faintest +fainting +faintly +faintness +faints +fair +Fairbanks +Fairchild +fairer +fairest +Fairfax +Fairfield +fairies +fairing +fairly +Fairmont +fairness +Fairport +fairs +Fairview +fairy +fairyland +faith +faithful +faithfully +faithfulness +faithless +faithlessly +faithlessness +faiths +fake +faked +faker +fakes +faking +falcon +falconer +falcons +Falk +Falkland +Falklands +fall +fallacies +fallacious +fallacy +fallen +fallibility +fallible +falling +Fallopian +fallout +fallow +falls +Falmouth +false +falsehood +falsehoods +falsely +falseness +falsification +falsified +falsifies +falsify +falsifying +falsity +Falstaff +falter +faltered +falters +fame +famed +fames +familial +familiar +familiarities +familiarity +familiarization +familiarize +familiarized +familiarizes +familiarizing +familiarly +familiarness +families +familism +family +famine +famines +famish +famous +famously +fan +fanatic +fanaticism +fanatics +fancied +fancier +fanciers +fancies +fanciest +fanciful +fancifully +fancily +fanciness +fancy +fancying +fanfare +fanfold +fang +fangled +fangs +fanned +Fannies +fanning +Fanny +fanout +fans +fantasies +fantasize +fantastic +fantasy +FAQ +far +farad +Faraday +faraway +Farber +farce +farces +fare +fared +fares +farewell +farewells +farfetched +Fargo +farina +faring +Farkas +Farley +farm +farmed +farmer +farmers +farmhouse +farmhouses +farming +Farmington +farmland +farms +farmyard +farmyards +Farnsworth +Farrell +farsighted +farther +farthest +farthing +fascicle +fascinate +fascinated +fascinates +fascinating +fascination +fascism +fascist +fashion +fashionable +fashionably +fashioned +fashioning +fashions +fast +fasted +fasten +fastened +fastener +fasteners +fastening +fastenings +fastens +faster +fastest +fastidious +fasting +fastness +fasts +fat +fatal +fatalities +fatality +fatally +fatals +fate +fated +fateful +fates +father +fathered +fatherland +fatherly +fathers +fathom +fathomed +fathoming +fathoms +fatigue +fatigued +fatigues +fatiguing +Fatima +fatness +fats +fatten +fattened +fattener +fatteners +fattening +fattens +fatter +fattest +fatty +faucet +Faulkner +Faulknerian +fault +faulted +faulting +faultless +faultlessly +faults +faulty +faun +fauna +Fauntleroy +Faust +Faustian +Faustus +favor +favorable +favorably +favored +favorer +favoring +favorite +favorites +favoritism +favors +Fawkes +fawn +fawned +fawning +fawns +Fayette +Fayetteville +faze +Fe +fear +feared +fearful +fearfully +fearing +fearless +fearlessly +fearlessness +fears +fearsome +feasibility +feasible +feast +feasted +feasting +feasts +feat +feather +featherbed +featherbedding +feathered +featherer +featherers +feathering +Featherman +feathers +featherweight +feathery +feats +feature +featured +features +featuring +Februaries +February +fecund +fed +Fedders +federal +federalist +federally +federals +federation +Fedora +fee +feeble +feebleness +feebler +feeblest +feebly +feed +feedback +feeder +feeders +feeding +feedings +feeds +feel +feeler +feelers +feeling +feelingly +feelings +feels +Feeney +fees +feet +feign +feigned +feigning +Felder +Feldman +Felice +Felicia +felicities +felicity +feline +Felix +fell +fellatio +felled +felling +Fellini +fellow +fellows +fellowship +fellowships +felon +felonious +felony +felt +felts +female +females +feminine +femininity +feminism +feminist +femur +femurs +fen +fence +fenced +fencer +fencers +fences +fencing +fend +Fenton +Fenwick +Ferber +Ferdinand +Ferdinando +Ferguson +Fermat +ferment +fermentation +fermentations +fermented +fermenting +ferments +Fermi +fern +Fernando +ferns +ferocious +ferociously +ferociousness +ferocity +Ferreira +Ferrer +ferret +ferried +ferries +ferrite +ferry +fertile +fertilely +fertility +fertilization +fertilize +fertilized +fertilizer +fertilizers +fertilizes +fertilizing +fervent +fervently +fervor +fervors +Fess +festival +festivals +festive +festively +festivities +festivity +fetal +fetch +fetched +fetches +fetching +fetchingly +fetid +fetish +fetter +fettered +fetters +fettle +fetus +feud +feudal +feudalism +feuds +fever +fevered +feverish +feverishly +fevers +few +fewer +fewest +fewness +fiance +fiancee +fiasco +fiat +fib +fibbing +fiber +Fiberglas +fibers +Fibonacci +fibrosities +fibrosity +fibrous +fibrously +fickle +fickleness +fiction +fictional +fictionally +fictions +fictitious +fictitiously +fiddle +fiddled +fiddler +fiddles +fiddlestick +fiddlesticks +fiddling +Fidel +fidelity +fidget +fiducial +fief +fiefdom +field +fielded +fielder +fielders +fielding +Fields +fieldwork +fiend +fiendish +fierce +fiercely +fierceness +fiercer +fiercest +fiery +fife +fifteen +fifteens +fifteenth +fifth +fifties +fiftieth +fifty +fig +Figaro +fight +fighter +fighters +fighting +fights +figs +figurative +figuratively +figure +figured +figures +figuring +figurings +Fiji +Fijian +Fijians +filament +filaments +file +filed +filename +filenames +filer +files +filial +filibuster +filing +filings +Filipino +Filipinos +Filippo +fill +fillable +filled +filler +fillers +filling +fillings +Fillmore +fills +filly +film +filmed +filming +films +filter +filtered +filtering +filters +filth +filthier +filthiest +filthiness +filthy +fin +final +finality +finalization +finalize +finalized +finalizes +finalizing +finally +finals +finance +financed +finances +financial +financially +financier +financiers +financing +find +finder +finders +finding +findings +finds +fine +fined +finely +fineness +finer +fines +finesse +finessed +finessing +finest +finger +fingered +fingering +fingerings +fingernail +fingerprint +fingerprints +fingers +fingertip +finicky +fining +finish +finished +finisher +finishers +finishes +finishing +finite +finitely +finiteness +fink +Finland +Finley +Finn +Finnegan +Finnish +Finns +finny +fins +Fiorello +Fiori +fir +fire +firearm +firearms +fireboat +firebreak +firebug +firecracker +fired +fireflies +firefly +firehouse +firelight +fireman +firemen +fireplace +fireplaces +firepower +fireproof +firer +firers +fires +fireside +Firestone +firewall +firewood +fireworks +firing +firings +firm +firmament +firmed +firmer +firmest +firming +firmly +firmness +firms +firmware +first +firsthand +firstly +firsts +fiscal +fiscally +Fischbein +Fischer +fish +fished +fisher +fisherman +fishermen +fishers +fishery +fishes +fishing +Fishkill +fishmonger +fishpond +fishy +Fisk +Fiske +fission +fissure +fissured +fist +fisted +fisticuff +fists +fit +Fitch +Fitchburg +fitful +fitfully +fitly +fitness +fits +fitted +fitter +fitters +fitting +fittingly +fittings +Fitzgerald +Fitzpatrick +Fitzroy +five +fivefold +fives +fix +fixate +fixated +fixates +fixating +fixation +fixations +fixed +fixedly +fixedness +fixer +fixers +fixes +fixing +fixings +fixture +fixtures +Fizeau +fizzle +fizzled +flabbergast +flabbergasted +flack +flag +flagellate +flagged +flagging +Flagler +flagpole +flagrant +flagrantly +flags +Flagstaff +flail +flair +flak +flake +flaked +flakes +flaking +flaky +flam +flamboyant +flame +flamed +flamer +flamers +flames +flaming +flammable +Flanagan +Flanders +flank +flanked +flanker +flanking +flanks +flannel +flannels +flap +flaps +flare +flared +flares +flaring +flash +flashback +flashed +flasher +flashers +flashes +flashing +flashlight +flashlights +flashy +flask +flat +flatbed +flatly +flatness +flats +flatten +flattened +flattening +flatter +flattered +flatterer +flattering +flattery +flattest +flatulent +flatus +flatworm +flaunt +flaunted +flaunting +flaunts +flavor +flavored +flavoring +flavorings +flavors +flaw +flawed +flawless +flawlessly +flaws +flax +flaxen +flea +fleas +fled +Fledermaus +fledged +fledgling +fledglings +flee +fleece +fleeces +fleecy +fleeing +flees +fleet +fleetest +fleeting +fleetly +fleetness +fleets +Fleischman +Fleisher +Fleming +Flemings +Flemish +Flemished +Flemishes +Flemishing +flesh +fleshed +fleshes +fleshing +fleshly +fleshy +Fletcher +Fletcherize +Fletcherizes +flew +flex +flexibilities +flexibility +flexible +flexibly +flick +flicked +flicker +flickering +flicking +flicks +flier +fliers +flies +flight +flights +flimsy +flinch +flinched +flinches +flinching +fling +flings +flint +flinty +flip +flipflop +flipped +flips +flirt +flirtation +flirtatious +flirted +flirting +flirts +flit +flitting +Flo +float +floated +floater +floating +floats +flock +flocked +flocking +flocks +flog +flogging +flood +flooded +flooding +floodlight +floodlit +floods +floor +floored +flooring +floorings +floors +flop +floppies +floppily +flopping +floppy +flops +flora +floral +Florence +Florentine +florid +Florida +Floridian +Floridians +florin +florist +floss +flossed +flosses +flossing +flotation +flotilla +flounder +floundered +floundering +flounders +flour +floured +flourish +flourished +flourishes +flourishing +flow +flowchart +flowcharting +flowcharts +flowed +flower +flowered +floweriness +flowering +flowerpot +flowers +flowery +flowing +flown +flows +Floyd +flu +fluctuate +fluctuates +fluctuating +fluctuation +fluctuations +flue +fluency +fluent +fluently +fluff +fluffier +fluffiest +fluffy +fluid +fluidity +fluidly +fluids +fluke +flung +flunked +fluoresce +fluorescent +flurried +flurry +flush +flushed +flushes +flushing +flute +fluted +fluting +flutter +fluttered +fluttering +flutters +flux +fly +flyable +flyer +flyers +flying +Flynn +foal +foam +foamed +foaming +foams +foamy +fob +fobbing +focal +focally +foci +focus +focused +focuses +focusing +focussed +fodder +foe +foes +fog +Fogarty +fogged +foggier +foggiest +foggily +fogging +foggy +fogs +fogy +foible +foil +foiled +foiling +foils +foist +fold +folded +folder +folders +folding +foldout +folds +Foley +foliage +folk +folklore +folks +folksong +folksy +follies +follow +followed +follower +followers +following +followings +follows +folly +Folsom +Fomalhaut +fond +fonder +fondle +fondled +fondles +fondling +fondly +fondness +font +Fontaine +Fontainebleau +Fontana +fonts +food +foods +foodstuff +foodstuffs +fool +fooled +foolhardy +fooling +foolish +foolishly +foolishness +foolproof +fools +foot +footage +football +footballs +footbridge +Foote +footed +footer +footers +footfall +foothill +foothold +footing +footman +footnote +footnotes +footpath +footprint +footprints +footstep +footsteps +for +forage +foraged +forages +foraging +foray +forays +forbade +forbear +forbearance +forbears +Forbes +forbid +forbidden +forbidding +forbids +force +forced +forceful +forcefully +forcefulness +forcer +forces +forcible +forcibly +forcing +ford +Fordham +fords +fore +forearm +forearms +foreboding +forecast +forecasted +forecaster +forecasters +forecasting +forecastle +forecasts +forefather +forefathers +forefinger +forefingers +forego +foregoes +foregoing +foregone +foreground +forehead +foreheads +foreign +foreigner +foreigners +foreigns +foreman +foremost +forenoon +forensic +forerunners +foresee +foreseeable +foreseen +foresees +foresight +foresighted +forest +forestall +forestalled +forestalling +forestallment +forestalls +forested +forester +foresters +forestry +forests +foretell +foretelling +foretells +foretold +forever +forewarn +forewarned +forewarning +forewarnings +forewarns +forfeit +forfeited +forfeiture +forgave +forge +forged +forger +forgeries +forgery +forges +forget +forgetful +forgetfulness +forgets +forgettable +forgettably +forgetting +forging +forgivable +forgivably +forgive +forgiven +forgiveness +forgives +forgiving +forgivingly +forgot +forgotten +fork +forked +forking +forklift +forks +forlorn +forlornly +form +formal +formalism +formalisms +formalities +formality +formalization +formalizations +formalize +formalized +formalizes +formalizing +formally +formant +formants +format +formation +formations +formative +formatively +formats +formatted +formatter +formatters +formatting +formed +former +formerly +Formica +Formicas +formidable +forming +Formosa +Formosan +forms +formula +formulae +formulas +formulate +formulated +formulates +formulating +formulation +formulations +formulator +formulators +fornication +Forrest +forsake +forsaken +forsakes +forsaking +Forsythe +fort +forte +Fortescue +FORTH +forthcoming +forthright +forthwith +fortier +forties +fortieth +fortification +fortifications +fortified +fortifies +fortify +fortifying +fortiori +fortitude +fortnight +fortnightly +FORTRAN +Fortran +fortress +fortresses +forts +fortuitous +fortuitously +fortunate +fortunately +fortune +fortunes +forty +forum +forums +forward +forwarded +forwarder +forwarding +forwardness +forwards +Foss +fossil +foster +fostered +fostering +fosters +fought +foul +fouled +foulest +fouling +foully +foulmouth +foulness +fouls +found +foundation +foundations +founded +founder +foundered +founders +founding +foundling +foundries +foundry +founds +fount +fountain +fountains +founts +four +fourfold +Fourier +fours +fourscore +foursome +foursquare +fourteen +fourteens +fourteenth +fourth +fowl +fowler +fowls +fox +foxes +Foxhall +fraction +fractional +fractionally +fractions +fracture +fractured +fractures +fracturing +fragile +fragment +fragmentary +fragmentation +fragmented +fragmenting +fragments +fragrance +fragrances +fragrant +fragrantly +frail +frailest +frailty +frame +framed +framer +frames +framework +frameworks +framing +Fran +franc +Francaise +France +Frances +Francesca +Francesco +franchise +franchises +Francie +Francine +Francis +Franciscan +Franciscans +Francisco +Francize +Francizes +Franco +Francois +Francoise +francs +frank +franked +Frankel +franker +frankest +Frankfort +Frankfurt +Frankie +franking +Franklinization +Franklinizations +frankly +frankness +franks +Franny +frantic +frantically +Franz +Fraser +fraternal +fraternally +fraternities +fraternity +Frau +fraud +frauds +fraudulent +fraught +fray +frayed +fraying +Frayne +frays +Frazier +frazzle +freak +freakish +freaks +freckle +freckled +freckles +Fred +Freddie +Freddy +Frederic +Frederick +Fredericks +Fredericksburg +Frederico +Fredericton +Fredholm +Fredrick +Fredrickson +free +freed +Freedman +freedom +freedoms +freeing +freeings +freely +freeman +Freemason +Freemasonry +Freemasons +freeness +Freeport +freer +frees +freest +freestyle +Freetown +freeway +freewheel +freeze +freezer +freezers +freezes +freezing +Freida +freight +freighted +freighter +freighters +freighting +freights +French +Frenchize +Frenchizes +Frenchman +Frenchmen +frenetic +frenzied +frenzy +freon +frequencies +frequency +frequent +frequented +frequenter +frequenters +frequenting +frequently +frequents +fresco +frescoes +fresh +freshen +freshened +freshener +fresheners +freshening +freshens +fresher +freshest +freshly +freshman +freshmen +freshness +freshwater +Fresnel +Fresno +fret +fretful +fretfully +fretfulness +Freud +Freudian +Freudianism +Freudianisms +Freudians +Frey +Freya +friar +friars +fricative +fricatives +Frick +friction +frictionless +frictions +Friday +Fridays +fried +Friedman +Friedrich +friend +friendless +friendlier +friendliest +friendliness +friendly +friends +friendship +friendships +fries +Friesland +frieze +friezes +frigate +frigates +Frigga +fright +frighten +frightened +frightening +frighteningly +frightens +frightful +frightfully +frightfulness +frigid +Frigidaire +frill +frills +fringe +fringed +Frisbee +Frisia +Frisian +frisk +frisked +frisking +frisks +frisky +Frito +fritter +Fritz +frivolity +frivolous +frivolously +fro +frock +frocks +frog +frogs +frolic +frolics +from +front +frontage +frontal +fronted +frontier +frontiers +frontiersman +frontiersmen +fronting +fronts +frost +Frostbelt +frostbite +frostbitten +frosted +frosting +frosts +frosty +froth +frothing +frothy +frown +frowned +frowning +frowns +froze +frozen +frozenly +Fruehauf +frugal +frugally +fruit +fruitful +fruitfully +fruitfulness +fruition +fruitless +fruitlessly +fruits +frustrate +frustrated +frustrates +frustrating +frustration +frustrations +fry +Frye +Fuchs +Fuchsia +fudge +fuel +fueled +fueling +fuels +fugitive +fugitives +fugue +Fuji +Fujitsu +Fulbright +Fulbrights +fulcrum +fulfill +fulfilled +fulfilling +fulfillment +fulfillments +fulfills +full +fuller +Fullerton +fullest +fullness +fully +fulminate +Fulton +fumble +fumbled +fumbling +fume +fumed +fumes +fuming +fun +function +functional +functionalities +functionality +functionally +functionals +functionary +functioned +functioning +functions +functor +functors +fund +fundamental +fundamentally +fundamentals +funded +funder +funders +funding +funds +funeral +funerals +funereal +fungal +fungi +fungible +fungicide +fungus +funk +funnel +funneled +funneling +funnels +funnier +funniest +funnily +funniness +funny +fur +furies +furious +furiouser +furiously +furlong +furlough +Furman +furnace +furnaces +furnish +furnished +furnishes +furnishing +furnishings +furniture +furrier +furrow +furrowed +furrows +furry +furs +further +furthered +furthering +furthermore +furthermost +furthers +furthest +furtive +furtively +furtiveness +fury +fuse +fused +fuses +fusing +fusion +fuss +fussing +fussy +futile +futility +future +futures +futuristic +fuzz +fuzzier +fuzziness +fuzzy +gab +gabardine +gabbing +Gaberones +gable +gabled +gabler +gables +Gabon +Gaborone +Gabriel +Gabrielle +gad +gadfly +gadget +gadgetry +gadgets +Gaelic +Gaelicization +Gaelicizations +Gaelicize +Gaelicizes +gag +gagged +gagging +gaging +gags +gaieties +gaiety +Gail +gaily +gain +gained +gainer +gainers +Gaines +Gainesville +gainful +gaining +gains +gait +gaited +gaiter +gaiters +Gaithersburg +galactic +Galahad +Galapagos +Galatea +Galatean +Galateans +Galatia +Galatians +galaxies +galaxy +Galbreath +gale +Galen +Galilean +Galilee +Galileo +gall +Gallagher +gallant +gallantly +gallantry +gallants +galled +galleried +galleries +gallery +galley +galleys +galling +gallon +gallons +gallop +galloped +galloper +galloping +gallops +Galloway +gallows +galls +gallstone +Gallup +Galois +Galt +Galveston +Galvin +Galway +Gambia +gambit +gamble +gambled +gambler +gamblers +gambles +gambling +gambol +game +gamed +gamely +gameness +games +gaming +gamma +gander +Gandhi +Gandhian +gang +Ganges +gangland +gangling +gangplank +gangrene +gangs +gangster +gangsters +Gannett +gantry +Ganymede +gap +gape +gaped +gapes +gaping +gaps +garage +garaged +garages +garb +garbage +garbages +garbed +garble +garbled +Garcia +garden +gardened +gardener +gardeners +gardening +gardens +Gardner +Garfield +Garfunkel +gargantuan +gargle +gargled +gargles +gargling +Garibaldi +garland +garlanded +garlic +garment +garments +garner +garnered +Garnett +garnish +Garrett +garrison +garrisoned +Garrisonian +Garry +garter +garters +Garth +Garvey +Gary +gas +Gascony +gaseous +gaseously +gases +gash +gashes +gasket +gaslight +gasoline +gasp +gasped +Gaspee +gasping +gasps +gassed +gasser +Gasset +gassing +gassings +gassy +Gaston +gastric +gastrointestinal +gastronome +gastronomy +gate +gated +Gates +gateway +gateways +gather +gathered +gatherer +gatherers +gathering +gatherings +gathers +gating +Gatlinburg +gator +Gatsby +gauche +gaudiness +gaudy +gauge +gauged +gauges +Gauguin +Gaul +Gaulle +Gauls +gaunt +Gauntley +gauntness +Gaussian +Gautama +gauze +gave +gavel +Gavin +gawk +gawky +gay +gayer +gayest +gayety +Gaylor +Gaylord +gayly +gayness +Gaynor +gaze +gazed +gazelle +gazer +gazers +gazes +gazette +gazing +gear +geared +gearing +gears +Geary +gecko +geese +Gehrig +Geiger +Geigy +geisha +gel +gelatin +gelatine +gelatinous +geld +gelled +gelling +gels +gem +Gemini +Geminid +Gemma +gems +gender +genders +gene +genealogy +general +generalist +generalists +generalities +generality +generalization +generalizations +generalize +generalized +generalizer +generalizers +generalizes +generalizing +generally +generals +generate +generated +generates +generating +generation +generations +generative +generator +generators +generic +generically +generosities +generosity +generous +generously +generousness +genes +Genesco +genesis +genetic +genetically +Geneva +Genevieve +genial +genially +genie +genius +geniuses +Genoa +genre +genres +gent +genteel +gentile +gentle +gentleman +gentlemanly +gentlemen +gentleness +gentler +gentlest +gentlewoman +gently +gentry +genuine +genuinely +genuineness +genus +geocentric +geodesic +geodesy +geodetic +Geoff +Geoffrey +geographer +geographic +geographical +geographically +geography +geological +geologist +geologists +geology +geometric +geometrical +geometrically +geometrician +geometries +geometry +geophysical +geophysics +George +Georges +Georgetown +Georgia +Georgian +Georgians +geosynchronous +Gerald +Geraldine +geranium +Gerard +Gerber +gerbil +Gerhard +Gerhardt +geriatric +germ +German +germane +Germania +Germanic +Germans +Germantown +Germany +germicide +germinal +germinate +germinated +germinates +germinating +germination +germs +Gerome +Gerry +Gershwin +Gershwins +Gertrude +gerund +Gestapo +gesture +gestured +gestures +gesturing +get +getaway +gets +getter +getters +getting +Getty +Gettysburg +geyser +Ghana +Ghanian +ghastly +Ghent +ghetto +ghost +ghosted +ghostly +ghosts +Giacomo +giant +giants +gibberish +Gibbons +Gibbs +Gibby +Gibraltar +Gibson +giddiness +Giddings +giddy +Gideon +Gifford +gift +gifted +gifts +gig +gigabit +gigabits +gigabyte +gigabytes +gigacycle +gigahertz +gigantic +gigavolt +gigawatt +giggle +giggled +giggles +giggling +Gil +Gilbertson +Gilchrist +gild +gilded +gilding +gilds +Gilead +Giles +Gilkson +gill +Gillespie +Gillette +Gilligan +gills +Gilmore +gilt +Gimbel +gimmick +gimmicks +gin +Gina +ginger +gingerbread +gingerly +gingham +ginghams +Ginn +Gino +gins +Ginsberg +Ginsburg +Gioconda +Giorgio +Giovanni +Gipsies +Gipsy +giraffe +giraffes +gird +girder +girders +girdle +girl +girlfriend +girlie +girlish +girls +girt +girth +gist +Giuliano +Giuseppe +give +giveaway +given +giver +givers +gives +giving +glacial +glacier +glaciers +glad +gladden +gladder +gladdest +glade +gladiator +gladly +gladness +Gladstone +Gladys +glamor +glamorous +glamour +glance +glanced +glances +glancing +gland +glands +glandular +glare +glared +glares +glaring +glaringly +Glasgow +glass +glassed +glasses +glassy +Glaswegian +glaucoma +glaze +glazed +glazer +glazes +glazing +gleam +gleamed +gleaming +gleams +glean +gleaned +gleaner +gleaning +gleanings +gleans +Gleason +glee +gleeful +gleefully +glees +glen +Glenda +Glendale +Glenn +glens +Glidden +glide +glided +glider +gliders +glides +glimmer +glimmered +glimmering +glimmers +glimpse +glimpsed +glimpses +glint +glinted +glinting +glints +glisten +glistened +glistening +glistens +glitch +glitter +glittered +glittering +glitters +gloat +global +globally +globe +globes +globular +globularity +gloom +gloomily +gloomy +Gloria +Gloriana +glories +glorification +glorified +glorifies +glorify +glorious +gloriously +glory +glorying +gloss +glossaries +glossary +glossed +glosses +glossing +glossy +glottal +Gloucester +glove +gloved +glover +glovers +gloves +gloving +glow +glowed +glower +glowers +glowing +glowingly +glows +glue +glued +glues +gluing +glut +glutton +Glynn +gnash +gnat +gnats +gnaw +gnawed +gnawing +gnaws +gnome +gnomon +gnu +go +Goa +goad +goaded +goal +goals +goat +goatee +goatees +goats +gobble +gobbled +gobbler +gobblers +gobbles +Gobi +goblet +goblets +goblin +goblins +god +Goddard +goddess +goddesses +godfather +Godfrey +godhead +godlike +godly +godmother +godmothers +Godot +godparent +gods +godsend +godson +Godwin +Godzilla +goes +Goethe +Goff +goggles +Gogh +going +goings +gold +Golda +Goldberg +golden +goldenly +goldenness +goldenrod +Goldfield +goldfish +golding +Goldman +golds +goldsmith +Goldstein +Goldstine +Goldwater +Goleta +golf +golfer +golfers +golfing +Goliath +golly +Gomez +gondola +gone +goner +gong +gongs +Gonzales +Gonzalez +good +goodby +goodbye +Goode +goodies +goodly +Goodman +goodness +Goodrich +goods +goodwill +Goodwin +goody +Goodyear +goof +goofed +goofs +goofy +goose +gopher +Gordian +Gordon +gore +Goren +gorge +gorgeous +gorgeously +gorges +gorging +Gorham +gorilla +gorillas +Gorky +Gorton +gory +gosh +gospel +gospelers +gospels +gossip +gossiped +gossiping +gossips +got +Gotham +Gothic +Gothically +Gothicism +Gothicize +Gothicized +Gothicizer +Gothicizers +Gothicizes +Gothicizing +GOTO +GOTOs +gotten +Gottfried +Goucher +Gouda +gouge +gouged +gouges +gouging +Gould +gourd +gourmet +gout +govern +governance +governed +governess +governing +government +governmental +governmentally +governments +governor +governors +governs +gown +gowned +gowns +grab +grabbed +grabber +grabbers +grabbing +grabbings +grabs +grace +graced +graceful +gracefully +gracefulness +graces +Gracie +gracing +gracious +graciously +graciousness +grad +gradation +gradations +grade +graded +grader +graders +grades +gradient +gradients +grading +gradings +gradual +gradually +graduate +graduated +graduates +graduating +graduation +graduations +Grady +Graff +graft +grafted +grafter +grafting +Grafton +grafts +graham +grahams +grail +grain +grained +graining +grains +gram +grammar +grammarian +grammars +grammatic +grammatical +grammatically +grams +granaries +granary +grand +grandchild +grandchildren +granddaughter +grander +grandest +grandeur +grandfather +grandfathers +grandiose +grandly +grandma +grandmother +grandmothers +grandnephew +grandness +grandniece +grandpa +grandparent +grands +grandson +grandsons +grandstand +grange +granite +granny +granola +grant +granted +grantee +granter +granting +grantor +grants +granularity +granulate +granulated +granulates +granulating +Granville +grape +grapefruit +grapes +grapevine +graph +graphed +graphic +graphical +graphically +graphics +graphing +graphite +graphs +grapple +grappled +grappling +grasp +graspable +grasped +grasping +graspingly +grasps +grass +grassed +grassers +grasses +grassier +grassiest +grassland +grassy +grate +grated +grateful +gratefully +gratefulness +grater +grates +gratification +gratified +gratify +gratifying +grating +gratings +gratis +gratitude +gratuities +gratuitous +gratuitously +gratuitousness +gratuity +grave +gravel +gravelly +gravely +graven +graveness +graver +Graves +gravest +gravestone +graveyard +gravitate +gravitation +gravitational +gravity +gravy +gray +grayed +grayer +grayest +graying +grayness +Grayson +graze +grazed +grazer +grazing +grease +greased +greases +greasy +great +greater +greatest +greatly +greatness +Grecian +Grecianize +Grecianizes +Greece +greed +greedily +greediness +greedy +Greek +Greekize +Greekizes +Greeks +green +Greenbelt +Greenberg +Greenblatt +Greenbriar +Greene +greener +greenery +greenest +Greenfeld +Greenfield +greengrocer +greenhouse +greenhouses +greening +greenish +Greenland +greenly +greenness +greens +Greensboro +Greensville +Greentree +Greenville +greenware +Greenwich +Greer +greet +greeted +greeter +greeting +greetings +greets +Greg +gregarious +Gregg +Gregorian +Gregory +grenade +grenades +Grendel +Grenier +Grenoble +Grenville +Gresham +Greta +Gretchen +grew +grey +greyest +greyhound +greying +grid +griddle +gridiron +grids +grief +griefs +grievance +grievances +grieve +grieved +griever +grievers +grieves +grieving +grievingly +grievous +grievously +Griffith +grill +grilled +grilling +grills +grim +grimace +Grimaldi +grime +grimed +Grimes +grimly +Grimm +grimness +grin +grind +grinder +grinders +grinding +grindings +grinds +grindstone +grindstones +grinning +grins +grip +gripe +griped +gripes +griping +gripped +gripping +grippingly +grips +Gris +grisly +grist +Griswold +grit +grits +gritty +grizzly +groan +groaned +groaner +groaners +groaning +groans +grocer +groceries +grocers +grocery +groggy +groin +groom +groomed +grooming +grooms +Groot +groove +grooved +grooves +grope +groped +gropes +groping +gross +grossed +grosser +grosses +grossest +Grosset +grossing +grossly +Grossman +grossness +Grosvenor +grotesque +grotesquely +grotesques +Groton +grotto +grottos +ground +grounded +grounder +grounders +grounding +grounds +groundwork +group +grouped +grouping +groupings +groups +grouse +grove +grovel +groveled +groveling +grovels +Grover +grovers +groves +grow +grower +growers +growing +growl +growled +growling +growls +grown +grownup +grownups +grows +growth +growths +grub +grubby +grubs +grudge +grudges +grudgingly +gruesome +gruff +gruffly +grumble +grumbled +grumbles +grumbling +Grumman +grunt +grunted +grunting +grunts +Grusky +Gruyere +Guadalupe +Guam +guano +guarantee +guaranteed +guaranteeing +guaranteer +guaranteers +guarantees +guaranty +guard +guarded +guardedly +guardhouse +Guardia +guardian +guardians +guardianship +guarding +guards +Guatemala +Guatemalan +gubernatorial +Guelph +Guenther +guerrilla +guerrillas +guess +guessed +guesses +guessing +guesswork +guest +guests +Guggenheim +Guhleman +Guiana +guidance +guide +guidebook +guidebooks +guided +guideline +guidelines +guides +guiding +guild +guilder +guilders +guile +Guilford +guilt +guiltier +guiltiest +guiltily +guiltiness +guiltless +guiltlessly +guilty +guinea +Guinevere +guise +guises +guitar +guitars +Gujarat +Gujarati +gulch +gulches +gulf +gulfs +gull +Gullah +gulled +gullies +gulling +gulls +gully +gulp +gulped +gulps +gum +gumming +gumption +gums +gun +Gunderson +gunfire +gunman +gunmen +Gunnar +gunned +gunner +gunners +gunnery +gunning +gunny +gunplay +gunpowder +guns +gunshot +Gunther +gurgle +Gurkha +guru +Gus +gush +gushed +gusher +gushes +gushing +gust +Gustafson +Gustav +Gustave +Gustavus +gusto +gusts +gusty +gut +Gutenberg +Guthrie +guts +gutsy +gutter +guttered +gutters +gutting +guttural +guy +Guyana +guyed +guyer +guyers +guying +guys +Gwen +Gwyn +gymnasium +gymnasiums +gymnast +gymnastic +gymnastics +gymnasts +gypsies +gypsy +gyro +gyrocompass +gyroscope +gyroscopes +ha +Haag +Haas +habeas +Haberman +Habib +habit +habitat +habitation +habitations +habitats +habits +habitual +habitually +habitualness +hack +hacked +hacker +hackers +Hackett +hacking +hackneyed +hacks +hacksaw +had +Hadamard +Haddad +haddock +Hades +Hadley +Hadrian +Hafiz +hag +Hagen +Hager +haggard +haggardly +haggle +Hagstrom +Hague +Hahn +Haifa +hail +hailed +hailing +hails +hailstone +hailstorm +Haines +hair +haircut +haircuts +hairier +hairiness +hairless +hairpin +hairs +hairy +Haiti +Haitian +Hal +halcyon +hale +haler +Haley +half +halfhearted +halfway +Halifax +hall +Halley +Hallinan +hallmark +hallmarks +hallow +hallowed +Halloween +halls +hallucinate +hallway +hallways +halogen +Halpern +Halsey +Halstead +halt +halted +halter +halters +halting +haltingly +halts +halve +halved +halvers +Halverson +halves +halving +ham +Hamal +Hamburg +hamburger +hamburgers +Hamey +Hamilton +Hamiltonian +Hamiltonians +hamlet +hamlets +Hamlin +hammer +hammered +hammering +hammers +Hammett +hamming +hammock +hammocks +Hammond +hamper +hampered +hampers +Hampshire +Hampton +hams +hamster +Han +Hancock +hand +handbag +handbags +handbook +handbooks +handcuff +handcuffed +handcuffing +handcuffs +handed +Handel +handful +handfuls +handgun +handicap +handicapped +handicaps +handier +handiest +handily +handiness +handing +handiwork +handkerchief +handkerchiefs +handle +handled +handler +handlers +handles +handling +handmaid +handout +hands +handshake +handshakes +handshaking +handsome +handsomely +handsomeness +handsomer +handsomest +handwriting +handwritten +handy +Haney +Hanford +hang +hangar +hangars +hanged +hanger +hangers +hanging +hangman +hangmen +hangout +hangover +hangovers +hangs +Hankel +Hanley +Hanlon +Hanna +Hannah +Hannibal +Hanoi +Hanover +Hanoverian +Hanoverianize +Hanoverianizes +Hanoverize +Hanoverizes +Hans +Hansel +Hansen +Hanson +Hanukkah +hap +Hapgood +haphazard +haphazardly +haphazardness +hapless +haplessly +haplessness +haply +happen +happened +happening +happenings +happens +happier +happiest +happily +happiness +happy +Hapsburg +harass +harassed +harasses +harassing +harassment +Harbin +harbinger +harbor +harbored +harboring +harbors +Harcourt +hard +hardboiled +hardcopy +harden +harder +hardest +hardhat +Hardin +hardiness +Harding +hardly +hardness +hardscrabble +hardship +hardships +hardware +hardwired +hardworking +hardy +hare +harelip +harem +hares +hark +harken +Harlan +Harlem +Harley +harlot +harlots +harm +harmed +harmful +harmfully +harmfulness +harming +harmless +harmlessly +harmlessness +Harmon +harmonic +harmonics +harmonies +harmonious +harmoniously +harmoniousness +Harmonist +Harmonistic +Harmonistically +harmonize +harmony +harms +harness +harnessed +harnessing +Harold +harp +harper +harpers +harping +Harpy +harried +harrier +Harriet +Harriman +Harrington +Harris +Harrisburg +Harrison +Harrisonburg +harrow +harrowed +harrowing +harrows +harry +harsh +harsher +harshly +harshness +hart +Hartford +Hartley +Hartman +Harvard +Harvardize +Harvardizes +harvest +harvested +harvester +harvesting +harvests +Harvey +Harveyize +Harveyizes +Harveys +has +hash +hashed +hasher +hashes +hashing +hashish +Haskell +Haskins +hassle +haste +hasten +hastened +hastening +hastens +hastily +hastiness +Hastings +hasty +hat +hatch +hatched +hatchet +hatchets +hatching +Hatchure +hate +hated +hateful +hatefully +hatefulness +hater +hates +Hatfield +Hathaway +hating +hatred +hats +Hatteras +Hattie +Hattiesburg +Hattize +Hattizes +Haugen +haughtily +haughtiness +haughty +haul +hauled +hauler +hauling +hauls +haunch +haunches +haunt +haunted +haunter +haunting +haunts +Hausa +Hausdorff +Hauser +Havana +have +haven +havens +haves +Havilland +having +havoc +Hawaii +Hawaiian +hawk +hawked +hawker +hawkers +Hawkins +hawks +Hawley +Hawthorne +hay +Hayden +Haydn +Hayes +haying +Haynes +Hays +haystack +Hayward +Haywood +hazard +hazardous +hazards +haze +hazel +hazes +haziness +hazy +he +head +headache +headaches +headed +header +headers +headgear +heading +headings +headland +headlands +headlight +headline +headlined +headlines +headlining +headlong +headmaster +headphone +headquarters +headroom +heads +headset +headway +heal +healed +healer +healers +Healey +healing +heals +health +healthful +healthfully +healthfulness +healthier +healthiest +healthily +healthiness +healthy +Healy +heap +heaped +heaping +heaps +hear +heard +hearer +hearers +hearing +hearings +hearken +hears +hearsay +Hearst +heart +heartbeat +heartbreak +hearten +heartiest +heartily +heartiness +heartless +hearts +Heartwood +hearty +heat +heatable +heated +heatedly +heater +heaters +heath +heathen +heather +Heathkit +Heathman +heating +heats +heave +heaved +heaven +heavenly +heavens +heaver +heavers +heaves +heavier +heaviest +heavily +heaviness +heaving +heavy +heavyweight +Hebe +Hebraic +Hebraicize +Hebraicizes +Hebrew +Hebrews +Hebrides +Hecate +heck +heckle +Heckman +hectic +Hecuba +Hedda +hedge +hedged +hedgehog +hedgehogs +hedges +hedonism +hedonist +heed +heeded +heedless +heedlessly +heedlessness +heeds +heel +heeled +heelers +heeling +heels +hefty +Hegel +Hegelian +Hegelianize +Hegelianizes +hegemony +Heidegger +Heidelberg +heifer +height +heighten +heightened +heightening +heightens +heights +Heine +Heinlein +heinous +heinously +Heinrich +Heinz +Heinze +heir +heiress +heiresses +heirs +Heisenberg +Heiser +held +Helen +Helena +Helene +Helga +helical +helicopter +heliocentric +Heliopolis +helium +helix +hell +Hellenic +Hellenization +Hellenizations +Hellenize +Hellenized +Hellenizes +Hellenizing +Hellespont +hellfire +hellish +Hellman +hello +hells +helm +helmet +helmets +Helmholtz +helmsman +Helmut +help +helped +helper +helpers +helpful +helpfully +helpfulness +helping +helpless +helplessly +helplessness +helpmate +helps +Helsinki +Helvetica +hem +Hemingway +hemisphere +hemispheres +hemlock +hemlocks +hemoglobin +hemorrhoid +hemostat +hemostats +hemp +hempen +Hempstead +hems +hen +hence +henceforth +henchman +henchmen +Henderson +Hendrick +Hendricks +Hendrickson +Hendrix +Henley +Hennessey +Hennessy +Henning +henpeck +Henri +Henrietta +hens +hepatitis +Hepburn +her +Hera +Heraclitus +herald +heralded +heralding +heralds +herb +Herbert +herbivore +herbivorous +herbs +Herculean +Hercules +herd +herded +herder +herding +herds +here +hereabout +hereabouts +hereafter +hereby +hereditary +heredity +Hereford +herein +hereinafter +hereof +heres +heresy +heretic +heretics +hereto +heretofore +hereunder +herewith +heritage +heritages +Herkimer +Herman +Hermann +Hermes +hermetic +hermetically +hermit +Hermite +hermitian +hermits +Hermosa +Hernandez +hero +Herodotus +heroes +heroic +heroically +heroics +heroin +heroine +heroines +heroism +heron +herons +herpes +Herr +herring +herrings +Herrington +hers +Herschel +herself +Hersey +Hershel +Hershey +hertz +Hertzog +hesitant +hesitantly +hesitate +hesitated +hesitates +hesitating +hesitatingly +hesitation +hesitations +Hesperus +Hess +Hesse +Hessian +Hessians +Hester +heterogeneity +heterogeneous +heterogeneously +heterogeneousness +heterogenous +heterosexual +Hetman +Hettie +Hetty +Heublein +heuristic +heuristically +heuristics +Heusen +Heuser +hew +hewed +hewer +Hewett +Hewitt +Hewlett +hews +hex +hexadecimal +hexagon +hexagonal +hexagonally +hexagons +hey +Heywood +hi +Hiatt +Hiawatha +Hibbard +hibernate +Hibernia +hick +Hickey +Hickeys +Hickman +Hickok +hickory +Hicks +hid +hidden +hide +hideous +hideously +hideousness +hideout +hideouts +hides +hiding +hierarchal +hierarchic +hierarchical +hierarchically +hierarchies +hierarchy +Hieronymus +Higgins +high +higher +highest +Highfield +highland +highlander +highlands +highlight +highlighted +highlighting +highlights +highly +highness +highnesses +highway +highwayman +highwaymen +highways +hijack +hijacked +hike +hiked +hiker +hikes +hiking +hilarious +hilariously +hilarity +Hilbert +Hildebrand +hill +Hillary +hillbilly +Hillcrest +Hillel +hillock +hills +Hillsboro +Hillsdale +hillside +hillsides +hilltop +hilltops +hilt +Hilton +hilts +him +Himalaya +Himalayas +Himmler +himself +hind +hinder +hindered +hindering +hinders +Hindi +hindrance +hindrances +hindsight +Hindu +Hinduism +Hindus +Hindustan +Hines +hinge +hinged +hinges +Hinkle +Hinman +Hinsdale +hint +hinted +hinting +hints +hip +hippo +Hippocrates +Hippocratic +hippopotamus +hips +Hiram +hire +hired +hirer +hirers +hires +Hirey +hiring +hirings +Hiroshi +Hiroshima +Hirsch +his +Hispanic +Hispanicize +Hispanicizes +Hispanics +hiss +hissed +hisses +hissing +histogram +histograms +historian +historians +historic +historical +historically +histories +history +hit +Hitachi +hitch +Hitchcock +hitched +hitchhike +hitchhiked +hitchhiker +hitchhikers +hitchhikes +hitchhiking +hitching +hither +hitherto +Hitler +Hitlerian +Hitlerism +Hitlerite +Hitlerites +hits +hitter +hitters +hitting +hive +Hoagland +hoar +hoard +hoarder +hoarding +hoariness +hoarse +hoarsely +hoarseness +hoary +Hobart +Hobbes +hobbies +hobble +hobbled +hobbles +hobbling +Hobbs +hobby +hobbyhorse +hobbyist +hobbyists +Hobday +Hoboken +hockey +hodgepodge +Hodges +Hodgkin +hoe +hoes +Hoff +Hoffman +hog +hogging +hogs +hoist +hoisted +hoisting +hoists +Hokan +Holbrook +Holcomb +hold +holden +holder +holders +holding +holdings +holds +hole +holed +holes +holiday +holidays +holies +holiness +holistic +Holland +Hollandaise +Hollander +Hollerith +Hollingsworth +Hollister +hollow +Holloway +hollowed +hollowing +hollowly +hollowness +hollows +holly +Hollywood +Hollywoodize +Hollywoodizes +Holm +Holman +Holmdel +Holmes +holocaust +Holocene +hologram +holograms +Holst +Holstein +holy +Holyoke +Holzman +Hom +homage +home +home-brew +homed +homeless +homely +homemade +homemaker +homemakers +homeomorphic +homeomorphism +homeomorphisms +homeopath +homeowner +homer +Homeric +homers +homes +homesick +homesickness +homespun +homestead +homesteader +homesteaders +homesteads +homeward +homewards +homework +homicidal +homicide +homing +homo +homogeneities +homogeneity +homogeneous +homogeneously +homogeneousness +homomorphic +homomorphism +homomorphisms +homosexual +Honda +Hondo +Honduras +hone +honed +honer +hones +honest +honestly +honesty +honey +honeybee +honeycomb +honeycombed +honeydew +honeymoon +honeymooned +honeymooner +honeymooners +honeymooning +honeymoons +honeysuckle +Honeywell +honing +Honolulu +honor +honorable +honorableness +honorably +honoraries +honorarium +honorary +honored +honorer +honoring +honors +Honshu +hood +hooded +hoodlum +hoods +hoodwink +hoodwinked +hoodwinking +hoodwinks +hoof +hoofs +hook +hooked +hooker +hookers +hooking +hooks +hookup +hookups +hoop +hooper +hoops +Hoosier +Hoosierize +Hoosierizes +hoot +hooted +hooter +hooting +hoots +Hoover +Hooverize +Hooverizes +hooves +hop +hope +hoped +hopeful +hopefully +hopefulness +hopefuls +hopeless +hopelessly +hopelessness +hopes +Hopi +hoping +Hopkins +Hopkinsian +hopper +hoppers +hopping +hops +Horace +Horatio +horde +hordes +horizon +horizons +horizontal +horizontally +hormone +hormones +horn +Hornblower +horned +hornet +hornets +horns +horny +Horowitz +horrendous +horrendously +horrible +horribleness +horribly +horrid +horridly +horrified +horrifies +horrify +horrifying +horror +horrors +horse +horseback +horseflesh +horsefly +horseman +horseplay +horsepower +horses +horseshoe +horseshoer +horticulture +Horton +Horus +hose +hoses +hospitable +hospitably +hospital +hospitality +hospitalize +hospitalized +hospitalizes +hospitalizing +hospitals +host +hostage +hostages +hosted +hostess +hostesses +hostile +hostilely +hostilities +hostility +hosting +hosts +hot +hotel +hotels +hotly +hotness +Hottentot +hotter +hottest +Houdaille +Houdini +Houghton +hound +hounded +hounding +hounds +hour +hourglass +hourly +hours +house +houseboat +housebroken +housed +houseflies +housefly +household +householder +householders +households +housekeeper +housekeepers +housekeeping +houses +housetop +housetops +housewife +housewifely +housewives +housework +housing +Houston +hovel +hovels +hover +hovered +hovering +hovers +how +Howard +Howe +Howell +however +howl +howled +howler +howling +howls +Hoyt +Hrothgar +hub +Hubbard +Hubbell +Huber +Hubert +hubris +hubs +Huck +huddle +huddled +huddling +Hudson +hue +hues +Huey +Huffman +hug +huge +hugely +hugeness +hugging +Huggins +Hugh +Hughes +Hugo +huh +hull +hulls +hum +human +humane +humanely +humaneness +humanitarian +humanities +humanity +humanly +humanness +humans +humble +humbled +humbleness +humbler +humblest +humbling +humbly +Humboldt +humbug +Hume +humerus +humid +humidification +humidified +humidifier +humidifiers +humidifies +humidify +humidifying +humidity +humidly +humiliate +humiliated +humiliates +humiliating +humiliation +humiliations +humility +hummed +Hummel +humming +hummingbird +humor +humored +humorer +humorers +humoring +humorous +humorously +humorousness +humors +hump +humpback +humped +Humphrey +Humpty +hums +Hun +hunch +hunched +hunches +hundred +hundredfold +hundreds +hundredth +hung +Hungarian +Hungary +hunger +hungered +hungering +hungers +hungrier +hungriest +hungrily +hungry +hunk +hunks +Huns +hunt +hunted +Hunter +hunters +hunting +Huntington +Huntley +hunts +huntsman +Huntsville +Hurd +hurdle +hurl +hurled +hurler +hurlers +hurling +Huron +Hurons +hurrah +hurricane +hurricanes +hurried +hurriedly +hurries +hurry +hurrying +Hurst +hurt +hurting +hurtle +hurtling +hurts +Hurwitz +husband +husbandry +husbands +hush +hushed +hushes +hushing +husk +husked +husker +huskiness +husking +husks +husky +hustle +hustled +hustler +hustles +hustling +Huston +hut +hutch +Hutchins +Hutchinson +Hutchison +huts +Huxley +Huxtable +hyacinth +Hyades +Hyannis +hybrid +Hyde +hydra +hydrant +hydraulic +hydro +hydrodynamic +hydrodynamics +hydrogen +hydrogens +hyena +hygiene +Hyman +hymen +hymn +hymns +hyper +hyperbola +hyperbolic +hypertext +hyphen +hyphenate +hyphens +hypnosis +hypnotic +hypocrisies +hypocrisy +hypocrite +hypocrites +hypodermic +hypodermics +hypotheses +hypothesis +hypothesize +hypothesized +hypothesizer +hypothesizes +hypothesizing +hypothetical +hypothetically +hysteresis +hysterical +hysterically +Ian +Iberia +Iberian +Ibero- +ibex +ibid +ibis +Ibn +Ibsen +Icarus +ice +iceberg +icebergs +icebox +iced +Iceland +Icelandic +ices +icicle +iciness +icing +icings +icon +iconoclasm +iconoclast +icons +icosahedra +icosahedral +icosahedron +icy +Ida +Idaho +idea +ideal +idealism +idealistic +idealization +idealizations +idealize +idealized +idealizes +idealizing +ideally +ideals +ideas +idem +idempotency +idempotent +identical +identically +identifiable +identifiably +identification +identifications +identified +identifier +identifiers +identifies +identify +identifying +identities +identity +ideological +ideologically +ideology +idiocy +idiom +idiosyncrasies +idiosyncrasy +idiosyncratic +idiot +idiotic +idiots +idle +idled +idleness +idler +idlers +idles +idlest +idling +idly +idol +idolatry +idols +if +Ifni +igloo +ignite +ignition +ignoble +ignominious +ignoramus +ignorance +ignorant +ignorantly +ignore +ignored +ignores +ignoring +Igor +Ike +Iliad +Iliadize +Iliadizes +ill +illegal +illegalities +illegality +illegally +illegitimate +illicit +illicitly +Illinois +illiteracy +illiterate +illness +illnesses +illogical +illogically +ills +illuminate +illuminated +illuminates +illuminating +illumination +illuminations +illusion +illusions +illusive +illusively +illusory +illustrate +illustrated +illustrates +illustrating +illustration +illustrations +illustrative +illustratively +illustrator +illustrators +illustrious +illustriousness +illy +Ilona +Ilyushin +image +Imagen +imagery +images +imaginable +imaginably +imaginary +imagination +imaginations +imaginative +imaginatively +imagine +imagined +imagines +imaging +imagining +imaginings +imbalance +imbalances +imbecile +imbibe +Imbrium +imitate +imitated +imitates +imitating +imitation +imitations +imitative +immaculate +immaculately +immaterial +immaterially +immature +immaturity +immediacies +immediacy +immediate +immediately +immemorial +immense +immensely +immerse +immersed +immerses +immersion +immigrant +immigrants +immigrate +immigrated +immigrates +immigrating +immigration +imminent +imminently +immoderate +immodest +immoral +immortal +immortality +immortally +immovability +immovable +immovably +immune +immunities +immunity +immunization +immutable +imp +impact +impacted +impacting +impaction +impactor +impactors +impacts +impair +impaired +impairing +impairs +impale +impart +imparted +impartial +impartially +imparts +impasse +impassive +impatience +impatient +impatiently +impeach +impeachable +impeached +impeachment +impeccable +impedance +impedances +impede +impeded +impedes +impediment +impediments +impeding +impel +impelled +impelling +impend +impending +impenetrability +impenetrable +impenetrably +imperative +imperatively +imperatives +imperceivable +imperceptible +imperfect +imperfection +imperfections +imperfectly +imperial +imperialism +imperialist +imperialists +imperil +imperiled +imperious +imperiously +impermanence +impermanent +impermeable +impermissible +impersonal +impersonally +impersonate +impersonated +impersonates +impersonating +impersonation +impersonations +impertinent +impertinently +impervious +imperviously +impetuous +impetuously +impetus +impinge +impinged +impinges +impinging +impious +implacable +implant +implanted +implanting +implants +implausible +implement +implementable +implementation +implementations +implemented +implementer +implementing +implementor +implementors +implements +implicant +implicants +implicate +implicated +implicates +implicating +implication +implications +implicit +implicitly +implicitness +implied +implies +implore +implored +imploring +imply +implying +impolite +import +importance +important +importantly +importation +imported +importer +importers +importing +imports +impose +imposed +imposes +imposing +imposition +impositions +impossibilities +impossibility +impossible +impossibly +impostor +impostors +impotence +impotency +impotent +impound +impoverish +impoverished +impoverishment +impracticable +impractical +impracticality +impractically +imprecise +imprecisely +imprecision +impregnable +impregnate +impress +impressed +impresser +impresses +impressible +impressing +impression +impressionable +impressionist +impressionistic +impressions +impressive +impressively +impressiveness +impressment +imprimatur +imprint +imprinted +imprinting +imprints +imprison +imprisoned +imprisoning +imprisonment +imprisonments +imprisons +improbability +improbable +impromptu +improper +improperly +impropriety +improve +improved +improvement +improvements +improves +improving +improvisation +improvisational +improvisations +improvise +improvised +improviser +improvisers +improvises +improvising +imprudent +imps +impudent +impudently +impugn +impulse +impulses +impulsion +impulsive +impunity +impure +impurities +impurity +impute +imputed +in +inability +inaccessible +inaccuracies +inaccuracy +inaccurate +inaction +inactivate +inactive +inactivity +inadequacies +inadequacy +inadequate +inadequately +inadequateness +inadmissibility +inadmissible +inadvertent +inadvertently +inadvisable +inalienable +inalterable +inane +inanimate +inanimately +Inanna +inapplicable +inapproachable +inappropriate +inappropriateness +inasmuch +inattention +inaudible +inaugural +inaugurate +inaugurated +inaugurating +inauguration +inauspicious +inboard +inbound +inbreed +Inca +incalculable +incandescent +incantation +incapable +incapacitate +incapacitating +incarcerate +incarnation +incarnations +Incas +incendiaries +incendiary +incense +incensed +incenses +incentive +incentives +inception +incessant +incessantly +incest +incestuous +inch +inched +inches +inching +incidence +incident +incidental +incidentally +incidentals +incidents +incinerate +incipient +incisive +incite +incited +incitement +incites +inciting +inclement +inclination +inclinations +incline +inclined +inclines +inclining +inclose +inclosed +incloses +inclosing +include +included +includes +including +inclusion +inclusions +inclusive +inclusively +inclusiveness +incoherence +incoherent +incoherently +income +incomes +incoming +incommensurable +incommensurate +incommunicable +incomparable +incomparably +incompatibilities +incompatibility +incompatible +incompatibly +incompetence +incompetent +incompetents +incomplete +incompletely +incompleteness +incomprehensibility +incomprehensible +incomprehensibly +incomprehension +incompressible +incomputable +inconceivable +inconclusive +incongruity +incongruous +inconsequential +inconsequentially +inconsiderable +inconsiderate +inconsiderately +inconsiderateness +inconsistencies +inconsistency +inconsistent +inconsistently +inconspicuous +incontestable +incontrovertible +incontrovertibly +inconvenience +inconvenienced +inconveniences +inconveniencing +inconvenient +inconveniently +inconvertible +incorporate +incorporated +incorporates +incorporating +incorporation +incorrect +incorrectly +incorrectness +incorrigible +increase +increased +increases +increasing +increasingly +incredible +incredibly +incredulity +incredulous +incredulously +increment +incremental +incrementally +incremented +incrementer +incrementing +increments +incriminate +incubate +incubated +incubates +incubating +incubation +incubator +incubators +inculcate +incumbent +incur +incurable +incurred +incurring +incurs +incursion +indebted +indebtedness +indecent +indecipherable +indecision +indecisive +indeed +indefatigable +indefensible +indefinite +indefinitely +indefiniteness +indelible +indemnify +indemnity +indent +indentation +indentations +indented +indenting +indents +indenture +independence +independent +independently +indescribable +indestructible +indeterminacies +indeterminacy +indeterminate +indeterminately +index +indexable +indexed +indexes +indexing +India +Indian +Indiana +Indianapolis +Indians +indicate +indicated +indicates +indicating +indication +indications +indicative +indicator +indicators +indices +indict +indictment +indictments +Indies +indifference +indifferent +indifferently +indigenous +indigenously +indigenousness +indigestible +indigestion +indignant +indignantly +indignation +indignities +indignity +indigo +Indira +indirect +indirected +indirecting +indirection +indirections +indirectly +indirects +indiscreet +indiscretion +indiscriminate +indiscriminately +indispensability +indispensable +indispensably +indisputable +indistinct +indistinguishable +individual +individualism +individualistic +individuality +individualize +individualized +individualizes +individualizing +individually +individuals +indivisibility +indivisible +Indo +Indochina +Indochinese +indoctrinate +indoctrinated +indoctrinates +indoctrinating +indoctrination +Indoeuropean +indolent +indolently +indomitable +Indonesia +Indonesian +indoor +indoors +indubitable +induce +induced +inducement +inducements +inducer +induces +inducing +induct +inductance +inductances +inducted +inductee +inducting +induction +inductions +inductive +inductively +inductor +inductors +inducts +indulge +indulged +indulgence +indulgences +indulgent +indulging +Indus +industrial +industrialism +industrialist +industrialists +industrialization +industrialized +industrially +industrials +industries +industrious +industriously +industriousness +industry +Indy +ineffective +ineffectively +ineffectiveness +ineffectual +inefficiencies +inefficiency +inefficient +inefficiently +inelegant +ineligible +inept +inequalities +inequality +inequitable +inequity +inert +inertia +inertial +inertly +inertness +inescapable +inescapably +inessential +inestimable +inevitabilities +inevitability +inevitable +inevitably +inexact +inexcusable +inexcusably +inexhaustible +inexorable +inexorably +inexpensive +inexpensively +inexperience +inexperienced +inexplicable +infallibility +infallible +infallibly +infamous +infamously +infamy +infancy +infant +infantile +infantry +infantryman +infantrymen +infants +infarct +infatuate +infeasible +infect +infected +infecting +infection +infections +infectious +infectiously +infective +infects +infer +inference +inferences +inferential +inferior +inferiority +inferiors +infernal +infernally +inferno +infernos +inferred +inferring +infers +infertile +infest +infested +infesting +infests +infidel +infidelity +infidels +infighting +infiltrate +infinite +infinitely +infiniteness +infinitesimal +infinitive +infinitives +infinitude +infinitum +infinity +infirm +infirmary +infirmity +infix +inflame +inflamed +inflammable +inflammation +inflammatory +inflatable +inflate +inflated +inflater +inflates +inflating +inflation +inflationary +inflexibility +inflexible +inflict +inflicted +inflicting +inflicts +inflow +influence +influenced +influences +influencing +influential +influentially +influenza +inform +informal +informality +informally +informant +informants +Informatica +information +informational +informative +informatively +informed +informer +informers +informing +informs +infra +infrared +infrastructure +infrequent +infrequently +infringe +infringed +infringement +infringements +infringes +infringing +infuriate +infuriated +infuriates +infuriating +infuriation +infuse +infused +infuses +infusing +infusion +infusions +ingenious +ingeniously +ingeniousness +ingenuity +ingenuous +Ingersoll +ingest +ingestion +inglorious +ingot +Ingram +ingrate +ingratiate +ingratitude +ingredient +ingredients +ingrown +inhabit +inhabitable +inhabitance +inhabitant +inhabitants +inhabited +inhabiting +inhabits +inhale +inhaled +inhaler +inhales +inhaling +inhere +inherent +inherently +inheres +inherit +inheritable +inheritance +inheritances +inherited +inheriting +inheritor +inheritors +inheritress +inheritresses +inheritrices +inheritrix +inherits +inhibit +inhibited +inhibiting +inhibition +inhibitions +inhibitor +inhibitors +inhibitory +inhibits +inhomogeneities +inhomogeneity +inhomogeneous +inhospitable +inhuman +inhumane +inimical +inimitable +iniquities +iniquity +initial +initialed +initialing +initialization +initializations +initialize +initialized +initializer +initializers +initializes +initializing +initially +initials +initiate +initiated +initiates +initiating +initiation +initiations +initiative +initiatives +initiator +initiators +inject +injected +injecting +injection +injections +injective +injects +injudicious +Injun +injunction +injunctions +Injuns +injure +injured +injures +injuries +injuring +injurious +injury +injustice +injustices +ink +inked +inker +inkers +inking +inkings +inkling +inklings +inks +inlaid +inland +inlay +inlet +inlets +inline +Inman +inmate +inmates +inn +innards +innate +innately +inner +innermost +inning +innings +innocence +innocent +innocently +innocents +innocuous +innocuously +innocuousness +innovate +innovation +innovations +innovative +inns +innuendo +innumerability +innumerable +innumerably +inoculate +inoperable +inoperative +inopportune +inordinate +inordinately +inorganic +input +inputs +inquest +inquire +inquired +inquirer +inquirers +inquires +inquiries +inquiring +inquiry +inquisition +inquisitions +inquisitive +inquisitively +inquisitiveness +inroad +inroads +insane +insanely +insanity +insatiable +inscribe +inscribed +inscribes +inscribing +inscription +inscriptions +inscrutable +insect +insecticide +insects +insecure +insecurely +inseminate +insensible +insensitive +insensitively +insensitivity +inseparable +insert +inserted +inserting +insertion +insertions +inserts +inset +inside +insider +insiders +insides +insidious +insidiously +insidiousness +insight +insightful +insights +insignia +insignificance +insignificant +insincere +insincerity +insinuate +insinuated +insinuates +insinuating +insinuation +insinuations +insipid +insist +insisted +insistence +insistent +insistently +insisting +insists +insofar +insolence +insolent +insolently +insoluble +insolvable +insolvent +insomnia +insomniac +inspect +inspected +inspecting +inspection +inspections +inspector +inspectors +inspects +inspiration +inspirations +inspire +inspired +inspirer +inspires +inspiring +instabilities +instability +install +installation +installations +installed +installer +installers +installing +installment +installments +installs +instance +instances +instant +instantaneous +instantaneously +instanter +instantiate +instantiated +instantiates +instantiating +instantiation +instantiations +instantly +instants +instead +instigate +instigated +instigates +instigating +instigator +instigators +instill +instinct +instinctive +instinctively +instincts +instinctual +institute +instituted +instituter +instituters +institutes +instituting +institution +institutional +institutionalize +institutionalized +institutionalizes +institutionalizing +institutionally +institutions +instruct +instructed +instructing +instruction +instructional +instructions +instructive +instructively +instructor +instructors +instructs +instrument +instrumental +instrumentalist +instrumentalists +instrumentally +instrumentals +instrumentation +instrumented +instrumenting +instruments +insubordinate +insufferable +insufficient +insufficiently +insular +insulate +insulated +insulates +insulating +insulation +insulator +insulators +insulin +insult +insulted +insulting +insults +insuperable +insupportable +insurance +insure +insured +insurer +insurers +insures +insurgent +insurgents +insuring +insurmountable +insurrection +insurrections +intact +intangible +intangibles +integer +integers +integrable +integral +integrals +integrand +integrate +integrated +integrates +integrating +integration +integrations +integrative +integrity +Intel +intellect +intellects +intellectual +intellectually +intellectuals +intelligence +intelligent +intelligently +intelligentsia +intelligibility +intelligible +intelligibly +Intelsat +intemperate +intend +intended +intending +intends +intense +intensely +intensification +intensified +intensifier +intensifiers +intensifies +intensify +intensifying +intensities +intensity +intensive +intensively +intent +intention +intentional +intentionally +intentioned +intentions +intently +intentness +intents +inter +interact +interacted +interacting +interaction +interactions +interactive +interactively +interactivity +interacts +intercept +intercepted +intercepting +interception +interceptor +intercepts +interchange +interchangeability +interchangeable +interchangeably +interchanged +interchanger +interchanges +interchanging +interchangings +interchannel +intercity +intercom +intercommunicate +intercommunicated +intercommunicates +intercommunicating +intercommunication +interconnect +interconnected +interconnecting +interconnection +interconnections +interconnects +intercontinental +intercourse +Interdata +interdependence +interdependencies +interdependency +interdependent +interdict +interdiction +interdisciplinary +interest +interested +interesting +interestingly +interests +interface +interfaced +interfacer +interfaces +interfacing +interfere +interfered +interference +interferences +interferes +interfering +interferingly +interferometer +interferometric +interferometry +interframe +intergroup +interim +interior +interiors +interject +interlace +interlaced +interlaces +interlacing +interleave +interleaved +interleaves +interleaving +interlink +interlinked +interlinks +interlisp +intermediary +intermediate +intermediates +interminable +intermingle +intermingled +intermingles +intermingling +intermission +intermittent +intermittently +intermix +intermixed +intermodule +intern +internal +internalize +internalized +internalizes +internalizing +internally +internals +international +internationality +internationally +interned +INTERNET +Internet +internetwork +interning +interns +internship +interoffice +interpersonal +interplay +Interpol +interpolate +interpolated +interpolates +interpolating +interpolation +interpolations +interpose +interposed +interposes +interposing +interpret +interpretable +interpretation +interpretations +interpreted +interpreter +interpreters +interpreting +interpretive +interpretively +interprets +interprocess +interrelate +interrelated +interrelates +interrelating +interrelation +interrelations +interrelationship +interrelationships +interrogate +interrogated +interrogates +interrogating +interrogation +interrogations +interrogative +interrupt +interrupted +interruptible +interrupting +interruption +interruptions +interruptive +interrupts +intersect +intersected +intersecting +intersection +intersections +intersects +intersperse +interspersed +intersperses +interspersing +interspersion +interstage +interstate +intertwine +intertwined +intertwines +intertwining +interval +intervals +intervene +intervened +intervenes +intervening +intervention +interventions +interview +interviewed +interviewee +interviewer +interviewers +interviewing +interviews +interwoven +intestate +intestinal +intestine +intestines +intimacy +intimate +intimated +intimately +intimating +intimation +intimations +intimidate +intimidated +intimidates +intimidating +intimidation +into +intolerable +intolerably +intolerance +intolerant +intonation +intonations +intone +intoxicant +intoxicate +intoxicated +intoxicating +intoxication +intractability +intractable +intractably +intragroup +intraline +intramural +intramuscular +intransigent +intransitive +intransitively +intraoffice +intraprocess +intrastate +intravenous +intrepid +intricacies +intricacy +intricate +intricately +intrigue +intrigued +intrigues +intriguing +intrinsic +intrinsically +introduce +introduced +introduces +introducing +introduction +introductions +introductory +introspect +introspection +introspections +introspective +introvert +introverted +intrude +intruded +intruder +intruders +intrudes +intruding +intrusion +intrusions +intrust +intubate +intubated +intubates +intubation +intuition +intuitionist +intuitions +intuitive +intuitively +inundate +invade +invaded +invader +invaders +invades +invading +invalid +invalidate +invalidated +invalidates +invalidating +invalidation +invalidations +invalidities +invalidity +invalidly +invalids +invaluable +invariable +invariably +invariance +invariant +invariantly +invariants +invasion +invasions +invective +invent +invented +inventing +invention +inventions +inventive +inventively +inventiveness +inventor +inventories +inventors +inventory +invents +Inverness +inverse +inversely +inverses +inversion +inversions +invert +invertebrate +invertebrates +inverted +inverter +inverters +invertible +inverting +inverts +invest +invested +investigate +investigated +investigates +investigating +investigation +investigations +investigative +investigator +investigators +investigatory +investing +investment +investments +investor +investors +invests +inveterate +invigorate +invincible +invisibility +invisible +invisibly +invitation +invitations +invite +invited +invites +inviting +invocable +invocation +invocations +invoice +invoiced +invoices +invoicing +invoke +invoked +invoker +invokes +invoking +involuntarily +involuntary +involve +involved +involvement +involvements +involves +involving +inward +inwardly +inwardness +inwards +Io +iodine +ion +Ionian +Ionians +Ionicization +Ionicizations +Ionicize +Ionicizes +ionosphere +ionospheric +ions +iota +Iowa +Ira +Iran +Iranian +Iranians +Iranize +Iranizes +Iraq +Iraqi +Iraqis +irate +irately +irateness +ire +Ireland +Irene +ires +iris +Irish +Irishize +Irishizes +Irishman +Irishmen +irk +irked +irking +irks +irksome +Irma +iron +ironed +ironic +ironical +ironically +ironies +ironing +ironings +irons +irony +Iroquois +irradiate +irrational +irrationally +irrationals +Irrawaddy +irreconcilable +irrecoverable +irreducible +irreducibly +irreflexive +irrefutable +irregular +irregularities +irregularity +irregularly +irregulars +irrelevance +irrelevances +irrelevant +irrelevantly +irreplaceable +irrepressible +irreproducibility +irreproducible +irresistible +irrespective +irrespectively +irresponsible +irresponsibly +irretrievably +irreverent +irreversibility +irreversible +irreversibly +irrevocable +irrevocably +irrigate +irrigated +irrigates +irrigating +irrigation +irritable +irritant +irritate +irritated +irritates +irritating +irritation +irritations +Irvin +Irvine +Irving +Irwin +is +Isaac +Isaacs +Isaacson +Isabel +Isabella +Isadore +Isaiah +Isfahan +Ising +Isis +Islam +Islamabad +Islamic +Islamization +Islamizations +Islamize +Islamizes +island +islander +islanders +Islandia +islands +isle +isles +islet +islets +isolate +isolated +isolates +isolating +isolation +isolations +Isolde +isometric +isomorphic +isomorphically +isomorphism +isomorphisms +isotope +isotopes +Israel +Israeli +Israelis +Israelite +Israelites +Israelitize +Israelitizes +issuance +issue +issued +issuer +issuers +issues +issuing +Istanbul +isthmus +Istvan +it +Italian +Italianization +Italianizations +Italianize +Italianizer +Italianizers +Italianizes +Italians +italic +italicize +italicized +italics +Italy +itch +itches +itching +Itel +item +itemization +itemizations +itemize +itemized +itemizes +itemizing +items +iterate +iterated +iterates +iterating +iteration +iterations +iterative +iteratively +iterator +iterators +Ithaca +Ithacan +itineraries +itinerary +Ito +its +itself +Ivan +Ivanhoe +Iverson +ivies +ivory +ivy +Izaak +Izvestia +jab +jabbed +jabbing +Jablonsky +jabs +jack +jackass +jacket +jacketed +jackets +Jackie +jacking +jackknife +Jackman +jackpot +Jackson +Jacksonian +Jacksons +Jacksonville +Jacky +Jacob +Jacobean +Jacobi +Jacobian +Jacobinize +Jacobite +Jacobs +Jacobsen +Jacobson +Jacobus +Jacoby +Jacqueline +Jacques +jade +jaded +Jaeger +jaguar +jail +jailed +jailer +jailers +jailing +jails +Jaime +Jakarta +Jake +Jakes +jam +Jamaica +Jamaican +James +Jameson +Jamestown +jammed +jamming +jams +Jane +Janeiro +Janesville +Janet +Janice +Janis +janitor +janitors +Janos +Jansen +Jansenist +Januaries +January +Janus +Japan +Japanese +Japanization +Japanizations +Japanize +Japanized +Japanizes +Japanizing +jar +jargon +jarred +jarring +jarringly +jars +Jarvin +Jason +Jastrow +jaundice +jaunt +jauntiness +jaunts +jaunty +Java +Javanese +javelin +javelins +jaw +jawbone +jaws +jay +Jaycee +Jaycees +jazz +jazzy +jealous +jealousies +jealously +jealousy +jean +Jeanne +Jeannie +jeans +Jed +jeep +jeeps +jeer +jeers +Jeff +Jefferson +Jeffersonian +Jeffersonians +Jeffrey +Jehovah +jellies +Jello +jelly +jellyfish +Jenkins +Jennie +Jennifer +Jennings +jenny +Jensen +jeopardize +jeopardized +jeopardizes +jeopardizing +jeopardy +Jeremiah +Jeremy +Jeres +Jericho +jerk +jerked +jerkiness +jerking +jerkings +jerks +jerky +Jeroboam +Jerome +Jerry +jersey +jerseys +Jerusalem +Jesse +Jessica +Jessie +Jessy +jest +jested +jester +jesting +jests +Jesuit +Jesuitism +Jesuitize +Jesuitized +Jesuitizes +Jesuitizing +Jesuits +Jesus +jet +jetliner +jets +jetted +jetting +Jew +jewel +jeweled +jeweler +Jewell +Jewelled +jewelries +jewelry +jewels +Jewett +Jewish +Jewishness +Jews +jiffy +jig +jigs +jigsaw +Jill +Jim +Jimenez +Jimmie +jingle +jingled +jingling +Jinny +jitter +jitterbug +jittery +Jo +Joan +Joanna +Joanne +Joaquin +job +Jobrel +jobs +jockey +jockstrap +jocund +Jody +Joe +Joel +Joes +jog +jogging +jogs +Johann +Johanna +Johannes +Johannesburg +Johansen +Johanson +John +Johnnie +Johnny +Johns +Johnsen +Johnson +Johnston +Johnstown +join +joined +joiner +joiners +joining +joins +joint +jointly +joints +joke +joked +joker +jokers +jokes +joking +jokingly +Joliet +Jolla +jolly +jolt +jolted +jolting +jolts +Jon +Jonas +Jonathan +Jonathanization +Jonathanizations +Jones +Joneses +jonquil +Joplin +Jordan +Jordanian +Jorge +Jorgensen +Jorgenson +Jose +Josef +Joseph +Josephine +Josephson +Josephus +Joshua +Josiah +jostle +jostled +jostles +jostling +jot +jots +jotted +jotting +joule +journal +journalism +journalist +journalists +journalize +journalized +journalizes +journalizing +journals +journey +journeyed +journeying +journeyings +journeyman +journeymen +journeys +joust +jousted +jousting +jousts +Jovanovich +Jove +jovial +Jovian +joy +Joyce +joyful +joyfully +joyous +joyously +joyousness +joyride +joys +joystick +Juan +Juanita +Jubal +jubilee +Judaica +Judaism +Judas +Judd +Judder +Juddered +Juddering +Judders +Jude +Judea +judge +judged +judges +judging +judgment +judgments +judicial +judiciary +judicious +judiciously +Judith +judo +Judson +Judy +jug +juggle +juggler +jugglers +juggles +juggling +Jugoslavia +jugs +juice +juices +juiciest +juicy +Jukes +Jules +Julia +Julian +Julie +Julies +Juliet +Julio +Julius +July +jumble +jumbled +jumbles +jumbo +jump +jumped +jumper +jumpers +jumping +jumps +jumpy +junction +junctions +juncture +junctures +June +Juneau +Junes +Jung +Jungian +jungle +jungles +junior +juniors +juniper +junk +junker +junkers +junks +junky +Juno +junta +Jupiter +Jura +Juras +Jurassic +jure +juries +jurisdiction +jurisdictions +jurisprudence +jurist +juror +jurors +jury +just +justice +justices +justifiable +justifiably +justification +justifications +justified +justifier +justifiers +justifies +justify +justifying +Justine +Justinian +justly +justness +jut +Jutish +Jutland +jutting +juvenile +juveniles +juxtapose +juxtaposed +juxtaposes +juxtaposing +Kabuki +Kabul +Kaddish +Kafka +Kafkaesque +Kahn +Kajar +Kalamazoo +Kali +Kalmuk +Kamchatka +Kamikaze +Kamikazes +Kampala +Kampuchea +Kanarese +Kane +kangaroo +kanji +Kankakee +Kannada +Kansas +Kant +Kantian +Kaplan +kappa +Karachi +Karamazov +karate +Karen +Karl +Karol +Karp +Kashmir +Kaskaskia +Kate +Katharine +Katherine +Kathleen +Kathy +Katie +Katmandu +Katowice +Katz +Kauffman +Kaufman +Kay +Keaton +Keats +Keegan +keel +keeled +keeling +keels +keen +Keenan +keener +keenest +keenly +keenness +keep +keeper +keepers +keeping +keeps +Keith +Keller +Kelley +Kellogg +Kelly +Kelsey +Kelvin +Kemp +ken +Kendall +Kenilworth +Kennan +Kennecott +Kennedy +kennel +kennels +Kenneth +Kenney +Kenning +Kenny +Kenosha +Kensington +Kent +Kenton +Kentucky +Kenya +Kenyon +Kepler +kept +kerchief +kerchiefs +Kermit +kern +kernel +kernels +Kernighan +kerosene +Kerouac +Kerr +Kessler +ketchup +Kettering +kettle +kettles +Kevin +Kewaskum +Kewaunee +key +keyboard +keyboards +keyed +Keyes +keyhole +keying +Keynes +Keynesian +keynote +keypad +keypads +keys +keystroke +keystrokes +keyword +keywords +Khartoum +Khmer +Khrushchev +Khrushchevs +kick +Kickapoo +kicked +kicker +kickers +kicking +kickoff +kicks +kid +Kidde +kidded +kiddie +kidding +kidnap +kidnapper +kidnappers +kidnapping +kidnappings +kidnaps +kidney +kidneys +kids +Kieffer +Kiel +Kiev +Kiewit +Kigali +Kikuyu +Kilgore +Kilimanjaro +kill +Killebrew +killed +killer +killers +killing +killingly +killings +killjoy +kills +kilobit +kilobits +kiloblock +kilobyte +kilobytes +kilogram +kilograms +kilohertz +kilohm +kilojoule +kilometer +kilometers +kiloton +kilovolt +kilowatt +kiloword +Kim +Kimball +Kimberly +kimono +kin +kind +kinder +kindergarten +kindest +kindhearted +kindle +kindled +kindles +kindling +kindly +kindness +kindred +kinds +kinetic +king +kingdom +kingdoms +kingly +kingpin +kings +Kingsbury +Kingsley +Kingston +Kingstown +Kingwood +kink +kinky +Kinney +Kinnickinnic +Kinsey +Kinshasha +kinship +kinsman +kiosk +Kiowa +Kipling +Kirby +Kirchner +Kirchoff +Kirk +Kirkland +Kirkpatrick +Kirkwood +Kirov +kiss +kissed +kisser +kissers +kisses +kissing +kit +Kitakyushu +kitchen +kitchenette +kitchens +kite +kited +kites +kiting +kits +kitten +kittenish +kittens +kitty +Kiwanis +Klan +Klaus +klaxon +Klein +Kleinrock +Kline +kludge +kludges +Klux +klystron +knack +Knapp +knapsack +knapsacks +Knauer +knave +knaves +knead +kneads +knee +kneecap +kneed +kneeing +kneel +kneeled +kneeling +kneels +knees +knell +knells +knelt +knew +Knickerbocker +Knickerbockers +knife +knifed +knifes +knifing +knight +knighted +knighthood +knighting +knightly +knights +Knightsbridge +knit +knits +knives +knob +Knobeloch +knobs +knock +knockdown +knocked +knocker +knockers +knocking +knockout +knocks +knoll +knolls +Knossos +knot +knots +Knott +knotted +knotting +know +knowable +knower +knowhow +knowing +knowingly +knowledge +knowledgeable +Knowles +Knowlton +known +knows +Knox +Knoxville +knuckle +knuckled +knuckles +Knudsen +Knudson +Knuth +Knutsen +Knutson +koala +Kobayashi +Koch +Kochab +Kodachrome +Kodak +Kodiak +Koenig +Koenigsberg +Kohler +Kong +Konrad +Koppers +Koran +Korea +Korean +Koreans +kosher +Kovacs +Kowalewski +Kowalski +Kowloon +Kowtow +Kraemer +Krakatoa +Krakow +Kramer +Krause +Krebs +Kremlin +Kresge +Krieger +Krishna +Kristin +Kronecker +Krueger +Kruger +Kruse +Ku +Kuala +kudo +Kuenning +Kuhn +Kumar +Kurd +Kurdish +Kurt +Kuwait +Kuwaiti +Kyoto +lab +Laban +label +labeled +labeling +labelled +labeller +labellers +labelling +labels +labor +laboratories +laboratory +labored +laborer +laborers +laboring +laborings +laborious +laboriously +labors +Labrador +labs +labyrinth +labyrinths +Lac +lace +laced +lacerate +lacerated +lacerates +lacerating +laceration +lacerations +Lacerta +laces +Lacey +Lachesis +lacing +lack +Lackawanna +lacked +lackey +lacking +lacks +lacquer +lacquered +lacquers +lacrosse +lacy +lad +ladder +laden +ladies +lading +ladle +lads +lady +ladylike +Lafayette +lag +lager +lagers +lagoon +lagoons +Lagos +Lagrange +Lagrangian +lags +Laguerre +Laguna +Lahore +laid +Laidlaw +lain +lair +lairs +laissez +lake +Lakehurst +lakes +Lakewood +Lamar +Lamarck +lamb +lambda +lambdas +lambert +lambs +lame +lamed +lamely +lameness +lament +lamentable +lamentation +lamentations +lamented +lamenting +laments +lames +laminar +laming +lamp +lamplight +lampoon +Lamport +lamprey +lamps +Lana +Lancashire +Lancaster +lance +lanced +Lancelot +lancer +lances +land +landed +lander +landers +landfill +landing +landings +Landis +landladies +landlady +landlord +landlords +landmark +landmarks +landowner +landowners +lands +landscape +landscaped +landscapes +landscaping +landslide +Landwehr +lane +lanes +Lang +Lange +Langeland +Langford +Langley +Langmuir +language +languages +languid +languidly +languidness +languish +languished +languishes +languishing +Lanka +Lansing +lantern +lanterns +Lao +Laocoon +Laos +Laotian +Laotians +lap +lapel +lapels +Laplace +Laplacian +lapping +laps +lapse +lapsed +lapses +lapsing +Laramie +lard +larder +Laredo +Lares +large +largely +largeness +larger +largest +lark +Larkin +larks +Larry +Lars +Larsen +Larson +larva +larvae +larynx +lascivious +laser +lasers +lash +lashed +lashes +lashing +lashings +lass +lasses +lasso +last +lasted +lasting +lastly +lasts +Laszlo +latch +latched +latches +latching +late +lately +latency +lateness +latent +later +lateral +laterally +Lateran +latest +LaTeX +lathe +Lathrop +Latin +Latinate +Latinity +Latinization +Latinizations +Latinize +Latinized +Latinizer +Latinizers +Latinizes +Latinizing +latitude +latitudes +latrine +latrines +Latrobe +latter +latterly +lattice +lattices +Lattimer +Latvia +laudable +Lauderdale +Laue +laugh +laughable +laughably +laughed +laughing +laughingly +laughingstock +Laughlin +laughs +laughter +launch +launched +launcher +launches +launching +launchings +launder +laundered +launderer +laundering +launderings +launders +Laundromat +Laundromats +laundry +laureate +laurel +laurels +Lauren +Laurence +Laurent +Laurentian +Laurie +Lausanne +lava +lavatories +lavatory +lavender +lavish +lavished +lavishing +lavishly +Lavoisier +law +lawbreaker +Lawford +lawful +lawfully +lawgiver +lawless +lawlessness +lawn +lawns +Lawrence +Lawrenceville +laws +Lawson +lawsuit +lawsuits +lawyer +lawyers +lax +laxative +lay +layer +layered +layering +layers +laying +layman +laymen +layoff +layoffs +layout +layouts +lays +Layton +Lazarus +lazed +lazier +laziest +lazily +laziness +lazing +lazy +lazybones +lead +leaded +leaden +leader +leaders +leadership +leaderships +leading +leadings +leads +leaf +leafed +leafiest +leafing +leafless +leaflet +leaflets +leafy +league +leagued +leaguer +leaguers +leagues +leak +leakage +leakages +leaked +leaking +leaks +leaky +lean +Leander +leaned +leaner +leanest +leaning +leanness +leans +leap +leaped +leapfrog +leaping +leaps +leapt +Lear +learn +learned +learner +learners +learning +learns +Leary +lease +leased +leases +leash +leashes +leasing +least +leather +leathered +leathern +leatherneck +leathers +leave +leaved +leaven +leavened +leavening +Leavenworth +leaves +leaving +leavings +Lebanese +Lebanon +Lebesgue +lechery +lecture +lectured +lecturer +lecturers +lectures +lecturing +led +ledge +ledger +ledgers +ledges +lee +leech +leeches +Leeds +leek +leer +leery +lees +Leeuwenhoek +leeward +leeway +left +leftist +leftists +leftmost +leftover +leftovers +leftward +leg +legacies +legacy +legal +legality +legalization +legalize +legalized +legalizes +legalizing +legally +legend +legendary +Legendre +legends +Leger +Legers +legged +leggings +legibility +legible +legibly +legion +legions +legislate +legislated +legislates +legislating +legislation +legislative +legislator +legislators +legislature +legislatures +legitimacy +legitimate +legitimately +legs +legume +Lehigh +Lehman +Leibniz +Leiden +Leigh +Leighton +Leila +Leipzig +leisure +leisurely +Leland +Lemke +lemma +lemmas +lemming +lemmings +lemon +lemonade +lemons +Lemuel +Len +Lena +lend +lender +lenders +lending +lends +length +lengthen +lengthened +lengthening +lengthens +lengthly +lengths +lengthwise +lengthy +leniency +lenient +leniently +Lenin +Leningrad +Leninism +Leninist +Lennox +Lenny +Lenore +lens +lenses +lent +Lenten +lentil +lentils +Leo +Leon +Leona +Leonard +Leonardo +Leone +Leonid +leopard +leopards +Leopold +Leopoldville +leper +leprosy +Leroy +Lesbian +Lesbians +Leslie +Lesotho +less +lessen +lessened +lessening +lessens +lesser +lesson +lessons +lessor +lest +Lester +let +lethal +Lethe +Letitia +lets +letter +lettered +letterer +letterhead +lettering +letters +letting +lettuce +leukemia +Lev +levee +levees +level +leveled +leveler +leveling +levelled +leveller +levellest +levelling +levelly +levelness +levels +lever +leverage +levers +Levi +Leviable +levied +levies +Levin +Levine +Levis +Leviticus +Levitt +levity +levy +levying +Lew +lewd +lewdly +lewdness +Lewellyn +lexical +lexically +lexicographic +lexicographical +lexicographically +lexicon +lexicons +Lexington +Leyden +liabilities +liability +liable +liaison +liaisons +liar +liars +libel +libelous +Liberace +liberal +liberalize +liberalized +liberalizes +liberalizing +liberally +liberals +liberate +liberated +liberates +liberating +liberation +liberator +liberators +Liberia +libertarian +liberties +liberty +libido +librarian +librarians +libraries +library +libretto +Libreville +Libya +Libyan +lice +license +licensed +licensee +licenses +licensing +licensor +licentious +lichen +lichens +Lichter +lick +licked +licking +licks +licorice +lid +lids +lie +Lieberman +Liechtenstein +lied +liege +lien +liens +lies +lieu +lieutenant +lieutenants +life +lifeblood +lifeboat +lifeguard +lifeless +lifelessness +lifelike +lifelong +lifer +lifespan +lifestyle +lifestyles +lifetime +lifetimes +lift +lifted +lifter +lifters +lifting +lifts +ligament +ligature +Ligget +Liggett +light +lighted +lighten +lightens +lighter +lighters +lightest +lightface +lighthearted +lighthouse +lighthouses +lighting +lightly +lightness +lightning +lightnings +lights +lightweight +like +liked +likelier +likeliest +likelihood +likelihoods +likeliness +likely +liken +likened +likeness +likenesses +likening +likens +likes +likewise +liking +Lila +lilac +lilacs +Lilian +lilies +Lillian +Lilliput +Lilliputian +Lilliputianize +Lilliputianizes +Lilly +lily +Lima +Liman +limb +limber +limbo +limbs +lime +limelight +Limerick +limes +limestone +limit +limitability +limitably +limitation +limitations +limited +limiter +limiters +limiting +limitless +limits +limousine +limp +limped +limping +limply +limpness +limps +Lin +Lincoln +Lind +Linda +Lindberg +Lindbergh +linden +Lindholm +Lindquist +Lindsay +Lindsey +Lindstrom +Lindy +line +linear +linearities +linearity +linearizable +linearize +linearized +linearizes +linearizing +linearly +lined +linen +linens +liner +liners +lines +lineup +linger +lingered +lingerie +lingering +lingers +lingo +lingua +linguist +linguistic +linguistically +linguistics +linguists +lining +linings +link +linkage +linkages +linked +linker +linkers +linking +links +Linnaeus +linoleum +Linotype +linseed +lint +Linton +Linus +Linux +lion +Lionel +lioness +lionesses +lions +lip +Lippincott +lips +Lipschitz +Lipscomb +lipstick +Lipton +liquid +liquidate +liquidation +liquidations +liquidity +liquids +liquor +liquors +Lisa +Lisbon +Lise +lisp +lisped +lisping +lisps +Liss +Lissajous +list +listed +listen +listened +listener +listeners +listening +listens +Lister +Listerize +Listerizes +listers +listing +listings +listless +Liston +lists +lit +litany +liter +literacy +literal +literally +literalness +literals +literary +literate +literature +literatures +liters +lithe +lithograph +lithography +Lithuania +Lithuanian +litigant +litigate +litigation +litigious +litmus +litter +litterbug +littered +littering +litters +little +littleness +littler +littlest +Littleton +Litton +livable +livably +live +lived +livelihood +lively +liveness +liver +liveried +Livermore +Liverpool +Liverpudlian +livers +livery +lives +livestock +livid +living +Livingston +Liz +lizard +lizards +Lizzie +Lizzy +Lloyd +load +loaded +loader +loaders +loading +loadings +loads +loaf +loafed +loafer +loan +loaned +loaning +loans +loath +loathe +loathed +loathing +loathly +loathsome +loaves +lobbied +lobbies +lobby +lobbying +lobe +lobes +lobster +lobsters +local +localities +locality +localization +localize +localized +localizes +localizing +locally +locals +locate +located +locates +locating +location +locations +locative +locatives +locator +locators +loci +lock +Locke +locked +locker +lockers +Lockhart +Lockheed +Lockian +locking +lockings +lockout +lockouts +locks +locksmith +lockstep +lockup +lockups +Lockwood +locomotion +locomotive +locomotives +locus +locust +locusts +lodge +lodged +lodger +lodges +lodging +lodgings +Lodowick +Loeb +loft +loftiness +lofts +lofty +Logan +logarithm +logarithmic +logarithmically +logarithms +logged +logger +loggers +logging +logic +logical +logically +logician +logicians +logics +login +logins +logistic +logistics +logjam +logo +logs +loin +loincloth +loins +Loire +Lois +loiter +loitered +loiterer +loitering +loiters +Loki +Lola +Lomb +Lombard +Lombardy +Lome +London +Londonderry +Londoner +Londonization +Londonizations +Londonize +Londonizes +lone +lonelier +loneliest +loneliness +lonely +loner +loners +lonesome +long +longed +longer +longest +longevity +Longfellow +longhand +longing +longings +longitude +longitudes +longs +longstanding +Longstreet +look +lookahead +looked +looker +lookers +looking +lookout +looks +lookup +lookups +loom +loomed +looming +Loomis +looms +loon +loop +looped +loophole +loopholes +looping +loops +loose +loosed +looseleaf +loosely +loosen +loosened +looseness +loosening +loosens +looser +looses +loosest +loosing +loot +looted +looter +looting +loots +Lopez +lopsided +lord +lordly +lords +lordship +lore +Lorelei +Loren +Lorentzian +Lorenz +Loretta +Lorinda +Lorraine +lorry +Los +lose +loser +losers +loses +losing +loss +losses +lossier +lossiest +lossy +lost +lot +Lothario +lotion +lots +Lotte +lottery +Lottie +lotus +Lou +loud +louder +loudest +loudly +loudness +loudspeaker +loudspeakers +Louis +Louisa +Louise +Louisiana +Louisianan +Louisville +lounge +lounged +lounges +lounging +Lounsbury +Lourdes +louse +lousy +lout +Louvre +lovable +lovably +love +loved +Lovejoy +Lovelace +Loveland +lovelier +lovelies +loveliest +loveliness +lovelorn +lovely +lover +lovers +loves +loving +lovingly +low +Lowe +Lowell +lower +lowered +lowering +lowers +lowest +lowland +lowlands +lowliest +lowly +lowness +Lowry +lows +Loy +loyal +loyally +loyalties +loyalty +Loyola +Lubbock +Lubell +lubricant +lubricate +lubrication +Lucas +Lucerne +Lucia +Lucian +lucid +Lucien +Lucifer +Lucille +Lucius +luck +lucked +luckier +luckiest +luckily +luckless +lucks +lucky +lucrative +Lucretia +Lucretius +Lucy +ludicrous +ludicrously +ludicrousness +Ludlow +Ludmilla +Ludwig +Lufthansa +Luftwaffe +luggage +Luis +Luke +lukewarm +lull +lullaby +lulled +lulls +lumber +lumbered +lumbering +luminous +luminously +lummox +lump +lumped +lumping +lumps +Lumpur +lumpy +lunar +lunatic +lunch +lunched +luncheon +luncheons +lunches +lunching +Lund +Lundberg +Lundquist +lung +lunged +lungs +Lura +lurch +lurched +lurches +lurching +lure +lured +lures +luring +lurk +lurked +lurking +lurks +Lusaka +luscious +lusciously +lusciousness +lush +lust +luster +lustful +lustily +lustiness +lustrous +lusts +lusty +lute +lutes +Luther +Lutheran +Lutheranize +Lutheranizer +Lutheranizers +Lutheranizes +Lutz +Luxembourg +Luxemburg +luxuriant +luxuriantly +luxuries +luxurious +luxuriously +luxury +Luzon +L'vov +Lydia +lying +Lykes +Lyle +Lyman +lymph +lynch +Lynchburg +lynched +lyncher +lynches +Lyndon +Lynn +lynx +lynxes +Lyon +Lyons +Lyra +lyre +lyric +lyrics +Lysenko +Mabel +Mac +Macadamia +MacArthur +Macarthur +Macassar +Macaulay +Macaulayan +Macaulayism +Macaulayisms +Macbeth +MacDonald +Macdonald +MacDougall +Macdougall +MacDraw +mace +maced +Macedon +Macedonia +Macedonian +maces +MacGregor +Macgregor +Mach +Machiavelli +Machiavellian +machination +machine +machined +machinelike +machinery +machines +machining +macho +MacIntosh +Macintosh +macintosh +MacKenzie +Mackenzie +mackerel +Mackey +Mackinac +Mackinaw +MacMahon +MacMillan +Macmillan +Macon +MacPaint +macro +macroeconomics +macromolecule +macromolecules +macrophage +macros +macroscopic +mad +Madagascar +madam +Madame +Madames +madden +maddening +madder +maddest +Maddox +made +Madeira +Madeleine +Madeline +madhouse +Madhya +Madison +madly +madman +madmen +madness +Madonna +Madonnas +madras +Madrid +Madsen +Mae +Maelstrom +maestro +Mafia +Mafiosi +magazine +magazines +Magdalene +Magellan +Magellanic +magenta +Maggie +maggot +maggots +magic +magical +magically +magician +magicians +Magill +magistrate +magistrates +magna +magnesium +magnet +magnetic +magnetically +magnetism +magnetisms +magnetizable +magnetized +magneto +magnification +magnificence +magnificent +magnificently +magnified +magnifier +magnifies +magnify +magnifying +magnitude +magnitudes +magnolia +magnum +Magnuson +Magog +magpie +Magruder +Maguire +Maguires +Maharashtra +Mahayana +Mahayanist +mahogany +Mahoney +maid +maiden +maidens +maids +Maier +mail +mailable +mailbox +mailboxes +mailed +mailer +mailing +mailings +mailman +mailmen +mails +maim +maimed +maiming +maims +main +Maine +mainframe +mainframes +mainland +mainline +mainly +mains +mainstay +mainstream +maintain +maintainability +maintainable +maintained +maintainer +maintainers +maintaining +maintains +maintenance +maintenances +maize +majestic +majesties +majesty +major +Majorca +majored +majoring +majorities +majority +majors +makable +make +maker +makers +makes +makeshift +makeup +makeups +making +makings +Malabar +maladies +malady +Malagasy +Malamud +malaria +Malawi +Malay +Malayize +Malayizes +Malaysia +Malaysian +Malcolm +malcontent +Malden +Maldive +male +malefactor +malefactors +maleness +males +malevolent +malformed +malfunction +malfunctioned +malfunctioning +malfunctions +Mali +Malibu +malice +malicious +maliciously +maliciousness +malign +malignant +malignantly +mall +mallard +mallet +mallets +Mallory +malnutrition +Malone +Maloney +malpractice +Malraux +malt +Malta +malted +Maltese +Malthus +Malthusian +Malton +malts +mama +mamma +mammal +mammalian +mammals +mammas +mammoth +man +manage +manageable +manageableness +managed +management +managements +manager +managerial +managers +manages +managing +Managua +Manama +Manchester +Manchuria +mandarin +mandate +mandated +mandates +mandating +mandatory +Mandelbrot +mandible +mane +manes +maneuver +maneuvered +maneuvering +maneuvers +Manfred +manger +mangers +mangle +mangled +mangler +mangles +mangling +Manhattan +Manhattanize +Manhattanizes +manhole +manhood +mania +maniac +maniacal +maniacs +manic +manicure +manicured +manicures +manicuring +manifest +manifestation +manifestations +manifested +manifesting +manifestly +manifests +manifold +manifolds +Manila +manipulability +manipulable +manipulatable +manipulate +manipulated +manipulates +manipulating +manipulation +manipulations +manipulative +manipulator +manipulators +manipulatory +Manitoba +Manitowoc +mankind +Mankowski +Manley +manly +Mann +manned +manner +mannered +mannerly +manners +manning +manometer +manometers +manor +manors +manpower +Mans +Mansfield +mansion +mansions +manslaughter +mantel +mantels +mantis +mantissa +mantissas +mantle +mantlepiece +mantles +manual +manually +manuals +Manuel +manufacture +manufactured +manufacturer +manufacturers +manufactures +manufacturing +manure +manuscript +manuscripts +Manville +many +Mao +Maori +map +maple +Maplecrest +maples +mappable +mapped +mapping +mappings +maps +marathon +marble +marbles +marbling +Marc +Marceau +Marcel +Marcello +march +marched +marcher +marches +marching +Marcia +Marco +Marcotte +Marcus +Marcy +Mardi +Mardis +mare +mares +Margaret +margarine +Margery +margin +marginal +marginally +margins +Margo +Marguerite +Marianne +Marie +Marietta +marigold +marijuana +Marilyn +Marin +marina +marinade +marinate +marine +mariner +marines +Marino +Mario +Marion +marionette +marital +maritime +Marjorie +Marjory +mark +markable +marked +markedly +marker +markers +market +marketability +marketable +marketed +marketing +marketings +marketplace +marketplaces +markets +Markham +marking +markings +Markism +Markov +Markovian +Markovitz +Marks +Marlboro +Marlborough +Marlene +Marlowe +marmalade +marmot +maroon +Marquette +marquis +marriage +marriageable +marriages +married +marries +Marriott +marrow +marry +marrying +Mars +Marseilles +marsh +Marsha +marshal +marshaled +marshaling +Marshall +Marshalled +Marshalling +marshals +marshes +marshmallow +mart +marten +Martha +martial +Martian +Martians +Martinez +martingale +martini +Martinique +Martinson +marts +Marty +martyr +martyrdom +martyrs +marvel +marveled +marvelled +marvelling +marvelous +marvelously +marvelousness +marvels +Marvin +Marx +Marxian +Marxism +Marxisms +Marxist +Mary +Maryland +Marylanders +mascara +masculine +masculinely +masculinity +Maseru +mash +mashed +mashes +mashing +mask +maskable +masked +masker +masking +maskings +masks +masochist +masochists +mason +Masonic +Masonite +masonry +masons +masquerade +masquerader +masquerades +masquerading +mass +Massachusetts +massacre +massacred +massacres +massage +massages +massaging +massed +masses +Massey +massing +massive +mast +masted +master +mastered +masterful +masterfully +mastering +masterings +masterly +mastermind +masterpiece +masterpieces +masters +mastery +mastodon +masts +masturbate +masturbated +masturbates +masturbating +masturbation +mat +match +matchable +matched +matcher +matchers +matches +matching +matchings +matchless +mate +mated +Mateo +mater +material +materialist +materialize +materialized +materializes +materializing +materially +materials +maternal +maternally +maternity +mates +math +Mathematica +mathematical +mathematically +mathematician +mathematicians +mathematics +Mathematik +Mathewson +Mathias +Mathieu +Matilda +mating +matings +Matisse +Matisses +matriarch +matriarchal +matrices +matriculate +matriculation +matrimonial +matrimony +matrix +matroid +matron +matronly +mats +Matson +Matsumoto +Matt +matted +matter +mattered +matters +Matthew +Matthews +Mattie +mattress +mattresses +Mattson +maturation +mature +matured +maturely +matures +maturing +maturities +maturity +Maude +maul +Maureen +Maurice +Mauricio +Maurine +Mauritania +Mauritius +mausoleum +maverick +Mavis +Mawr +Max +maxim +maxima +maximal +maximally +Maximilian +maximize +maximized +maximizer +maximizers +maximizes +maximizing +maxims +maximum +maximums +Maxine +Maxtor +Maxwell +Maxwellian +May +Maya +Mayans +maybe +Mayer +Mayfair +Mayflower +mayhap +mayhem +Maynard +Mayo +mayonnaise +mayor +mayoral +mayors +Mazda +maze +mazes +Mbabane +McAdam +McAdams +McAllister +McBride +McCabe +McCall +McCallum +McCann +McCarthy +McCarty +McCauley +McClain +McClellan +McClure +McCluskey +McConnel +McConnell +McCormick +McCoy +McCracken +McCullough +McDaniel +McDermott +McDonald +McDonnell +McDougall +McDowell +McElhaney +McElroy +McFadden +McFarland +McGee +McGill +McGinnis +McGovern +McGowan +McGrath +McGraw +McGregor +McGuire +McHugh +McIntosh +McIntyre +McKay +McKee +McKenna +McKenzie +McKeon +McKesson +McKinley +McKinney +McKnight +McLanahan +McLaughlin +McLean +McLeod +McMahon +McMartin +McMillan +McMullen +McNally +McNaughton +McNeil +McNulty +McPherson +me +mead +meadow +meadows +meager +meagerly +meagerness +meal +meals +mealtime +mealy +mean +meander +meandered +meandering +meanders +meaner +meanest +meaning +meaningful +meaningfully +meaningfulness +meaningless +meaninglessly +meaninglessness +meanings +meanly +meanness +means +meant +meantime +meanwhile +measle +measles +measurable +measurably +measure +measured +measurement +measurements +measurer +measures +measuring +meat +meats +meaty +Mecca +mechanic +mechanical +mechanically +mechanics +mechanism +mechanisms +mechanization +mechanizations +mechanize +mechanized +mechanizes +mechanizing +medal +medallion +medallions +medals +meddle +meddled +meddler +meddles +meddling +Medea +Medfield +Medford +media +median +medians +mediate +mediated +mediates +mediating +mediation +mediations +mediator +medic +Medicaid +medical +medically +Medicare +Medici +medicinal +medicinally +medicine +medicines +Medicis +medics +medieval +mediocre +mediocrity +meditate +meditated +meditates +meditating +meditation +meditations +meditative +Mediterranean +Mediterraneanization +Mediterraneanizations +Mediterraneanize +Mediterraneanizes +medium +mediums +medley +Medusa +Medusan +meek +meeker +meekest +meekly +meekness +meet +meeting +meetinghouse +meetings +meets +Meg +megabaud +megabit +megabits +megabyte +megabytes +megahertz +megalomania +megaton +megavolt +megawatt +megaword +megawords +megohm +Meier +Meiji +Meister +Meistersinger +Mekong +Mel +Melampus +melancholy +Melanesia +Melanesian +Melanie +Melbourne +Melcher +Melinda +Melisande +Melissa +Mellon +mellow +mellowed +mellowing +mellowness +mellows +melodies +melodious +melodiously +melodiousness +melodrama +melodramas +melodramatic +melody +melon +melons +Melpomene +melt +melted +melting +meltingly +melts +Melville +Melvin +member +members +membership +memberships +membrane +memento +memo +memoir +memoirs +memorabilia +memorable +memorableness +memoranda +memorandum +memorial +memorially +memorials +memories +memorization +memorize +memorized +memorizer +memorizes +memorizing +memory +memoryless +memos +Memphis +men +menace +menaced +menacing +menagerie +menarche +Mencken +mend +mendacious +mendacity +mended +Mendel +Mendelian +Mendelize +Mendelizes +Mendelssohn +mender +mending +Mendoza +mends +Menelaus +menial +menials +Menlo +Mennonite +Mennonites +Menominee +Menorca +mens +Mensch +menstruate +mensurable +mensuration +mental +mentalities +mentality +mentally +mention +mentionable +mentioned +mentioner +mentioners +mentioning +mentions +mentor +mentors +menu +menus +Menzies +Mephistopheles +mercantile +Mercator +Mercedes +mercenaries +mercenariness +mercenary +merchandise +merchandiser +merchandising +merchant +merchants +merciful +mercifully +merciless +mercilessly +Merck +mercurial +mercury +mercy +mere +Meredith +merely +merest +merge +merged +merger +mergers +merges +merging +meridian +meringue +merit +merited +meriting +meritorious +meritoriously +meritoriousness +merits +Meriwether +Merle +mermaid +Merriam +Merrick +merriest +Merrill +merrily +Merrimac +Merrimack +merriment +Merritt +merry +Merrymake +Mervin +mescaline +mesh +meson +Mesopotamia +Mesozoic +mesquite +mess +message +messages +messed +messenger +messengers +messes +Messiah +messiahs +messier +messiest +messily +messiness +messing +messy +met +meta +metabolic +metabolism +metacircular +metacircularity +metal +metalanguage +metallic +metallization +metallizations +metallurgy +metals +metamathematical +metamorphosis +metaphor +metaphorical +metaphorically +metaphors +metaphysical +metaphysically +metaphysics +metavariable +Metcalf +mete +meted +meteor +meteoric +meteorite +meteoritic +meteorology +meteors +meter +metering +meters +metes +methane +method +methodical +methodically +methodicalness +Methodism +Methodist +methodists +methodological +methodologically +methodologies +methodologists +methodology +methods +Methuen +Methuselah +Methuselahs +meticulously +meting +Metrecal +metric +metrical +metrics +metro +metronome +metropolis +metropolitan +mets +mettle +mettlesome +Metzler +mew +mewed +mews +Mexican +Mexicanize +Mexicanizes +Mexicans +Mexico +Meyer +Meyers +Miami +miasma +mica +mice +Michael +Michaels +Michel +Michelangelo +Michele +Michelin +Michelson +Michigan +Mick +Mickey +Mickie +Micky +micro +microarchitects +microarchitecture +microarchitectures +microbial +microbicidal +microbicide +microcode +microcoded +microcodes +microcoding +microcomputer +microcomputers +microcosm +microcycle +microcycles +microeconomics +microelectronics +microfilm +microfilms +microgramming +microinstruction +microinstructions +microjump +microjumps +microlevel +micron +Micronesia +Micronesian +microoperations +microphone +microphones +microphoning +Microport +microprocedure +microprocedures +microprocessing +microprocessor +microprocessors +microprogram +microprogrammable +microprogrammed +microprogrammer +microprogramming +microprograms +micros +microscope +microscopes +microscopic +microscopy +microsecond +microseconds +Microsoft +microstore +microsystems +MicroVAX +MicroVAXes +microwave +microwaves +microword +microwords +mid +Midas +midday +middle +Middlebury +middleman +middlemen +middles +Middlesex +Middleton +Middletown +middling +midget +Midlandize +Midlandizes +midnight +midnights +midpoint +midpoints +midrange +midscale +midsection +midshipman +midshipmen +midst +midstream +midsts +midsummer +midway +midweek +Midwest +Midwestern +Midwesterner +Midwesterners +midwife +midwinter +midwives +mien +might +mightier +mightiest +mightily +mightiness +mighty +migrant +migrate +migrated +migrates +migrating +migration +migrations +migratory +Miguel +mike +Mikhail +Mikoyan +Milan +mild +milder +mildest +mildew +mildly +mildness +Mildred +mile +mileage +Miles +milestone +milestones +militant +militantly +militarily +militarism +military +militia +milk +milked +milker +milkers +milkiness +milking +milkmaid +milkmaids +milks +milky +mill +Millard +milled +millennium +miller +millet +milliammeter +milliampere +Millie +millijoule +Millikan +millimeter +millimeters +millinery +milling +Millington +million +millionaire +millionaires +millions +millionth +millipede +millipedes +millisecond +milliseconds +millivolt +millivoltmeter +milliwatt +Mills +millstone +millstones +Milne +Milquetoast +Milquetoasts +Milton +Miltonian +Miltonic +Miltonism +Miltonist +Miltonize +Miltonized +Miltonizes +Miltonizing +Milwaukee +mimeograph +Mimi +mimic +mimicked +mimicking +mimics +minaret +mince +minced +mincemeat +minces +mincing +mind +Mindanao +minded +mindful +mindfully +mindfulness +minding +mindless +mindlessly +minds +mine +mined +minefield +miner +mineral +minerals +miners +Minerva +mines +minesweeper +mingle +mingled +mingles +mingling +mini +miniature +miniatures +miniaturization +miniaturize +miniaturized +miniaturizes +miniaturizing +minicomputer +minicomputers +minima +minimal +minimally +minimax +minimization +minimizations +minimize +minimized +minimizer +minimizers +minimizes +minimizing +minimum +mining +minion +minis +minister +ministered +ministering +ministers +ministries +ministry +mink +minks +Minneapolis +Minnesota +Minnie +minnow +minnows +Minoan +minor +minoring +minorities +minority +minors +Minos +Minotaur +Minsk +Minsky +minstrel +minstrels +mint +minted +minter +minting +mints +minuend +minuet +minus +minuscule +minute +minutely +minuteman +minutemen +minuteness +minuter +minutes +Miocene +MIPS +Mira +miracle +miracles +miraculous +miraculously +mirage +Miranda +mire +mired +mires +Mirfak +Miriam +mirror +mirrored +mirroring +mirrors +mirth +misanthrope +misbehaving +miscalculation +miscalculations +miscarriage +miscarry +miscegenation +miscellaneous +miscellaneously +miscellaneousness +mischief +mischievous +mischievously +mischievousness +misconception +misconceptions +misconduct +misconstrue +misconstrued +misconstrues +misdemeanors +miser +miserable +miserableness +miserably +miseries +miserly +misers +misery +misfit +misfits +misfortune +misfortunes +misgiving +misgivings +misguided +mishap +mishaps +misinformed +misjudged +misjudgment +mislead +misleading +misleads +misled +mismanagement +mismatch +mismatched +mismatches +mismatching +misnomer +misplace +misplaced +misplaces +misplacing +mispronunciation +misrepresentation +misrepresentations +miss +missed +misses +misshapen +missile +missiles +missing +mission +missionaries +missionary +missioner +missions +Mississippi +Mississippian +Mississippians +missive +Missoula +Missouri +misspell +misspelled +misspelling +misspellings +misspells +Missy +mist +mistakable +mistake +mistaken +mistakenly +mistakes +mistaking +misted +mister +misters +mistiness +misting +mistletoe +mistress +mistrust +mistrusted +mists +misty +mistype +mistyped +mistypes +mistyping +misunderstand +misunderstander +misunderstanders +misunderstanding +misunderstandings +misunderstood +misuse +misused +misuses +misusing +Mitch +Mitchell +miter +mitigate +mitigated +mitigates +mitigating +mitigation +mitigative +MITRE +MITREs +mitten +mittens +mix +mixed +mixer +mixers +mixes +mixing +mixture +mixtures +mixup +Mizar +mnemonic +mnemonically +mnemonics +moan +moaned +moans +moat +moats +mob +Mobil +mobile +mobility +mobs +mobster +moccasin +moccasins +mock +mocked +mocker +mockery +mocking +mockingbird +mocks +mockup +modal +modalities +modality +modally +mode +model +modeled +modeling +modelings +models +modem +modems +moderate +moderated +moderately +moderateness +moderates +moderating +moderation +modern +modernity +modernize +modernized +modernizer +modernizing +modernly +modernness +moderns +modes +modest +modestly +Modesto +modesty +modicum +modifiability +modifiable +modification +modifications +modified +modifier +modifiers +modifies +modify +modifying +Modula +Modula-2 +Modula-3 +modular +modularity +modularization +modularize +modularized +modularizes +modularizing +modularly +modulate +modulated +modulates +modulating +modulation +modulations +modulator +modulators +module +modules +moduli +modulo +modulus +modus +Moe +Moen +Mogadiscio +Mogadishu +Moghul +Mohammed +Mohammedan +Mohammedanism +Mohammedanization +Mohammedanizations +Mohammedanize +Mohammedanizes +Mohawk +Mohr +Moines +Moiseyev +moist +moisten +moistly +moistness +moisture +molar +molasses +mold +Moldavia +molded +molder +molding +molds +mole +molecular +molecule +molecules +molehill +moles +molest +molested +molesting +molests +Moliere +Moline +Moll +Mollie +mollify +mollusk +Molly +mollycoddle +Moloch +Molochize +Molochizes +Molotov +molten +Moluccas +moment +momentarily +momentariness +momentary +momentous +momentously +momentousness +moments +momentum +mommy +Mona +Monaco +monadic +monarch +monarchies +monarchs +monarchy +Monash +monasteries +monastery +monastic +Monday +Mondays +Monet +monetarism +monetary +money +moneyed +moneys +Monfort +Mongolia +Mongolian +Mongolianism +mongoose +Monica +monitor +monitored +monitoring +monitors +monk +monkey +monkeyed +monkeying +monkeys +monkish +monks +Monmouth +monoalphabetic +Monoceros +monochromatic +monochrome +monocotyledon +monocular +monogamous +monogamy +monogram +monograms +monograph +monographes +monographs +monolith +monolithic +monologue +Monongahela +monopolies +monopolize +monopolized +monopolizing +monopoly +monoprogrammed +monoprogramming +monostable +monotheism +monotone +monotonic +monotonically +monotonicity +monotonous +monotonously +monotonousness +monotony +Monroe +Monrovia +Monsanto +monsoon +monster +monsters +monstrosity +monstrous +monstrously +Mont +Montague +Montaigne +Montana +Montanan +Montclair +Montenegrin +Montenegro +Monterey +Monteverdi +Montevideo +Montgomery +month +monthly +months +Monticello +Montmartre +Montpelier +Montrachet +Montreal +Monty +monument +monumental +monumentally +monuments +moo +mood +moodiness +moods +moody +Moon +mooned +Mooney +mooning +moonlight +moonlighter +moonlighting +Moonlike +moonlit +moons +moonshine +Moor +Moore +moored +mooring +moorings +Moorish +Moors +moose +moot +mop +moped +mops +moraine +moral +morale +moralities +morality +morally +morals +Moran +morass +moratorium +Moravia +Moravian +Moravianized +Moravianizeds +morbid +morbidly +morbidness +more +Morehouse +Moreland +moreover +mores +Moresby +Morgan +Moriarty +moribund +Morley +Mormon +morn +morning +mornings +Moroccan +Morocco +moron +morose +morphine +morphism +morphisms +morphological +morphology +Morrill +Morris +Morrison +Morrissey +Morristown +morrow +Morse +morsel +morsels +mortal +mortality +mortally +mortals +mortar +mortared +mortaring +mortars +mortem +mortgage +mortgages +mortician +mortification +mortified +mortifies +mortify +mortifying +Mortimer +Morton +mosaic +mosaics +Moscone +Moscow +Moser +Moses +Moslem +Moslemize +Moslemizes +Moslems +mosque +mosquito +mosquitoes +moss +Mossberg +mosses +mossy +most +mostly +motel +motels +moth +mothball +mothballs +mother +mothered +motherer +motherers +motherhood +mothering +motherland +motherly +mothers +motif +motifs +motion +motioned +motioning +motionless +motionlessly +motionlessness +motions +motivate +motivated +motivates +motivating +motivation +motivations +motive +motives +motley +motor +motorcar +motorcars +motorcycle +motorcycles +motoring +motorist +motorists +motorize +motorized +motorizes +motorizing +Motorola +motors +motto +mottoes +mould +moulding +Moulton +mound +mounded +mounds +mount +mountable +mountain +mountaineer +mountaineering +mountaineers +mountainous +mountainously +mountains +mounted +mounter +mounting +mountings +mounts +mourn +mourned +mourner +mourners +mournful +mournfully +mournfulness +mourning +mourns +mouse +mouser +mouses +mousetrap +mousy +mouth +Mouthe +mouthed +mouthes +mouthful +mouthing +mouthpiece +mouths +Mouton +movable +move +moved +movement +movements +mover +movers +moves +movie +movies +moving +movings +mow +mowed +mower +mows +Moyer +Mozart +mu +much +muck +mucker +mucking +mucus +mud +Mudd +muddied +muddiness +muddle +muddled +muddlehead +muddler +muddlers +muddles +muddling +muddy +Mueller +Muenster +muff +muffin +muffins +muffle +muffled +muffler +muffles +muffling +muffs +mug +mugging +mugs +Muhammad +Muir +Mukden +mulatto +mulberries +mulberry +mule +mules +mull +mullah +Mullen +multi +multibit +Multibus +multibyte +multicast +multicasting +multicasts +multicellular +multicomputer +MULTICS +Multics +multidimensional +multilateral +multilayer +multilayered +multilevel +multimedia +multinational +multiple +multiples +multiplex +multiplexed +multiplexer +multiplexers +multiplexes +multiplexing +multiplexor +multiplexors +multiplicand +multiplicands +multiplication +multiplications +multiplicative +multiplicatives +multiplicity +multiplied +multiplier +multipliers +multiplies +multiply +multiplying +multiprocess +multiprocessing +multiprocessor +multiprocessors +multiprogram +multiprogrammed +multiprogramming +multistage +multitude +multitudes +multiuser +multivariate +multiword +mumble +mumbled +mumbler +mumblers +mumbles +mumbling +mumblings +Mumford +mummies +mummy +munch +munched +munching +Muncie +mundane +mundanely +Mundt +mung +Munich +municipal +municipalities +municipality +municipally +munition +munitions +Munroe +Munsey +Munson +Muong +mural +murder +murdered +murderer +murderers +murdering +murderous +murderously +murders +Muriel +murky +murmur +murmured +murmurer +murmuring +murmurs +Murphy +Murray +Murrow +Muscat +muscle +muscled +muscles +muscling +Muscovite +Muscovy +muscular +musculature +muse +mused +muses +museum +museums +mush +mushroom +mushroomed +mushrooming +mushrooms +mushy +music +musical +musically +musicals +musician +musicianly +musicians +musicology +musing +musings +musk +Muskegon +musket +muskets +muskox +muskoxen +muskrat +muskrats +musks +Muslim +Muslims +muslin +mussel +mussels +Mussolini +Mussolinis +Mussorgsky +must +mustache +mustached +mustaches +mustard +muster +mustiness +musts +musty +mutability +mutable +mutableness +mutandis +mutant +mutate +mutated +mutates +mutating +mutation +mutations +mutatis +mutative +mute +muted +mutely +muteness +mutilate +mutilated +mutilates +mutilating +mutilation +mutinies +mutiny +mutt +mutter +muttered +mutterer +mutterers +muttering +mutters +mutton +mutual +mutually +Muzak +Muzo +muzzle +muzzles +my +Mycenae +Mycenaean +Myers +Mynheer +Myra +myriad +Myron +myrtle +myself +Mysore +mysteries +mysterious +mysteriously +mysteriousness +mystery +mystic +mystical +mystics +mystify +myth +mythical +mythologies +mythology +nab +Nabisco +nabla +nablas +Nadia +Nadine +nadir +nag +Nagasaki +nagged +nagging +Nagoya +nags +Nagy +nail +nailed +nailing +nails +Nair +Nairobi +naive +naively +naiveness +naivete +Nakamura +Nakayama +naked +nakedly +nakedness +Nakoma +name +nameable +named +nameless +namelessly +namely +namer +namers +names +namesake +namesakes +naming +Nan +Nancy +Nanette +Nanking +nanoinstruction +nanoinstructions +Nanook +nanoprogram +nanoprogramming +nanosecond +nanoseconds +nanostore +nanostores +Nantucket +Naomi +nap +napkin +napkins +Naples +Napoleon +Napoleonic +Napoleonize +Napoleonizes +naps +Narbonne +narcissus +narcotic +narcotics +Narragansett +narrate +narration +narrative +narratives +narrow +narrowed +narrower +narrowest +narrowing +narrowly +narrowness +narrows +nary +NASA +nasal +nasally +NASAs +Nash +Nashua +Nashville +Nassau +nastier +nastiest +nastily +nastiness +nasty +Nat +natal +Natalie +Natchez +Nate +Nathan +Nathaniel +nation +national +nationalist +nationalists +nationalities +nationality +nationalization +nationalize +nationalized +nationalizes +nationalizing +nationally +nationals +nationhood +nations +nationwide +native +natively +natives +nativity +NATO +NATOs +natural +naturalism +naturalist +naturalization +naturally +naturalness +naturals +nature +natured +natures +naught +naughtier +naughtiness +naughty +Naur +nausea +nauseate +nauseum +Navaho +Navajo +naval +navally +navel +navies +navigable +navigate +navigated +navigates +navigating +navigation +navigator +navigators +Navona +navy +nay +Nazarene +Nazareth +Nazi +Nazis +Nazism +Ndjamena +Neal +Neanderthal +Neapolitan +near +nearby +neared +nearer +nearest +nearing +nearly +nearness +nears +nearsighted +neat +neater +neatest +neatly +neatness +Nebraska +Nebraskan +Nebuchadnezzar +nebula +nebular +nebulous +necessaries +necessarily +necessary +necessitate +necessitated +necessitates +necessitating +necessitation +necessities +necessity +neck +necking +necklace +necklaces +neckline +necks +necktie +neckties +necrosis +nectar +Ned +need +needed +needful +Needham +needing +needle +needled +needler +needlers +needles +needless +needlessly +needlessness +needlework +needling +needs +needy +Neff +negate +negated +negates +negating +negation +negations +negative +negatively +negatives +negator +negators +neglect +neglected +neglecting +neglects +negligee +negligence +negligent +negligible +negotiable +negotiate +negotiated +negotiates +negotiating +negotiation +negotiations +Negro +Negroes +Negroid +Negroization +Negroizations +Negroize +Negroizes +Nehru +neigh +neighbor +neighborhood +neighborhoods +neighboring +neighborly +neighbors +Neil +neither +Nell +Nellie +Nelsen +Nelson +nemesis +neoclassic +neon +neonatal +neophyte +neophytes +Nepal +Nepali +nephew +nephews +Neptune +Nero +nerve +nerves +nervous +nervously +nervousness +Ness +nest +nested +nester +nesting +nestle +nestled +nestles +nestling +Nestor +nests +net +nether +Netherlands +nets +netted +netting +nettle +nettled +network +networked +networking +networks +Neumann +neural +neuritis +neurological +neurologists +neuron +neurons +neuroses +neurosis +neurotic +neuter +neutral +neutralities +neutrality +neutralize +neutralized +neutralizing +neutrally +neutrino +neutrinos +neutron +Neva +Nevada +never +nevertheless +Nevins +new +Newark +Newbold +newborn +Newbury +Newburyport +Newcastle +newcomer +newcomers +Newell +newer +newest +Newfoundland +newly +newlywed +Newman +Newmanize +Newmanizes +newness +Newport +NeWS +newscast +newsgroup +newsletter +newsletters +newsman +newsmen +newspaper +newspapers +newsstand +Newsweek +Newsweekly +newt +Newton +Newtonian +next +Nguyen +Niagara +Niamey +nibble +nibbled +nibbler +nibblers +nibbles +nibbling +Nibelung +Nicaragua +Niccolo +nice +nicely +niceness +nicer +nicest +niche +Nicholas +Nicholls +Nichols +Nicholson +nick +nicked +nickel +nickels +nicker +nicking +Nicklaus +nickname +nicknamed +nicknames +nicks +Nicodemus +Nicosia +nicotine +niece +nieces +Nielsen +Nielson +Nietzsche +nifty +Niger +Nigeria +Nigerian +nigh +night +nightcap +nightclub +nightfall +nightgown +nightingale +nightingales +nightly +nightmare +nightmares +nightmarish +nights +nighttime +nihilism +Nijinsky +Nikko +Nikolai +nil +Nile +Nilsen +Nilsson +nimble +nimbleness +nimbler +nimbly +nimbus +Nina +nine +ninefold +nines +nineteen +nineteens +nineteenth +nineties +ninetieth +ninety +Nineveh +ninth +Niobe +nip +nipple +Nippon +Nipponize +Nipponizes +nips +nitric +nitrogen +nitrous +nitty +Nixon +no +Noah +Nobel +nobility +noble +nobleman +nobleness +nobler +nobles +noblest +nobly +nobody +nocturnal +nocturnally +nod +nodal +nodded +nodding +node +nodes +nods +nodular +nodule +Noel +Noetherian +noise +noiseless +noiselessly +noises +noisier +noisily +noisiness +noisy +Nolan +Noll +nomenclature +nominal +nominally +nominate +nominated +nominating +nomination +nominative +nominee +non +nonadaptive +nonbiodegradable +nonblocking +nonce +nonchalant +noncommercial +noncommunication +nonconsecutively +nonconservative +noncritical +noncyclic +nondecreasing +nondescript +nondescriptly +nondestructively +nondeterminacy +nondeterminate +nondeterminately +nondeterminism +nondeterministic +nondeterministically +none +nonempty +nonetheless +nonexistence +nonexistent +nonextensible +nonfunctional +nongovernmental +nonidempotent +noninteracting +noninterference +noninterleaved +nonintrusive +nonintuitive +noninverting +nonlinear +nonlinearities +nonlinearity +nonlinearly +nonlocal +nonmaskable +nonmathematical +nonmilitary +nonnegative +nonnegligible +nonnumerical +nonogenarian +nonorthogonal +nonorthogonality +nonperishable +nonpersistent +nonportable +nonprocedural +nonprocedurally +nonprofit +nonprogrammable +nonprogrammer +nonsegmented +nonsense +nonsensical +nonsequential +nonspecialist +nonspecialists +nonstandard +nonsynchronous +nontechnical +nonterminal +nonterminals +nonterminating +nontermination +nonthermal +nontransparent +nontrivial +nonuniform +nonuniformity +nonzero +noodle +nook +nooks +noon +noonday +noons +noontide +noontime +noose +nor +Nora +Nordhoff +Nordic +Nordstrom +Noreen +Norfolk +norm +Norma +normal +normalcy +normality +normalization +normalize +normalized +normalizes +normalizing +normally +normals +Norman +Normandy +Normanization +Normanizations +Normanize +Normanizer +Normanizers +Normanizes +normative +norms +Norris +Norristown +Norse +north +Northampton +northbound +northeast +northeaster +northeastern +northerly +northern +northerner +northerners +northernly +Northfield +Northrop +Northrup +Northumberland +northward +northwards +northwest +northwestern +Norton +Norwalk +Norway +Norwegian +Norwich +nose +nosed +noses +nosing +nostalgia +nostalgic +Nostradamus +Nostrand +nostril +nostrils +not +notable +notables +notably +notarize +notarized +notarizes +notarizing +notary +notation +notational +notations +notch +notched +notches +notching +note +notebook +notebooks +noted +notes +noteworthy +nothing +nothingness +nothings +notice +noticeable +noticeably +noticed +notices +noticing +notification +notifications +notified +notifier +notifiers +notifies +notify +notifying +noting +notion +notions +notoriety +notorious +notoriously +Notre +Nottingham +notwithstanding +Nouakchott +noun +nouns +nourish +nourished +nourishes +nourishing +nourishment +Novak +novel +novelist +novelists +novels +novelties +novelty +November +Novembers +novice +novices +Novosibirsk +now +nowadays +nowhere +noxious +Noyes +nozzle +nu +nuance +nuances +Nubia +Nubian +nubile +nuclear +nuclei +nucleic +nucleotide +nucleotides +nucleus +nuclide +nude +nudge +nudged +nudity +Nugent +nugget +nuisance +nuisances +null +nullary +nulled +nullified +nullifiers +nullifies +nullify +nullifying +nulls +numb +numbed +number +numbered +numberer +numbering +numberless +numbers +numbing +numbly +numbness +numbs +numerable +numeral +numerals +numerator +numerators +numeric +numerical +numerically +numerics +numerous +numismatic +numismatist +nun +nuns +nuptial +nurse +nursed +nurseries +nursery +nurses +nursing +nurture +nurtured +nurtures +nurturing +nut +nutate +nutria +nutrient +nutrition +nutritious +nuts +nutshell +nutshells +nuzzle +nylon +nymph +nymphomania +nymphomaniac +nymphs +Nyquist +oaf +oak +oaken +Oakland +Oakley +Oakmont +oaks +oar +oars +oases +oasis +oat +oaten +oath +oaths +oatmeal +oats +obedience +obediences +obedient +obediently +obelisk +Oberlin +Oberon +obese +obey +obeyed +obeying +obeys +obfuscate +obfuscatory +obituary +object +objected +objecting +objection +objectionable +objections +objective +objectively +objectives +objector +objectors +objects +obligated +obligation +obligations +obligatory +oblige +obliged +obliges +obliging +obligingly +oblique +obliquely +obliqueness +obliterate +obliterated +obliterates +obliterating +obliteration +oblivion +oblivious +obliviously +obliviousness +oblong +obnoxious +oboe +O'Brien +obscene +obscure +obscured +obscurely +obscurer +obscures +obscuring +obscurities +obscurity +obsequious +observable +observance +observances +observant +observation +observations +observatory +observe +observed +observer +observers +observes +observing +obsession +obsessions +obsessive +obsolescence +obsolescent +obsolete +obsoleted +obsoletes +obsoleting +obstacle +obstacles +obstinacy +obstinate +obstinately +obstruct +obstructed +obstructing +obstruction +obstructions +obstructive +obtain +obtainable +obtainably +obtained +obtaining +obtains +obviate +obviated +obviates +obviating +obviation +obviations +obvious +obviously +obviousness +Occam +occasion +occasional +occasionally +occasioned +occasioning +occasionings +occasions +Occident +Occidental +Occidentalization +Occidentalizations +Occidentalize +Occidentalized +Occidentalizes +Occidentalizing +Occidentals +occipital +occlude +occluded +occludes +occlusion +occlusions +occult +occupancies +occupancy +occupant +occupants +occupation +occupational +occupationally +occupations +occupied +occupier +occupies +occupy +occupying +occur +occurred +occurrence +occurrences +occurring +occurs +ocean +Oceania +oceanic +oceanography +oceans +O'Connell +O'Connor +Oconomowoc +octagon +octagonal +octahedra +octahedral +octahedron +octal +octane +octave +octaves +Octavia +octet +octets +October +Octobers +octogenarian +octopus +odd +odder +oddest +oddities +oddity +oddly +oddness +odds +ode +O'Dell +Oderberg +Oderbergs +odes +Odessa +Odin +odious +odiously +odiousness +odium +O'Donnell +odor +odorous +odorously +odorousness +odors +O'Dwyer +Odysseus +Odyssey +Oedipal +Oedipally +Oedipus +of +off +Offenbach +offend +offended +offender +offenders +offending +offends +offense +offenses +offensive +offensively +offensiveness +offer +offered +offerer +offerers +offering +offerings +offers +offhand +office +officemate +officer +officers +offices +official +officialdom +officially +officials +officiate +officio +officious +officiously +officiousness +offing +offload +offs +offset +offsets +offsetting +offshore +offspring +oft +often +oftentimes +Ogden +oh +O'Hare +Ohio +ohm +ohmmeter +oil +oilcloth +oiled +oiler +oilers +oilier +oiliest +oiling +oils +oily +ointment +Ojibwa +Okamoto +okay +Okinawa +Oklahoma +Oklahoman +Olaf +Olav +old +olden +Oldenburg +older +oldest +oldness +Oldsmobile +Olduvai +oldy +oleander +O'Leary +Oleg +oleomargarine +Olga +oligarchy +Oligocene +Olin +olive +Oliver +Olivers +olives +Olivetti +Olivia +Olivier +Olsen +Olson +Olympia +Olympian +Olympianize +Olympianizes +Olympic +Olympics +Olympus +Omaha +Oman +omega +omelet +omen +omens +omicron +ominous +ominously +ominousness +omission +omissions +omit +omits +omitted +omitting +omnibus +omnidirectional +omnipotent +omnipresent +omniscient +omnisciently +omnivore +on +onanism +once +oncology +one +Oneida +O'Neill +oneness +onerous +ones +oneself +onetime +ongoing +onion +onions +online +onlooker +only +Onondaga +onrush +onset +onsets +onslaught +Ontario +onto +ontology +onus +onward +onwards +onyx +ooze +oozed +opacity +opal +opals +opaque +opaquely +opaqueness +opcode +OPEC +Opel +open +opened +opener +openers +opening +openings +openly +openness +opens +opera +operable +operand +operandi +operands +operas +operate +operated +operates +operating +operation +operational +operationally +operations +operative +operatives +operator +operators +operetta +Ophiuchus +Ophiucus +opiate +opinion +opinions +opium +opossum +Oppenheimer +opponent +opponents +opportune +opportunely +opportunism +opportunistic +opportunities +opportunity +opposable +oppose +opposed +opposes +opposing +opposite +oppositely +oppositeness +opposites +opposition +oppress +oppressed +oppresses +oppressing +oppression +oppressive +oppressor +oppressors +opprobrium +opt +opted +opthalmic +optic +optical +optically +optics +optima +optimal +optimality +optimally +optimism +optimist +optimistic +optimistically +optimization +optimizations +optimize +optimized +optimizer +optimizers +optimizes +optimizing +optimum +opting +option +optional +optionally +options +optoacoustic +optometrist +optometry +opts +opulence +opulent +opus +or +oracle +oracles +oral +orally +orange +oranges +orangutan +oration +orations +orator +oratories +orators +oratory +orb +orbit +orbital +orbitally +orbited +orbiter +orbiters +orbiting +orbits +orchard +orchards +orchestra +orchestral +orchestras +orchestrate +orchid +orchids +ordain +ordained +ordaining +ordains +ordeal +order +ordered +ordering +orderings +orderlies +orderly +orders +ordinal +ordinance +ordinances +ordinarily +ordinariness +ordinary +ordinate +ordinates +ordination +ore +oregano +Oregon +Oregonians +ores +Oresteia +Orestes +organ +organic +organism +organisms +organist +organists +organizable +organization +organizational +organizationally +organizations +organize +organized +organizer +organizers +organizes +organizing +organs +orgasm +orgiastic +orgies +orgy +Orient +Oriental +Orientalization +Orientalizations +Orientalize +Orientalized +Orientalizes +Orientalizing +Orientals +orientation +orientations +oriented +orienting +orients +orifice +orifices +origin +original +originality +originally +originals +originate +originated +originates +originating +origination +originator +originators +origins +Orin +Orinoco +oriole +Orion +Orkney +Orlando +Orleans +Orlick +Orly +ornament +ornamental +ornamentally +ornamentation +ornamented +ornamenting +ornaments +ornate +ornery +Orono +orphan +orphanage +orphaned +orphans +Orpheus +Orphic +Orphically +Orr +Ortega +orthant +orthodontist +orthodox +orthodoxy +orthogonal +orthogonality +orthogonally +orthopedic +Orville +Orwell +Orwellian +Osaka +Osbert +Osborn +Osborne +Oscar +oscillate +oscillated +oscillates +oscillating +oscillation +oscillations +oscillator +oscillators +oscillatory +oscilloscope +oscilloscopes +Osgood +O'Shea +Oshkosh +Osiris +Oslo +osmosis +osmotic +ossify +ostensible +ostensibly +ostentatious +osteopath +osteopathic +osteopathy +osteoporosis +ostracism +Ostrander +ostrich +ostriches +O'Sullivan +Oswald +Othello +other +others +otherwise +otherworldly +Otis +Ott +Ottawa +otter +otters +Otto +Ottoman +Ottomanization +Ottomanizations +Ottomanize +Ottomanizes +Ouagadougou +ouch +ought +ounce +ounces +our +ours +ourself +ourselves +oust +out +outbound +outbreak +outbreaks +outburst +outbursts +outcast +outcasts +outcome +outcomes +outcries +outcry +outdated +outdo +outdoor +outdoors +outer +outermost +outfit +outfits +outfitted +outgoing +outgrew +outgrow +outgrowing +outgrown +outgrows +outgrowth +outing +outlandish +outlast +outlasts +outlaw +outlawed +outlawing +outlaws +outlay +outlays +outlet +outlets +outline +outlined +outlines +outlining +outlive +outlived +outlives +outliving +outlook +outlying +outnumbered +outperform +outperformed +outperforming +outperforms +outpost +outposts +output +outputs +outputting +outrage +outraged +outrageous +outrageously +outrages +outright +outrun +outruns +outs +outset +outside +outsider +outsiders +outskirts +outstanding +outstandingly +outstretched +outstrip +outstripped +outstripping +outstrips +outvote +outvoted +outvotes +outvoting +outward +outwardly +outweigh +outweighed +outweighing +outweighs +outwit +outwits +outwitted +outwitting +oval +ovals +ovaries +ovary +oven +ovens +over +overall +overalls +overboard +overcame +overcoat +overcoats +overcome +overcomes +overcoming +overcrowd +overcrowded +overcrowding +overcrowds +overdone +overdose +overdraft +overdrafts +overdue +overemphasis +overemphasized +overestimate +overestimated +overestimates +overestimating +overestimation +overflow +overflowed +overflowing +overflows +overgrown +overhang +overhanging +overhangs +overhaul +overhauling +overhead +overheads +overhear +overheard +overhearing +overhears +overjoy +overjoyed +overkill +overland +overlap +overlapped +overlapping +overlaps +overlay +overlaying +overlays +overload +overloaded +overloading +overloads +overlook +overlooked +overlooking +overlooks +overly +overnight +overnighter +overnighters +overpower +overpowered +overpowering +overpowers +overprint +overprinted +overprinting +overprints +overproduction +overridden +override +overrides +overriding +overrode +overrule +overruled +overrules +overrun +overrunning +overruns +overseas +oversee +overseeing +overseer +overseers +oversees +overshadow +overshadowed +overshadowing +overshadows +overshoot +overshot +oversight +oversights +oversimplified +oversimplifies +oversimplify +oversimplifying +oversized +overstate +overstated +overstatement +overstatements +overstates +overstating +overstocks +oversubscribed +overt +overtake +overtaken +overtaker +overtakers +overtakes +overtaking +overthrew +overthrow +overthrown +overtime +overtly +overtone +overtones +overtook +overture +overtures +overturn +overturned +overturning +overturns +overuse +overview +overviews +overwhelm +overwhelmed +overwhelming +overwhelmingly +overwhelms +overwork +overworked +overworking +overworks +overwrite +overwrites +overwriting +overwritten +overzealous +Ovid +owe +owed +Owen +Owens +owes +owing +owl +owls +own +owned +owner +owners +ownership +ownerships +owning +owns +ox +oxen +Oxford +oxide +oxides +oxidize +oxidized +Oxnard +Oxonian +oxygen +oyster +oysters +Oz +Ozark +Ozarks +ozone +Ozzie +Pablo +Pabst +pace +paced +pacemaker +pacer +pacers +paces +pacific +pacification +pacified +pacifier +pacifies +pacifism +pacifist +pacify +pacing +pack +package +packaged +packager +packagers +packages +packaging +packagings +Packard +Packards +packed +packer +packers +packet +packets +packing +packs +Packwood +pact +pacts +pad +padded +padding +paddle +paddock +paddy +padlock +pads +pagan +Paganini +pagans +page +pageant +pageantry +pageants +paged +pager +pagers +pages +paginate +paginated +paginates +paginating +pagination +paging +pagoda +paid +pail +pails +pain +Paine +pained +painful +painfully +painless +pains +painstaking +painstakingly +paint +painted +painter +painters +painting +paintings +paints +pair +paired +pairing +pairings +pairs +pairwise +pajama +pajamas +Pakistan +Pakistani +Pakistanis +pal +palace +palaces +palate +palates +Palatine +pale +paled +palely +paleness +Paleolithic +Paleozoic +paler +Palermo +pales +palest +Palestine +Palestinian +palfrey +palindrome +palindromic +paling +pall +Palladian +palladium +palliate +palliative +pallid +palm +palmed +palmer +palming +Palmolive +palms +Palmyra +Palo +Palomar +palpable +pals +palsy +Pam +Pamela +pamper +pamphlet +pamphlets +pan +panacea +panaceas +panama +Panamanian +pancake +pancakes +Pancho +panda +Pandanus +pandas +pandemic +pandemonium +pander +Pandora +pane +panel +paneled +paneling +panelist +panelists +panels +panes +pang +Pangaea +pangs +panic +panicked +panicking +panicky +panics +panned +panning +panorama +panoramic +pans +pansies +pansy +pant +panted +pantheism +pantheist +pantheon +panther +panthers +panties +panting +pantomime +pantries +pantry +pants +panty +pantyhose +Paoli +papa +papal +paper +paperback +paperbacks +papered +paperer +paperers +papering +paperings +papers +paperweight +paperwork +papoose +Pappas +Papua +papyrus +par +parabola +parabolic +paraboloid +paraboloidal +parachute +parachuted +parachutes +parade +paraded +parades +paradigm +paradigms +parading +paradise +paradox +paradoxes +paradoxical +paradoxically +paraffin +paragon +paragons +paragraph +paragraphing +paragraphs +Paraguay +Paraguayan +Paraguayans +parakeet +parallax +parallel +paralleled +paralleling +parallelism +parallelize +parallelized +parallelizes +parallelizing +parallelogram +parallelograms +parallels +paralysis +paralyze +paralyzed +paralyzes +paralyzing +parameter +parameterizable +parameterization +parameterizations +parameterize +parameterized +parameterizes +parameterizing +parameterless +parameters +parametric +parametrized +paramilitary +paramount +Paramus +paranoia +paranoiac +paranoid +paranormal +parapet +parapets +paraphernalia +paraphrase +paraphrased +paraphrases +paraphrasing +parapsychology +parasite +parasites +parasitic +parasitics +parasol +parboil +PARC +parcel +parceled +parceling +parcels +parch +parched +parchment +pardon +pardonable +pardonably +pardoned +pardoner +pardoners +pardoning +pardons +pare +paregoric +parent +parentage +parental +parentheses +parenthesis +parenthesized +parenthesizes +parenthesizing +parenthetic +parenthetical +parenthetically +parenthood +parents +pares +Pareto +pariah +parimutuel +paring +parings +Paris +parish +parishes +parishioner +Parisian +Parisianization +Parisianizations +Parisianize +Parisianizes +parity +park +Parke +parked +parker +parkers +Parkersburg +Parkhouse +parking +Parkinson +Parkinsonian +parkland +parklike +Parks +parkway +parlay +parley +parliament +parliamentarian +parliamentary +parliaments +parlor +parlors +Parmesan +parochial +parody +parole +paroled +paroles +paroling +Parr +parried +Parrish +parrot +parroting +parrots +Parrs +parry +pars +parse +parsed +parser +parsers +parses +Parsi +Parsifal +parsimony +parsing +parsings +parsley +parson +Parsons +part +partake +partaker +partakes +partaking +parted +parter +parters +Parthenon +Parthia +partial +partiality +partially +participant +participants +participate +participated +participates +participating +participation +participle +particle +particles +particular +particularly +particulars +particulate +parties +parting +partings +partisan +partisans +partition +partitioned +partitioning +partitions +partly +partner +partnered +partners +partnership +partook +partridge +partridges +parts +party +Pasadena +PASCAL +Pascal +Paso +pass +passage +passages +passageway +Passaic +passe +passed +passenger +passengers +passer +passers +passes +passing +passion +passionate +passionately +passions +passivate +passive +passively +passiveness +passivity +Passover +passport +passports +password +passwords +past +paste +pasted +pastel +Pasternak +pastes +Pasteur +pastime +pastimes +pasting +pastness +pastor +pastoral +pastors +pastry +pasts +pasture +pastures +pat +Patagonia +Patagonians +patch +patched +patches +patching +patchwork +patchy +pate +paten +patent +patentable +patented +patenter +patenters +patenting +patently +patents +paternal +paternally +paternoster +Paterson +path +pathetic +pathname +pathnames +pathogen +pathogenesis +pathological +pathology +pathos +paths +pathway +pathways +patience +patient +patiently +patients +patina +patio +patriarch +patriarchal +patriarchs +patriarchy +Patrice +Patricia +patrician +patricians +Patrick +patrimonial +patrimony +patriot +patriotic +patriotism +patriots +patrol +patrolled +patrolling +patrolman +patrolmen +patrols +patron +patronage +patronize +patronized +patronizes +patronizing +patrons +pats +Patsies +Patsy +patter +pattered +pattering +patterings +pattern +patterned +patterning +patterns +patters +Patterson +Patti +patties +Patton +patty +paucity +Paul +Paula +Paulette +Pauli +Pauline +Pauling +Paulinize +Paulinizes +Paulo +Paulsen +Paulson +Paulus +paunch +paunchy +pauper +pause +paused +pauses +pausing +pave +paved +pavement +pavements +paves +pavilion +pavilions +paving +Pavlov +Pavlovian +paw +pawing +pawn +pawns +pawnshop +paws +Pawtucket +pay +payable +paycheck +paychecks +payed +payer +payers +paying +payment +payments +Payne +Paynes +Paynize +Paynizes +payoff +payoffs +payroll +pays +Payson +Paz +pea +Peabody +peace +peaceable +peaceful +peacefully +peacefulness +peacetime +peach +peaches +Peachtree +peacock +peacocks +peak +peaked +peaks +peal +Peale +pealed +pealing +peals +peanut +peanuts +pear +Pearce +pearl +pearls +pearly +pears +Pearson +peas +peasant +peasantry +peasants +Pease +peat +pebble +pebbles +peccary +peck +pecked +pecking +pecks +Pecos +pectoral +peculiar +peculiarities +peculiarity +peculiarly +pecuniary +pedagogic +pedagogical +pedagogically +pedagogy +pedal +pedant +pedantic +pedantry +peddle +peddler +peddlers +pedestal +pedestrian +pedestrians +pediatric +pediatrician +pediatrics +pedigree +Pedro +peek +peeked +peeking +peeks +peel +peeled +peeling +peels +peep +peeped +peeper +peephole +peeping +peeps +peer +peered +peering +peerless +peers +peg +Pegasus +pegboard +Peggy +pegs +Peiping +pejorative +Peking +Pelham +pelican +pellagra +Peloponnese +pelt +pelting +pelts +pelvic +pelvis +Pembroke +pen +penal +penalize +penalized +penalizes +penalizing +penalties +penalty +penance +pence +penchant +pencil +penciled +pencils +pend +pendant +pended +pending +Pendleton +pends +pendulum +pendulums +Penelope +penetrable +penetrate +penetrated +penetrates +penetrating +penetratingly +penetration +penetrations +penetrative +penetrator +penetrators +penguin +penguins +Penh +penicillin +peninsula +peninsulas +penis +penises +penitent +penitentiary +Penn +penned +pennies +penniless +penning +Pennsylvania +penny +Penrose +pens +Pensacola +pension +pensioner +pensions +pensive +pent +pentagon +pentagons +Pentateuch +Pentecost +pentecostal +penthouse +penultimate +penumbra +peony +people +peopled +peoples +Peoria +pep +pepper +peppered +peppering +peppermint +pepperoni +peppers +peppery +peppy +Pepsi +PepsiCo +Pepsico +peptide +per +perceivable +perceivably +perceive +perceived +perceiver +perceivers +perceives +perceiving +percent +percentage +percentages +percentile +percentiles +percents +perceptible +perceptibly +perception +perceptions +perceptive +perceptively +perceptual +perceptually +perch +perchance +perched +perches +perching +Percival +percussion +percutaneous +Percy +peremptory +perennial +perennially +Perez +perfect +perfected +perfectible +perfecting +perfection +perfectionist +perfectionists +perfectly +perfectness +perfects +perforce +perform +performance +performances +performed +performer +performers +performing +performs +perfume +perfumed +perfumes +perfuming +perfunctory +Pergamon +perhaps +Periclean +Pericles +perihelion +peril +Perilla +perilous +perilously +perils +perimeter +period +periodic +periodical +periodically +periodicals +periods +peripheral +peripherally +peripherals +peripheries +periphery +periscope +perish +perishable +perishables +perished +perisher +perishers +perishes +perishing +perjure +perjury +perk +Perkins +perky +Perle +permanence +permanent +permanently +permeable +permeate +permeated +permeates +permeating +permeation +Permian +permissibility +permissible +permissibly +permission +permissions +permissive +permissively +permit +permits +permitted +permitting +permutation +permutations +permute +permuted +permutes +permuting +pernicious +Pernod +peroxide +perpendicular +perpendicularly +perpendiculars +perpetrate +perpetrated +perpetrates +perpetrating +perpetration +perpetrations +perpetrator +perpetrators +perpetual +perpetually +perpetuate +perpetuated +perpetuates +perpetuating +perpetuation +perpetuity +perplex +perplexed +perplexing +perplexity +Perry +persecute +persecuted +persecutes +persecuting +persecution +persecutor +persecutors +Perseid +Persephone +Perseus +perseverance +persevere +persevered +perseveres +persevering +Pershing +Persia +Persian +Persianization +Persianizations +Persianize +Persianizes +Persians +persist +persisted +persistence +persistent +persistently +persisting +persists +person +personage +personages +personal +personalities +personality +personalization +personalize +personalized +personalizes +personalizing +personally +personification +personified +personifies +personify +personifying +personnel +persons +perspective +perspectives +perspicuous +perspicuously +perspiration +perspire +persuadable +persuade +persuaded +persuader +persuaders +persuades +persuading +persuasion +persuasions +persuasive +persuasively +persuasiveness +pertain +pertained +pertaining +pertains +Perth +pertinent +perturb +perturbation +perturbations +perturbed +Peru +perusal +peruse +perused +peruser +perusers +peruses +perusing +Peruvian +Peruvianize +Peruvianizes +Peruvians +pervade +pervaded +pervades +pervading +pervasive +pervasively +perversion +pervert +perverted +perverts +pessimism +pessimist +pessimistic +pest +pester +pesticide +pestilence +pestilent +pests +pet +petal +petals +Pete +Peter +Peters +Petersburg +Petersen +Peterson +petition +petitioned +petitioner +petitioning +petitions +Petkiewicz +petri +petroleum +pets +petted +petter +petters +Pettibone +petticoat +petticoats +pettiness +petting +petty +petulance +petulant +Peugeot +pew +Pewaukee +pews +pewter +Pfizer +Phaedra +phantom +phantoms +pharmaceutic +pharmacist +pharmacology +pharmacopoeia +pharmacy +phase +phased +phaser +phasers +phases +phasing +pheasant +pheasants +Phelps +phenomena +phenomenal +phenomenally +phenomenological +phenomenologically +phenomenologies +phenomenology +phenomenon +phi +PHIGS +Phil +Philadelphia +philanthropy +Philco +philharmonic +Philip +Philippe +Philippians +Philippine +Philippines +Philistine +Philistines +Philistinize +Philistinizes +Phillies +Phillip +Phillips +Philly +philosopher +philosophers +philosophic +philosophical +philosophically +philosophies +philosophize +philosophized +philosophizer +philosophizers +philosophizes +philosophizing +philosophy +Phipps +Phobos +Phoenicia +phoenix +phone +phoned +phoneme +phonemes +phonemic +phones +phonetic +phonetics +phoning +phonograph +phonographs +phony +phosgene +phosphate +phosphates +phosphor +phosphorescent +phosphoric +phosphorus +photo +photocopied +photocopier +photocopiers +photocopies +photocopy +photocopying +photodiode +photodiodes +photogenic +photograph +photographed +photographer +photographers +photographic +photographing +photographs +photography +photon +photos +photosensitive +phototypesetter +phototypesetters +phrase +phrased +phraseology +phrases +phrasing +phrasings +phyla +Phyllis +phylum +physic +physical +physically +physicalness +physicals +physician +physicians +physicist +physicists +physics +physiological +physiologically +physiology +physiotherapist +physiotherapy +physique +phytoplankton +pi +pianist +piano +pianos +pica +picas +Picasso +picayune +Piccadilly +piccolo +pick +pickaxe +picked +picker +Pickering +pickers +picket +picketed +picketer +picketers +picketing +pickets +Pickett +Pickford +picking +pickings +pickle +pickled +pickles +pickling +Pickman +picks +pickup +pickups +picky +picnic +picnicked +picnicking +picnics +picofarad +picojoule +picosecond +Pict +pictorial +pictorially +picture +pictured +pictures +picturesque +picturesqueness +picturing +piddle +pidgin +pie +piece +pieced +piecemeal +pieces +piecewise +piecing +Piedfort +Piedmont +pier +pierce +pierced +pierces +piercing +Pierre +piers +Pierson +pies +piety +piezoelectric +pig +pigeon +pigeonhole +pigeons +piggish +piggy +piggyback +piggybacked +piggybacking +piggybacks +pigment +pigmentation +pigmented +pigments +pigpen +pigs +pigskin +pigtail +pike +piker +pikes +Pilate +pile +piled +pilers +piles +pilfer +pilferage +pilgrim +pilgrimage +pilgrimages +pilgrims +piling +pilings +pill +pillage +pillaged +pillar +pillared +pillars +pillory +pillow +pillows +pills +Pillsbury +pilot +piloting +pilots +pimp +pimple +pin +pinafore +pinball +pinch +pinched +pinches +pinching +pincushion +pine +pineapple +pineapples +pined +Pinehurst +pines +ping +pinhead +pinhole +pining +pinion +pink +pinker +pinkest +pinkie +pinkish +pinkly +pinkness +pinks +pinnacle +pinnacles +pinned +pinning +pinnings +pinochle +pinpoint +pinpointing +pinpoints +pins +pinscher +Pinsky +pint +pinto +pints +pinwheel +pion +pioneer +pioneered +pioneering +pioneers +Piotr +pious +piously +pip +pipe +piped +pipeline +pipelined +pipelines +pipelining +Piper +pipers +pipes +Pipestone +pipette +piping +pique +piracy +Piraeus +pirate +pirates +Pisa +Piscataway +Pisces +piss +pistachio +pistil +pistils +pistol +pistols +piston +pistons +pit +pitch +pitched +pitcher +pitchers +pitches +pitchfork +pitching +piteous +piteously +pitfall +pitfalls +pith +pithed +pithes +pithier +pithiest +pithiness +pithing +pithy +pitiable +pitied +pitier +pitiers +pities +pitiful +pitifully +pitiless +pitilessly +Pitney +pits +Pitt +pitted +Pittsburgh +Pittsburghers +Pittsfield +Pittston +pituitary +pity +pitying +pityingly +Pius +pivot +pivotal +pivoting +pivots +pixel +pixels +Pizarro +pizza +placard +placards +placate +place +placebo +placed +placeholder +placement +placements +placenta +placental +placer +places +placid +placidly +placing +plagiarism +plagiarist +plague +plagued +plagues +plaguing +plaid +plaids +plain +plainer +plainest +Plainfield +plainly +plainness +plains +plaintext +plaintexts +plaintiff +plaintiffs +plaintive +plaintively +plaintiveness +Plainview +plait +plaits +plan +planar +planarity +Planck +plane +planed +planeload +planer +planers +planes +planet +planetaria +planetarium +planetary +planetesimal +planetoid +planets +planing +plank +planking +planks +plankton +planned +planner +planners +planning +planoconcave +planoconvex +plans +plant +plantation +plantations +planted +planter +planters +planting +plantings +plants +plaque +plasma +plaster +plastered +plasterer +plastering +plasters +plastic +plasticity +plastics +plate +plateau +plateaus +plated +platelet +platelets +platen +platens +plates +platform +platforms +plating +platinum +platitude +Plato +platonic +Platonism +Platonist +platoon +Platte +platter +platters +Platteville +plausibility +plausible +play +playable +playback +playboy +played +player +players +playful +playfully +playfulness +playground +playgrounds +playhouse +playing +playmate +playmates +playoff +playroom +plays +plaything +playthings +playtime +playwright +playwrights +playwriting +plaza +plea +plead +pleaded +pleader +pleading +pleads +pleas +pleasant +pleasantly +pleasantness +please +pleased +pleases +pleasing +pleasingly +pleasure +pleasures +pleat +plebeian +plebian +plebiscite +plebiscites +pledge +pledged +pledges +Pleiades +Pleistocene +plenary +plenipotentiary +plenteous +plentiful +plentifully +plenty +plethora +pleurisy +Plexiglas +pliable +pliant +plied +pliers +plies +plight +Pliny +Pliocene +plod +plodding +plot +plots +plotted +plotter +plotters +plotting +plow +plowed +plower +plowing +plowman +plows +plowshare +ploy +ploys +pluck +plucked +plucking +plucks +plucky +plug +pluggable +plugged +plugging +plugs +plum +plumage +plumb +plumbed +plumbing +plumbs +plume +plumed +plumes +plummet +plummeting +plump +plumped +plumpness +plums +plunder +plundered +plunderer +plunderers +plundering +plunders +plunge +plunged +plunger +plungers +plunges +plunging +plunk +plural +plurality +plurals +plus +pluses +plush +Plutarch +Pluto +plutonium +ply +Plymouth +plywood +pneumatic +pneumonia +Po +poach +poacher +poaches +Pocahontas +pocket +pocketbook +pocketbooks +pocketed +pocketful +pocketing +pockets +Pocono +Poconos +pod +podia +podium +pods +Podunk +Poe +poem +poems +poet +poetic +poetical +poetically +poetics +poetries +poetry +poets +pogo +pogrom +poignancy +poignant +Poincare +Poindexter +point +pointed +pointedly +pointer +pointers +pointing +pointless +points +pointy +poise +poised +poises +poison +poisoned +poisoner +poisoning +poisonous +poisonousness +poisons +Poisson +poke +poked +poker +pokerface +pokes +poking +Poland +polar +Polaris +polarities +polarity +Polaroid +pole +polecat +poled +polemic +polemics +poles +police +policed +policeman +policemen +polices +policies +policing +policy +poling +polio +polish +polished +polisher +polishers +polishes +polishing +Politburo +polite +politely +politeness +politer +politest +politic +political +politically +politician +politicians +politicking +politics +Polk +polka +poll +Pollard +polled +pollen +polling +polloi +polls +pollutant +pollute +polluted +pollutes +polluting +pollution +Pollux +polo +polyalphabetic +polygon +polygons +Polyhymnia +polymer +polymers +polymorphic +Polynesia +Polynesian +polynomial +polynomials +Polyphemus +polytechnic +polytheist +Pomerania +Pomeranian +Pomona +pomp +pompadour +Pompeii +Pompey +pomposity +pompous +pompously +pompousness +Ponce +Ponchartrain +poncho +pond +ponder +pondered +pondering +ponderous +ponders +ponds +pong +ponies +Pontiac +pontiff +pontific +pontificate +pony +pooch +poodle +pool +Poole +pooled +pooling +pools +poor +poorer +poorest +poorly +poorness +pop +popcorn +Pope +Popek +Popeks +popish +poplar +poplin +popped +poppies +popping +poppy +pops +Popsicle +Popsicles +populace +popular +popularity +popularization +popularize +popularized +popularizes +popularizing +popularly +populate +populated +populates +populating +population +populations +populous +populousness +porcelain +porch +porches +porcine +porcupine +porcupines +pore +pored +pores +poring +pork +porker +pornographer +pornographic +pornography +porous +porpoise +porridge +port +portability +portable +portage +portal +portals +Porte +ported +portend +portended +portending +portends +portent +portentous +porter +porterhouse +porters +portfolio +portfolios +Portia +portico +porting +portion +portions +Portland +portly +portmanteau +Porto +portrait +portraits +portray +portrayal +portrayed +portraying +portrays +ports +Portsmouth +Portugal +Portuguese +pose +posed +Poseidon +poser +posers +poses +posh +posing +posit +posited +positing +position +positional +positioned +positioning +positions +positive +positively +positiveness +positives +positron +posits +Posner +posse +possess +possessed +possesses +possessing +possession +possessional +possessions +possessive +possessively +possessiveness +possessor +possessors +possibilities +possibility +possible +possibly +possum +possums +post +postage +postal +postcard +postcondition +postdoctoral +posted +poster +posterior +posteriori +posterity +posters +postfix +postgraduate +posting +postlude +postman +postmark +postmaster +postmasters +postmortem +postoperative +postorder +postpone +postponed +postponing +postprocess +postprocessor +posts +postscript +postscripts +postulate +postulated +postulates +postulating +postulation +postulations +posture +postures +pot +potable +potash +potassium +potato +potatoes +potbelly +Potemkin +potent +potentate +potentates +potential +potentialities +potentiality +potentially +potentials +potentiating +potentiometer +potentiometers +pothole +potion +potlatch +Potomac +potpourri +pots +Potsdam +Pottawatomie +potted +potter +potters +pottery +potting +Potts +pouch +pouches +Poughkeepsie +poultice +poultry +pounce +pounced +pounces +pouncing +pound +pounded +pounder +pounders +pounding +pounds +pour +poured +pourer +pourers +pouring +pours +Poussin +Poussins +pout +pouted +pouting +pouts +poverty +powder +powdered +powdering +powderpuff +powders +powdery +Powell +power +powered +powerful +powerfully +powerfulness +powering +powerless +powerlessly +powerlessness +Powers +pox +Poynting +practicable +practicably +practical +practicality +practically +practice +practiced +practices +practicing +practitioner +practitioners +Pradesh +Prado +pragmatic +pragmatically +pragmatics +pragmatism +pragmatist +Prague +prairie +praise +praised +praiser +praisers +praises +praiseworthy +praising +praisingly +prance +pranced +prancer +prancing +prank +pranks +prate +Pratt +Prattville +Pravda +pray +prayed +prayer +prayers +praying +preach +preached +preacher +preachers +preaches +preaching +preallocate +preallocated +preallocating +preamble +preambles +preassign +preassigned +preassigning +preassigns +Precambrian +precarious +precariously +precariousness +precaution +precautions +precede +preceded +precedence +precedences +precedent +precedented +precedents +precedes +preceding +precept +precepts +precess +precession +precinct +precincts +precious +preciously +preciousness +precipice +precipitable +precipitate +precipitated +precipitately +precipitateness +precipitates +precipitating +precipitation +precipitous +precipitously +precise +precisely +preciseness +precision +precisions +preclude +precluded +precludes +precluding +precocious +precociously +precocity +precompute +precomputed +precomputing +preconceive +preconceived +preconception +preconceptions +precondition +preconditioned +preconditions +precursor +precursors +predate +predated +predates +predating +predatory +predecessor +predecessors +predefine +predefined +predefines +predefining +predefinition +predefinitions +predetermination +predetermine +predetermined +predetermines +predetermining +predicament +predicate +predicated +predicates +predicating +predication +predications +predict +predictability +predictable +predictably +predicted +predicting +prediction +predictions +predictive +predictor +predicts +predilection +predilections +predisposition +predominant +predominantly +predominate +predominated +predominately +predominates +predominating +predomination +preeminence +preeminent +preempt +preempted +preempting +preemption +preemptive +preemptor +preempts +preen +preexisting +prefab +prefabricate +preface +prefaced +prefaces +prefacing +prefer +preferable +preferably +preference +preferences +preferential +preferentially +preferred +preferring +prefers +prefix +prefixed +prefixes +prefixing +pregnancy +pregnant +prehistoric +preinitialize +preinitialized +preinitializes +preinitializing +prejudge +prejudged +prejudice +prejudiced +prejudices +prejudicial +prelate +preliminaries +preliminary +prelude +preludes +premature +prematurely +prematurity +premeditated +premeditation +premier +premiers +premise +premises +premium +premiums +premonition +prenatal +Prentice +Prenticed +Prenticing +preoccupation +preoccupied +preoccupies +preoccupy +prep +preparation +preparations +preparative +preparatives +preparatory +prepare +prepared +prepares +preparing +prepend +prepended +prepending +preposition +prepositional +prepositions +preposterous +preposterously +preprocessed +preprocessing +preprocessor +preprocessors +preproduction +preprogrammed +prerequisite +prerequisites +prerogative +prerogatives +Presbyterian +Presbyterianism +Presbyterianize +Presbyterianizes +Prescott +prescribe +prescribed +prescribes +prescription +prescriptions +prescriptive +preselect +preselected +preselecting +preselects +presence +presences +present +presentation +presentations +presented +presenter +presenting +presently +presentness +presents +preservation +preservations +preserve +preserved +preserver +preservers +preserves +preserving +preset +preside +presided +presidency +president +presidential +presidents +presides +presiding +Presley +press +pressed +presser +presses +pressing +pressings +pressure +pressured +pressures +pressuring +pressurize +pressurized +prestidigitate +prestige +prestigious +Preston +presumably +presume +presumed +presumes +presuming +presumption +presumptions +presumptive +presumptuous +presumptuousness +presuppose +presupposed +presupposes +presupposing +presupposition +pretend +pretended +pretender +pretenders +pretending +pretends +pretense +pretenses +pretension +pretensions +pretentious +pretentiously +pretentiousness +pretext +pretexts +Pretoria +Pretorian +prettier +prettiest +prettily +prettiness +pretty +prevail +prevailed +prevailing +prevailingly +prevails +prevalence +prevalent +prevalently +prevent +preventable +preventably +prevented +preventing +prevention +preventive +preventives +prevents +preview +previewed +previewing +previews +previous +previously +prey +preyed +preying +preys +Priam +price +priced +priceless +pricer +pricers +prices +pricing +prick +pricked +pricking +prickly +pricks +pride +prided +prides +priding +priest +Priestley +priggish +prim +prima +primacy +primal +primaries +primarily +primary +primate +prime +primed +primeness +primer +primers +primes +primeval +priming +primitive +primitively +primitiveness +primitives +primrose +prince +princely +princes +princess +princesses +Princeton +principal +principalities +principality +principally +principals +Principia +principle +principled +principles +print +printable +printably +printed +printer +printers +printing +printout +prints +prior +priori +priorities +priority +priory +Priscilla +prism +prisms +prison +prisoner +prisoners +prisons +pristine +Pritchard +privacies +privacy +private +privately +privates +privation +privations +privies +privilege +privileged +privileges +privy +prize +prized +prizer +prizers +prizes +prizewinning +prizing +pro +probabilistic +probabilistically +probabilities +probability +probable +probably +probate +probated +probates +probating +probation +probative +probe +probed +probes +probing +probings +probity +problem +problematic +problematical +problematically +problems +procaine +procedural +procedurally +procedure +procedures +proceed +proceeded +proceeding +proceedings +proceeds +process +processed +processes +processing +procession +processor +processors +proclaim +proclaimed +proclaimer +proclaimers +proclaiming +proclaims +proclamation +proclamations +proclivities +proclivity +procotols +procrastinate +procrastinated +procrastinates +procrastinating +procrastination +procreate +Procrustean +Procrusteanize +Procrusteanizes +Procrustes +Procter +procure +procured +procurement +procurements +procurer +procurers +procures +procuring +Procyon +prod +prodigal +prodigally +prodigious +prodigy +produce +produced +producer +producers +produces +producible +producing +product +production +productions +productive +productively +productivity +products +profane +profanely +profess +professed +professes +professing +profession +professional +professionalism +professionally +professionals +professions +professor +professorial +professors +proffer +proffered +proffers +proficiency +proficient +proficiently +profile +profiled +profiles +profiling +profit +profitability +profitable +profitably +profited +profiteer +profiteers +profiting +profits +profitted +profligate +profound +profoundest +profoundly +profundity +profuse +profusion +progenitor +progeny +prognosis +prognosticate +program +programmability +programmable +programmed +programmer +programmers +programming +programs +progress +progressed +progresses +progressing +progression +progressions +progressive +progressively +prohibit +prohibited +prohibiting +prohibition +prohibitions +prohibitive +prohibitively +prohibitory +prohibits +project +projected +projectile +projecting +projection +projections +projective +projectively +projector +projectors +projects +Prokofieff +Prokofiev +prolate +prolegomena +proletariat +proliferate +proliferated +proliferates +proliferating +proliferation +prolific +prolix +prolog +prologue +prolong +prolongate +prolonged +prolonging +prolongs +promenade +promenades +Promethean +Prometheus +prominence +prominent +prominently +promiscuous +promise +promised +promises +promising +promontory +promote +promoted +promoter +promoters +promotes +promoting +promotion +promotional +promotions +prompt +prompted +prompter +promptest +prompting +promptings +promptly +promptness +prompts +promulgate +promulgated +promulgates +promulgating +promulgation +prone +proneness +prong +pronged +prongs +pronoun +pronounce +pronounceable +pronounced +pronouncement +pronouncements +pronounces +pronouncing +pronouns +pronunciation +pronunciations +proof +proofread +proofreader +proofs +prop +propaganda +propagandist +propagate +propagated +propagates +propagating +propagation +propagations +propane +propel +propellant +propelled +propeller +propellers +propelling +propels +propensity +proper +properly +properness +propertied +properties +property +prophecies +prophecy +prophesied +prophesier +prophesies +prophesy +prophet +prophetic +prophets +propitious +proponent +proponents +proportion +proportional +proportionally +proportionately +proportioned +proportioning +proportionment +proportions +propos +proposal +proposals +propose +proposed +proposer +proposes +proposing +proposition +propositional +propositionally +propositioned +propositioning +propositions +propound +propounded +propounding +propounds +proprietary +proprietor +proprietors +propriety +props +propulsion +propulsions +prorate +prorated +prorates +pros +proscenium +proscribe +proscription +prose +prosecute +prosecuted +prosecutes +prosecuting +prosecution +prosecutions +prosecutor +proselytize +proselytized +proselytizes +proselytizing +Proserpine +prosodic +prosodics +prospect +prospected +prospecting +prospection +prospections +prospective +prospectively +prospectives +prospector +prospectors +prospects +prospectus +prosper +prospered +prospering +prosperity +prosperous +prospers +prostate +prosthetic +prostitute +prostitution +prostrate +prostration +protagonist +protean +protect +protected +protecting +protection +protections +protective +protectively +protectiveness +protector +protectorate +protectors +protects +protege +proteges +protein +proteins +protest +protestant +Protestantism +Protestantize +Protestantizes +protestation +protestations +protested +protesting +protestingly +protestor +protests +Protista +protocol +protocols +proton +protons +Protophyta +protoplasm +prototype +prototyped +prototypes +prototypical +prototypically +prototyping +Protozoa +protozoan +protract +protrude +protruded +protrudes +protruding +protrusion +protrusions +protuberant +proud +prouder +proudest +proudly +Proust +provability +provable +provably +prove +proved +proven +provenance +Provence +prover +proverb +proverbial +proverbs +provers +proves +provide +provided +providence +provident +provider +providers +provides +providing +province +provinces +provincial +proving +provision +provisional +provisionally +provisioned +provisioning +provisions +proviso +provocation +provoke +provoked +provokes +provost +prow +prowess +prowl +prowled +prowler +prowlers +prowling +prows +proximal +proximate +proximity +Proxmire +proxy +prudence +prudent +prudential +prudently +prune +pruned +pruner +pruners +prunes +pruning +prurient +Prussia +Prussian +Prussianization +Prussianizations +Prussianize +Prussianizer +Prussianizers +Prussianizes +pry +prying +psalm +psalms +pseudo +pseudofiles +pseudoinstruction +pseudoinstructions +pseudonym +pseudoparallelism +psilocybin +psych +psyche +psychedelic +psyches +psychiatric +psychiatrist +psychiatrists +psychiatry +psychic +psycho +psychoanalysis +psychoanalyst +psychoanalytic +psychobiology +psychological +psychologically +psychologist +psychologists +psychology +psychopath +psychopathic +psychophysic +psychoses +psychosis +psychosocial +psychosomatic +psychotherapeutic +psychotherapist +psychotherapy +psychotic +Ptolemaic +Ptolemaists +Ptolemy +pub +puberty +public +publication +publications +publicity +publicize +publicized +publicizes +publicizing +publicly +publish +published +publisher +publishers +publishes +publishing +pubs +Puccini +pucker +puckered +puckering +puckers +pudding +puddings +puddle +puddles +puddling +Puerto +puff +puffed +puffin +puffing +puffs +Pugh +puke +Pulaski +Pulitzer +pull +pulled +puller +pulley +pulleys +pulling +pullings +Pullman +Pullmanize +Pullmanizes +Pullmans +pullover +pulls +pulmonary +pulp +pulping +pulpit +pulpits +pulsar +pulsate +pulsation +pulsations +pulse +pulsed +pulses +pulsing +puma +pumice +pummel +pump +pumped +pumping +pumpkin +pumpkins +pumps +pun +punch +punched +puncher +punches +punching +punctual +punctually +punctuation +puncture +punctured +punctures +puncturing +pundit +pungent +Punic +punish +punishable +punished +punishes +punishing +punishment +punishments +punitive +Punjab +Punjabi +puns +punt +punted +punting +punts +puny +pup +pupa +pupil +pupils +puppet +puppeteer +puppets +puppies +puppy +pups +Purcell +purchase +purchased +purchaser +purchasers +purchases +purchasing +Purdue +pure +purely +purer +purest +purgatory +purge +purged +purges +purging +purification +purifications +purified +purifier +purifiers +purifies +purify +purifying +Purina +purist +Puritan +puritanic +Puritanize +Puritanizer +Puritanizers +Puritanizes +purity +purple +purpler +purplest +purport +purported +purportedly +purporter +purporters +purporting +purports +purpose +purposed +purposeful +purposefully +purposely +purposes +purposive +purr +purred +purring +purrs +purse +pursed +purser +purses +pursuant +pursue +pursued +pursuer +pursuers +pursues +pursuing +pursuit +pursuits +purveyor +purview +pus +Pusan +Pusey +push +pushbutton +pushdown +pushed +pusher +pushers +pushes +pushing +puss +pussy +pussycat +put +Putnam +puts +putt +putter +puttering +putters +putting +putty +puzzle +puzzled +puzzlement +puzzler +puzzlers +puzzles +puzzling +puzzlings +Pygmalion +pygmies +pygmy +Pyle +Pyongyang +Pyotr +pyramid +pyramids +pyre +Pyrex +Pyrrhic +Pythagoras +Pythagorean +Pythagoreanize +Pythagoreanizes +Pythagoreans +python +Qatar +qua +quack +quacked +quackery +quacks +quad +quadrangle +quadrangular +quadrant +quadrants +quadratic +quadratical +quadratically +quadratics +quadrature +quadratures +quadrennial +quadrilateral +quadrillion +quadruple +quadrupled +quadruples +quadrupling +quadrupole +quaff +quagmire +quagmires +quahog +quail +quails +quaint +quaintly +quaintness +quake +quaked +quaker +Quakeress +Quakerization +Quakerizations +Quakerize +Quakerizes +quakers +quakes +quaking +qualification +qualifications +qualified +qualifier +qualifiers +qualifies +qualify +qualifying +qualitative +qualitatively +qualities +quality +qualm +quandaries +quandary +quanta +Quantico +quantifiable +quantification +quantifications +quantified +quantifier +quantifiers +quantifies +quantify +quantifying +quantile +quantitative +quantitatively +quantities +quantity +quantization +quantize +quantized +quantizes +quantizing +quantum +quarantine +quarantines +quarantining +quark +quarrel +quarreled +quarreling +quarrels +quarrelsome +quarries +quarry +quart +quarter +quarterback +quartered +quartering +quarterly +quartermaster +quarters +quartet +quartets +quartile +quarts +quartz +quartzite +quasar +quash +quashed +quashes +quashing +quasi +Quasimodo +quaternary +quaver +quavered +quavering +quavers +quay +queasy +Quebec +queen +queenly +queens +Queensland +queer +queerer +queerest +queerly +queerness +quell +quelling +quench +quenched +quenches +quenching +queried +queries +query +querying +quest +quested +quester +questers +questing +question +questionable +questionably +questioned +questioner +questioners +questioning +questioningly +questionings +questionnaire +questionnaires +questions +quests +queue +queued +queueing +queuer +queuers +queues +queuing +Quezon +quibble +Quichua +quick +quicken +quickened +quickening +quickens +quicker +quickest +quickie +quicklime +quickly +quickness +quicksand +quicksilver +quiescent +quiet +quieted +quieter +quietest +quieting +quietly +quietness +quiets +quietude +quill +quilt +quilted +quilting +quilts +quince +quinine +Quinn +quint +quintet +quintillion +quip +Quirinal +quirk +quirky +quit +quite +Quito +quits +quitter +quitters +quitting +quiver +quivered +quivering +quivers +Quixote +quixotic +Quixotism +quiz +quizzed +quizzes +quizzical +quizzing +quo +quonset +quorum +quota +quotas +quotation +quotations +quote +quoted +quotes +quoth +quotient +quotients +quoting +Rabat +rabbi +rabbit +rabbits +rabble +rabid +rabies +Rabin +raccoon +raccoons +race +raced +racer +racers +races +racetrack +Rachel +Rachmaninoff +racial +racially +Racine +racing +rack +racked +racket +racketeer +racketeering +racketeers +rackets +racking +racks +radar +radars +Radcliffe +radial +radially +radian +radiance +radiant +radiantly +radiate +radiated +radiates +radiating +radiation +radiations +radiator +radiators +radical +radically +radicals +radices +radii +radio +radioactive +radioastronomy +radioed +radiography +radioing +radiology +radios +radish +radishes +radium +radius +radix +radon +Rae +Rafael +Rafferty +raft +rafter +rafters +rafts +rag +rage +raged +rages +ragged +raggedly +raggedness +raging +rags +Ragusan +ragweed +raid +raided +raider +raiders +raiding +raids +rail +railed +railer +railers +railing +railroad +railroaded +railroader +railroaders +railroading +railroads +rails +railway +railways +raiment +rain +rainbow +raincoat +raincoats +raindrop +raindrops +rained +rainfall +rainier +rainiest +raining +rains +rainstorm +rainy +raise +raised +raiser +raisers +raises +raisin +raising +rake +raked +rakes +raking +Raleigh +rallied +rallies +rally +rallying +Ralph +Ralston +ram +Ramada +Raman +ramble +rambler +rambles +rambling +ramblings +ramification +ramifications +Ramirez +Ramo +Ramona +ramp +rampage +rampant +rampart +ramps +ramrod +rams +Ramsey +ran +ranch +ranched +rancher +ranchers +ranches +ranching +rancid +Rand +Randall +Randolph +random +randomization +randomize +randomized +randomizes +randomly +randomness +randy +rang +range +ranged +rangeland +ranger +rangers +ranges +ranging +Rangoon +rangy +Ranier +rank +ranked +ranker +rankers +rankest +Rankin +Rankine +ranking +rankings +rankle +rankly +rankness +ranks +ransack +ransacked +ransacking +ransacks +ransom +ransomer +ransoming +ransoms +rant +ranted +ranter +ranters +ranting +rants +Raoul +rap +rapacious +rape +raped +raper +rapes +Raphael +rapid +rapidity +rapidly +rapids +rapier +raping +rapport +rapprochement +raps +rapt +raptly +rapture +raptures +rapturous +Rapunzel +rare +rarely +rareness +rarer +rarest +Raritan +rarity +rascal +rascally +rascals +rash +rasher +rashly +rashness +Rasmussen +rasp +raspberry +rasped +rasping +rasps +raster +Rastus +rat +rate +rated +rater +raters +rates +Ratfor +rather +ratification +ratified +ratifies +ratify +ratifying +rating +ratings +ratio +ration +rational +rationale +rationales +rationalities +rationality +rationalization +rationalizations +rationalize +rationalized +rationalizes +rationalizing +rationally +rationals +rationing +rations +ratios +rats +rattle +rattled +rattler +rattlers +rattles +rattlesnake +rattlesnakes +rattling +raucous +Raul +ravage +ravaged +ravager +ravagers +ravages +ravaging +rave +raved +raven +ravening +ravenous +ravenously +ravens +raves +ravine +ravines +raving +ravings +raw +rawer +rawest +Rawlings +Rawlins +Rawlinson +rawly +rawness +Rawson +ray +Rayburn +Rayleigh +Raymond +Raymondville +rays +Raytheon +raze +razor +razors +re +reabbreviate +reabbreviated +reabbreviates +reabbreviating +reach +reachability +reachable +reachably +reached +reacher +reaches +reaching +reacquired +react +reacted +reacting +reaction +reactionaries +reactionary +reactions +reactivate +reactivated +reactivates +reactivating +reactivation +reactive +reactively +reactivity +reactor +reactors +reacts +read +readability +readable +reader +readers +readied +readier +readies +readiest +readily +readiness +reading +readings +readjusted +readout +readouts +reads +ready +readying +Reagan +real +realest +realign +realigned +realigning +realigns +realism +realist +realistic +realistically +realists +realities +reality +realizable +realizably +realization +realizations +realize +realized +realizes +realizing +reallocate +really +realm +realms +realness +reals +realtor +ream +reanalyze +reanalyzes +reanalyzing +reap +reaped +reaper +reaping +reappear +reappeared +reappearing +reappears +reappraisal +reappraisals +reaps +rear +reared +rearing +rearrange +rearrangeable +rearranged +rearrangement +rearrangements +rearranges +rearranging +rearrest +rearrested +rears +reason +reasonable +reasonableness +reasonably +reasoned +reasoner +reasoning +reasonings +reasons +reassemble +reassembled +reassembles +reassembling +reassembly +reassessment +reassessments +reassign +reassigned +reassigning +reassignment +reassignments +reassigns +reassure +reassured +reassures +reassuring +reawaken +reawakened +reawakening +reawakens +rebate +rebates +Rebecca +rebel +rebelled +rebelling +rebellion +rebellions +rebellious +rebelliously +rebelliousness +rebels +rebind +rebinding +rebinds +reboot +rebooted +rebooting +reboots +rebound +rebounded +rebounding +rebounds +rebroadcast +rebroadcasting +rebroadcasts +rebuff +rebuffed +rebuild +rebuilding +rebuilds +rebuilt +rebuke +rebuked +rebukes +rebuking +rebuttal +rebutted +rebutting +recalcitrant +recalculate +recalculated +recalculates +recalculating +recalculation +recalculations +recalibrate +recalibrated +recalibrates +recalibrating +recall +recalled +recalling +recalls +recant +recapitulate +recapitulated +recapitulates +recapitulation +recapture +recaptured +recaptures +recapturing +recast +recasting +recasts +recede +receded +recedes +receding +receipt +receipts +receivable +receive +received +receiver +receivers +receives +receiving +recent +recently +recentness +receptacle +receptacles +reception +receptionist +receptions +receptive +receptively +receptiveness +receptivity +receptor +recess +recessed +recesses +recession +recessive +Recife +recipe +recipes +recipient +recipients +reciprocal +reciprocally +reciprocate +reciprocated +reciprocates +reciprocating +reciprocation +reciprocity +recirculate +recirculated +recirculates +recirculating +recital +recitals +recitation +recitations +recite +recited +reciter +recites +reciting +reckless +recklessly +recklessness +reckon +reckoned +reckoner +reckoning +reckonings +reckons +reclaim +reclaimable +reclaimed +reclaimer +reclaimers +reclaiming +reclaims +reclamation +reclamations +reclassification +reclassified +reclassifies +reclassify +reclassifying +recline +reclining +recode +recoded +recodes +recoding +recognition +recognitions +recognizability +recognizable +recognizably +recognize +recognized +recognizer +recognizers +recognizes +recognizing +recoil +recoiled +recoiling +recoils +recollect +recollected +recollecting +recollection +recollections +recombination +recombine +recombined +recombines +recombining +recommend +recommendation +recommendations +recommended +recommender +recommending +recommends +recompense +recompile +recompiled +recompiles +recompiling +recompute +recomputed +recomputes +recomputing +reconcile +reconciled +reconciler +reconciles +reconciliation +reconciling +reconfigurable +reconfiguration +reconfigurations +reconfigure +reconfigured +reconfigurer +reconfigures +reconfiguring +reconnect +reconnected +reconnecting +reconnection +reconnects +reconsider +reconsideration +reconsidered +reconsidering +reconsiders +reconstituted +reconstruct +reconstructed +reconstructing +reconstruction +reconstructs +reconverted +reconverts +record +recorded +recorder +recorders +recording +recordings +records +recount +recounted +recounting +recounts +recourse +recover +recoverable +recovered +recoveries +recovering +recovers +recovery +recreate +recreated +recreates +recreating +recreation +recreational +recreations +recreative +recruit +recruited +recruiter +recruiting +recruits +recta +rectangle +rectangles +rectangular +rectify +rector +rectors +rectum +rectums +recuperate +recur +recurrence +recurrences +recurrent +recurrently +recurring +recurs +recurse +recursed +recurses +recursing +recursion +recursions +recursive +recursively +recyclable +recycle +recycled +recycles +recycling +red +redbreast +redcoat +redden +reddened +redder +reddest +reddish +reddishness +redeclare +redeclared +redeclares +redeclaring +redeem +redeemed +redeemer +redeemers +redeeming +redeems +redefine +redefined +redefines +redefining +redefinition +redefinitions +redemption +redesign +redesigned +redesigning +redesigns +redevelopment +Redford +redhead +Redhook +redirect +redirected +redirecting +redirection +redirections +redisplay +redisplayed +redisplaying +redisplays +redistribute +redistributed +redistributes +redistributing +redly +Redmond +redneck +redness +redo +redone +redouble +redoubled +redraw +redrawn +redress +redressed +redresses +redressing +reds +Redstone +reduce +reduced +reducer +reducers +reduces +reducibility +reducible +reducibly +reducing +reduction +reductions +redundancies +redundancy +redundant +redundantly +redwood +reed +reeds +reeducation +Reedville +reef +reefer +reefs +reel +reelect +reelected +reelecting +reelects +reeled +reeler +reeling +reels +reemphasize +reemphasized +reemphasizes +reemphasizing +reenabled +reenforcement +reenter +reentered +reentering +reenters +reentrant +Reese +reestablish +reestablished +reestablishes +reestablishing +reevaluate +reevaluated +reevaluates +reevaluating +reevaluation +Reeves +reexamine +reexamined +reexamines +reexamining +reexecuted +refer +referee +refereed +refereeing +referees +reference +referenced +referencer +references +referencing +referenda +referendum +referendums +referent +referential +referentiality +referentially +referents +referral +referrals +referred +referring +refers +refill +refillable +refilled +refilling +refills +refine +refined +refinement +refinements +refiner +refinery +refines +refining +reflect +reflected +reflecting +reflection +reflections +reflective +reflectively +reflectivity +reflector +reflectors +reflects +reflex +reflexes +reflexive +reflexively +reflexiveness +reflexivity +reforestation +reform +reformable +reformat +reformation +reformatory +reformats +reformatted +reformatting +reformed +reformer +reformers +reforming +reforms +reformulate +reformulated +reformulates +reformulating +reformulation +refract +refracted +refraction +refractory +refragment +refrain +refrained +refraining +refrains +refresh +refreshed +refresher +refreshers +refreshes +refreshing +refreshingly +refreshment +refreshments +refrigerate +refrigerator +refrigerators +refuel +refueled +refueling +refuels +refuge +refugee +refugees +refusal +refuse +refused +refuses +refusing +refutable +refutation +refute +refuted +refuter +refutes +refuting +regain +regained +regaining +regains +regal +regaled +regally +regard +regarded +regarding +regardless +regards +regatta +regenerate +regenerated +regenerates +regenerating +regeneration +regenerative +regenerator +regenerators +regent +regents +regime +regimen +regiment +regimentation +regimented +regiments +regimes +Regina +Reginald +region +regional +regionally +regions +Regis +register +registered +registering +registers +registrar +registration +registrations +registry +regress +regressed +regresses +regressing +regression +regressions +regressive +regret +regretful +regretfully +regrets +regrettable +regrettably +regretted +regretting +regroup +regrouped +regrouping +regular +regularities +regularity +regularly +regulars +regulate +regulated +regulates +regulating +regulation +regulations +regulative +regulator +regulators +regulatory +Regulus +rehabilitate +rehearsal +rehearsals +rehearse +rehearsed +rehearser +rehearses +rehearsing +Reich +Reichenberg +Reichstag +Reid +reign +reigned +reigning +reigns +Reilly +reimbursable +reimburse +reimbursed +reimbursement +reimbursements +rein +reincarnate +reincarnated +reincarnation +reindeer +reined +reinforce +reinforced +reinforcement +reinforcements +reinforcer +reinforces +reinforcing +Reinhard +Reinhardt +Reinhold +reinitialize +reinitialized +reinitializing +reins +reinsert +reinserted +reinserting +reinserts +reinstate +reinstated +reinstatement +reinstates +reinstating +reinterpret +reinterpreted +reinterpreting +reinterprets +reintroduce +reintroduced +reintroduces +reintroducing +reinvent +reinvented +reinventing +reinvents +reiterate +reiterated +reiterates +reiterating +reiteration +reject +rejected +rejecting +rejection +rejections +rejector +rejectors +rejects +rejoice +rejoiced +rejoicer +rejoices +rejoicing +rejoin +rejoinder +rejoined +rejoining +rejoins +relabel +relabeled +relabeling +relabelled +relabelling +relabels +relapse +relate +related +relater +relates +relating +relation +relational +relationally +relations +relationship +relationships +relative +relatively +relativeness +relatives +relativism +relativistic +relativistically +relativity +relax +relaxation +relaxations +relaxed +relaxer +relaxes +relaxing +relay +relayed +relaying +relays +release +released +releases +releasing +relegate +relegated +relegates +relegating +relent +relented +relenting +relentless +relentlessly +relentlessness +relents +relevance +relevances +relevant +relevantly +reliability +reliable +reliably +reliance +reliant +relic +relics +relied +relief +relies +relieve +relieved +reliever +relievers +relieves +relieving +religion +religions +religious +religiously +religiousness +relink +relinquish +relinquished +relinquishes +relinquishing +relish +relished +relishes +relishing +relive +relives +reliving +reload +reloaded +reloader +reloading +reloads +relocatable +relocate +relocated +relocates +relocating +relocation +relocations +reluctance +reluctant +reluctantly +rely +relying +remain +remainder +remainders +remained +remaining +remains +remark +remarkable +remarkableness +remarkably +remarked +remarking +remarks +Rembrandt +remedial +remedied +remedies +remedy +remedying +remember +remembered +remembering +remembers +remembrance +remembrances +remind +reminded +reminder +reminders +reminding +reminds +Remington +reminiscence +reminiscences +reminiscent +reminiscently +remiss +remission +remit +remittance +remnant +remnants +remodel +remodeled +remodeling +remodels +remonstrate +remonstrated +remonstrates +remonstrating +remonstration +remonstrative +remorse +remorseful +remote +remotely +remoteness +remotest +removable +removal +removals +remove +removed +remover +removes +removing +remunerate +remuneration +Remus +Remy +Rena +renaissance +renal +rename +renamed +renames +renaming +Renault +Renaults +rend +render +rendered +rendering +renderings +renders +rendezvous +rending +rendition +renditions +rends +Rene +Renee +renegade +renegotiable +renew +renewable +renewal +renewed +renewer +renewing +renews +Reno +Renoir +renounce +renounces +renouncing +renovate +renovated +renovation +renown +renowned +Rensselaer +rent +rental +rentals +rented +renting +rents +renumber +renumbering +renumbers +renunciate +renunciation +Renville +reoccur +reopen +reopened +reopening +reopens +reorder +reordered +reordering +reorders +reorganization +reorganizations +reorganize +reorganized +reorganizes +reorganizing +repackage +repaid +repair +repaired +repairer +repairing +repairman +repairmen +repairs +reparation +reparations +repartee +repartition +repast +repasts +repay +repaying +repays +repeal +repealed +repealer +repealing +repeals +repeat +repeatable +repeated +repeatedly +repeater +repeaters +repeating +repeats +repel +repelled +repellent +repels +repent +repentance +repented +repenting +repents +repercussion +repercussions +repertoire +repertory +repetition +repetitions +repetitious +repetitive +repetitively +repetitiveness +rephrase +rephrased +rephrases +rephrasing +repine +replace +replaceable +replaced +replacement +replacements +replacer +replaces +replacing +replay +replayed +replaying +replays +replenish +replenished +replenishes +replenishing +replete +repleteness +repletion +replica +replicas +replicate +replicated +replicates +replicating +replication +replications +replied +replies +reply +replying +report +reported +reportedly +reporter +reporters +reporting +reports +repose +reposed +reposes +reposing +reposition +repositioned +repositioning +repositions +repositories +repository +reprehensible +represent +representable +representably +representation +representational +representationally +representations +representative +representatively +representativeness +representatives +represented +representing +represents +repress +repressed +represses +repressing +repression +repressions +repressive +reprieve +reprieved +reprieves +reprieving +reprimand +reprint +reprinted +reprinting +reprints +reprisal +reprisals +reproach +reproached +reproaches +reproaching +reprobate +reproduce +reproduced +reproducer +reproducers +reproduces +reproducibilities +reproducibility +reproducible +reproducibly +reproducing +reproduction +reproductions +reprogram +reprogrammed +reprogramming +reprograms +reproof +reprove +reprover +reptile +reptiles +reptilian +republic +republican +republicans +republics +repudiate +repudiated +repudiates +repudiating +repudiation +repudiations +repugnant +repulse +repulsed +repulses +repulsing +repulsion +repulsions +repulsive +reputable +reputably +reputation +reputations +repute +reputed +reputedly +reputes +request +requested +requester +requesters +requesting +requests +require +required +requirement +requirements +requires +requiring +requisite +requisites +requisition +requisitioned +requisitioning +requisitions +reread +reregister +reroute +rerouted +reroutes +rerouting +rerun +reruns +reschedule +rescind +rescue +rescued +rescuer +rescuers +rescues +rescuing +research +researched +researcher +researchers +researches +researching +reselect +reselected +reselecting +reselects +resell +reselling +resemblance +resemblances +resemble +resembled +resembles +resembling +resent +resented +resentful +resentfully +resenting +resentment +resents +reserpine +reservation +reservations +reserve +reserved +reserver +reserves +reserving +reservoir +reservoirs +reset +resets +resetting +resettings +reside +resided +residence +residences +resident +residential +residentially +residents +resides +residing +residual +residue +residues +resign +resignation +resignations +resigned +resigning +resigns +resilient +resin +resins +resist +resistable +resistance +resistances +resistant +resistantly +resisted +resistible +resisting +resistive +resistivity +resistor +resistors +resists +resolute +resolutely +resoluteness +resolution +resolutions +resolvable +resolve +resolved +resolver +resolvers +resolves +resolving +resonance +resonances +resonant +resonate +resort +resorted +resorting +resorts +resound +resounding +resounds +resource +resourceful +resourcefully +resourcefulness +resources +respect +respectability +respectable +respectably +respected +respecter +respectful +respectfully +respectfulness +respecting +respective +respectively +respects +respiration +respirator +respiratory +respite +resplendent +resplendently +respond +responded +respondent +respondents +responder +responding +responds +response +responses +responsibilities +responsibility +responsible +responsibleness +responsibly +responsive +responsively +responsiveness +rest +restart +restarted +restarting +restarts +restate +restated +restatement +restates +restating +restaurant +restaurants +restaurateur +rested +restful +restfully +restfulness +resting +restitution +restive +restless +restlessly +restlessness +restoration +restorations +restore +restored +restorer +restorers +restores +restoring +restrain +restrained +restrainer +restrainers +restraining +restrains +restraint +restraints +restrict +restricted +restricting +restriction +restrictions +restrictive +restrictively +restricts +restroom +restructure +restructured +restructures +restructuring +rests +result +resultant +resultantly +resultants +resulted +resulting +results +resumable +resume +resumed +resumes +resuming +resumption +resumptions +resurgent +resurrect +resurrected +resurrecting +resurrection +resurrections +resurrector +resurrectors +resurrects +resuscitate +resynchronization +resynchronize +resynchronized +resynchronizing +retail +retailer +retailers +retailing +retain +retained +retainer +retainers +retaining +retainment +retains +retaliate +retaliation +retaliatory +retard +retarded +retarder +retarding +retch +retention +retentions +retentive +retentively +retentiveness +reticle +reticles +reticular +reticulate +reticulated +reticulately +reticulates +reticulating +reticulation +retina +retinal +retinas +retinue +retire +retired +retiree +retirement +retirements +retires +retiring +retort +retorted +retorts +retrace +retraced +retraces +retracing +retract +retracted +retracting +retraction +retractions +retracts +retrain +retrained +retraining +retrains +retranslate +retranslated +retransmission +retransmissions +retransmit +retransmits +retransmitted +retransmitting +retreat +retreated +retreating +retreats +retribution +retried +retrier +retriers +retries +retrievable +retrieval +retrievals +retrieve +retrieved +retriever +retrievers +retrieves +retrieving +retroactive +retroactively +retrofit +retrofitting +retrograde +retrospect +retrospection +retrospective +retry +retrying +return +returnable +returned +returner +returning +returns +retype +retyped +retypes +retyping +Reub +Reuben +reunion +reunions +reunite +reunited +reuniting +reusable +reuse +reused +reuses +reusing +Reuters +Reuther +revamp +revamped +revamping +revamps +reveal +revealed +revealing +reveals +revel +revelation +revelations +reveled +reveler +reveling +revelry +revels +revenge +revenger +revenue +revenuers +revenues +reverberate +revere +revered +reverence +reverend +reverends +reverent +reverently +reveres +reverie +reverified +reverifies +reverify +reverifying +revering +reversal +reversals +reverse +reversed +reversely +reverser +reverses +reversible +reversing +reversion +revert +reverted +reverting +reverts +review +reviewed +reviewer +reviewers +reviewing +reviews +revile +reviled +reviler +reviling +revise +revised +reviser +revises +revising +revision +revisionary +revisions +revisit +revisited +revisiting +revisits +revival +revivals +revive +revived +reviver +revives +reviving +revocable +revocation +revoke +revoked +revoker +revokes +revoking +revolt +revolted +revolter +revolting +revoltingly +revolts +revolution +revolutionaries +revolutionary +revolutionize +revolutionized +revolutionizer +revolutions +revolve +revolved +revolver +revolvers +revolves +revolving +revulsion +reward +rewarded +rewarding +rewardingly +rewards +rewind +rewinding +rewinds +rewire +rework +reworked +reworking +reworks +rewound +rewrite +rewrites +rewriting +rewritten +Rex +Reykjavik +Reynolds +rhapsody +Rhea +Rheims +Rheinholdt +Rhenish +rhesus +rhetoric +rheumatic +rheumatism +Rhine +rhinestone +rhino +rhinoceros +rho +Rhoda +Rhode +Rhodes +Rhodesia +rhododendron +rhombic +rhombus +rhubarb +rhyme +rhymed +rhymes +rhyming +rhythm +rhythmic +rhythmically +rhythms +rib +ribald +ribbed +ribbing +ribbon +ribbons +riboflavin +ribonucleic +ribs +Rica +Rican +Ricanism +Ricans +rice +rich +Richard +Richards +Richardson +richer +riches +richest +Richey +Richfield +Richland +richly +Richmond +richness +Richter +Rick +Rickenbaugh +rickets +Rickettsia +rickety +rickshaw +rickshaws +Rico +ricochet +rid +riddance +ridden +ridding +riddle +riddled +riddles +riddling +ride +rider +riders +rides +ridge +Ridgefield +ridgepole +ridges +Ridgway +ridicule +ridiculed +ridicules +ridiculing +ridiculous +ridiculously +ridiculousness +riding +rids +Riemann +Riemannian +rifle +rifled +rifleman +rifler +rifles +rifling +rift +rig +Riga +Rigel +rigging +Riggs +right +righted +righteous +righteously +righteousness +righter +rightful +rightfully +rightfulness +righting +rightly +rightmost +rightness +rights +rightward +rigid +rigidity +rigidly +rigor +rigorous +rigorously +rigors +rigs +Riley +Rilke +rill +rim +rime +rims +rind +rinds +Rinehart +ring +ringed +ringer +ringers +ringing +ringingly +ringings +rings +ringside +rink +rinse +rinsed +rinser +rinses +rinsing +Rio +Riordan +riot +rioted +rioter +rioters +rioting +riotous +riots +rip +ripe +ripely +ripen +ripeness +Ripley +ripoff +ripped +ripping +ripple +rippled +ripples +rippling +rips +RISC +rise +risen +riser +risers +rises +rising +risings +risk +risked +risking +risks +risky +Ritchie +rite +rites +Ritter +ritual +ritually +rituals +Ritz +rival +rivaled +rivalled +rivalling +rivalries +rivalry +rivals +river +riverbank +riverfront +rivers +riverside +Riverview +rivet +riveter +rivets +Riviera +rivulet +rivulets +Riyadh +roach +road +roadbed +roadblock +roads +roadside +roadster +roadsters +roadway +roadways +roam +roamed +roaming +roams +roar +roared +roarer +roaring +roars +roast +roasted +roaster +roasting +roasts +rob +robbed +robber +robberies +robbers +robbery +Robbie +Robbin +robbing +Robbins +robe +robed +Robert +Roberta +Roberto +Roberts +Robertson +Robertsons +robes +robin +robing +robins +Robinson +Robinsonville +robot +robotic +robotics +robots +robs +robust +robustly +robustness +Rocco +Rochester +Rochford +rock +rockabye +Rockaway +Rockaways +rocked +Rockefeller +rocker +rockers +rocket +rocketed +rocketing +rockets +Rockford +Rockies +rocking +Rockland +rocks +Rockville +Rockwell +rocky +rod +rode +rodent +rodents +rodeo +Rodgers +Rodney +Rodriguez +rods +roe +Roentgen +Roger +Rogers +rogue +rogues +Roland +role +roles +roll +rollback +rolled +roller +rollers +Rollie +rolling +Rollins +rolls +Roman +romance +romancer +romancers +romances +romancing +Romanesque +Romania +Romanizations +Romanizer +Romanizers +Romanizes +Romano +Romans +romantic +romantics +Rome +Romeldale +Romeo +romp +romped +romper +romping +romps +Romulus +Ron +Ronald +Ronnie +roof +roofed +roofer +roofing +roofs +rooftop +rook +rookie +room +roomed +roomer +roomers +roomful +rooming +roommate +rooms +roomy +Rooney +Roosevelt +Rooseveltian +roost +rooster +roosters +root +rooted +rooter +rooting +roots +rope +roped +roper +ropers +ropes +roping +Roquemore +Rorschach +Rosa +Rosabelle +Rosalie +rosary +Rose +rosebud +rosebuds +rosebush +Roseland +Rosella +rosemary +Rosen +Rosenberg +Rosenblum +Rosenthal +Rosenzweig +roses +Rosetta +rosette +Rosie +rosiness +Ross +Rossi +roster +rostrum +Roswell +rosy +rot +Rotarian +Rotarians +rotary +rotate +rotated +rotates +rotating +rotation +rotational +rotations +rotator +Roth +Rothschild +rotor +rots +rotten +rottenness +Rotterdam +rotting +rotund +rotunda +rouge +rough +roughed +roughen +rougher +roughest +roughly +roughneck +roughness +roulette +round +roundabout +rounded +roundedness +rounder +roundest +roundhead +roundhouse +rounding +roundly +roundness +roundoff +rounds +roundtable +roundup +roundworm +Rourke +rouse +roused +rouses +rousing +Rousseau +roustabout +rout +route +routed +router +routers +routes +routine +routinely +routines +routing +routings +rove +roved +rover +roves +roving +row +rowboat +rowdy +Rowe +rowed +Rowena +rower +rowing +Rowland +Rowley +rows +Roxbury +Roxy +Roy +royal +royalist +royalists +royally +royalties +royalty +Royce +Rozelle +Ruanda +rub +Rubaiyat +rubbed +rubber +rubbers +rubbery +rubbing +rubbish +rubble +rubdown +Rube +Ruben +Rubens +rubies +Rubin +ruble +rubles +rubout +rubs +ruby +rudder +rudders +ruddiness +ruddy +rude +rudely +rudeness +rudiment +rudimentary +rudiments +Rudolf +Rudolph +Rudy +Rudyard +rue +ruefully +ruffian +ruffianly +ruffians +ruffle +ruffled +ruffles +Rufus +rug +rugged +ruggedly +ruggedness +rugs +ruin +ruination +ruinations +ruined +ruining +ruinous +ruinously +ruins +rule +ruled +ruler +rulers +rules +ruling +rulings +rum +Rumania +Rumanian +Rumanians +rumble +rumbled +rumbler +rumbles +rumbling +rumen +Rumford +rummage +Rummel +rummy +rumor +rumored +rumors +rump +rumple +rumpled +rumply +rumpus +run +runaway +rundown +rung +Runge +rungs +runnable +runner +runners +running +Runnymede +runoff +runs +runt +runtime +Runyon +rupee +Ruppert +rupture +ruptured +ruptures +rupturing +rural +rurally +rush +rushed +rusher +rushes +rushing +Rushmore +Russ +Russell +russet +Russia +Russian +Russianizations +Russianizes +Russians +Russo +rust +rusted +rustic +rusticate +rusticated +rusticates +rusticating +rustication +rusting +rustle +rustled +rustler +rustlers +rustling +rusts +rusty +rut +Rutgers +Ruth +Rutherford +ruthless +ruthlessly +ruthlessness +Rutland +Rutledge +ruts +Rwanda +Ryan +Rydberg +Ryder +rye +sabbath +Sabbathize +Sabbathizes +sabbatical +saber +sabers +Sabina +Sabine +sable +sables +sabotage +Sachs +sack +sacker +sacking +sacks +sacrament +Sacramento +sacred +sacredly +sacredness +sacrifice +sacrificed +sacrificer +sacrificers +sacrifices +sacrificial +sacrificially +sacrificing +sacrilege +sacrilegious +sacrosanct +sad +sadden +saddened +saddens +sadder +saddest +saddle +saddlebag +saddled +saddles +Sadie +sadism +sadist +sadistic +sadistically +sadists +Sadler +sadly +sadness +safari +safe +safeguard +safeguarded +safeguarding +safeguards +safekeeping +safely +safeness +safer +safes +safest +safeties +safety +saffron +sag +saga +sagacious +sagacity +sage +sagebrush +sagely +sages +sagging +Saginaw +sagittal +Sagittarius +sags +saguaro +Sahara +said +Saigon +sail +sailboat +sailed +sailfish +sailing +sailor +sailorly +sailors +sails +saint +sainted +sainthood +saintly +saints +sake +sakes +Sal +Salaam +salable +salad +salads +salamander +salami +salaried +salaries +salary +sale +Salem +Salerno +sales +salesgirl +Salesian +saleslady +salesman +salesmen +salesperson +salient +Salina +saline +Salisbury +Salish +saliva +salivary +salivate +Salk +Salle +sallies +sallow +Sally +sallying +salmon +salon +salons +saloon +saloons +salt +salted +salter +salters +saltier +saltiest +saltiness +salting +Salton +salts +salty +salutary +salutation +salutations +salute +saluted +salutes +saluting +Salvador +Salvadoran +salvage +salvaged +salvager +salvages +salvaging +salvation +Salvatore +salve +salver +salves +Salz +Sam +Samaritan +same +sameness +Sammy +Samoa +Samoan +sample +sampled +sampler +samplers +samples +sampling +samplings +Sampson +Samson +Samuel +Samuels +Samuelson +San +Sana +sanatoria +sanatorium +Sanborn +Sanchez +Sancho +sanctification +sanctified +sanctify +sanctimonious +sanction +sanctioned +sanctioning +sanctions +sanctity +sanctuaries +sanctuary +sanctum +sand +sandal +sandals +sandbag +Sandburg +sanded +sander +Sanderling +Sanders +Sanderson +Sandia +sanding +sandman +sandpaper +Sandra +sands +sandstone +Sandusky +sandwich +sandwiches +sandy +sane +sanely +saner +sanest +Sanford +sang +sanguine +Sanhedrin +sanitarium +sanitary +sanitation +sanity +sank +Sanskrit +Sanskritic +Sanskritize +Santa +Santayana +Santiago +Santo +Sao +sap +sapiens +sapling +saplings +sapphire +Sappho +saps +sapsucker +Sara +Saracen +Saracens +Sarah +Saran +Sarasota +Saratoga +sarcasm +sarcasms +sarcastic +sardine +Sardinia +sardonic +Sargent +sari +Sartre +sash +Saskatchewan +Saskatoon +sat +Satan +satanic +Satanism +Satanist +satchel +satchels +sate +sated +satellite +satellites +sates +satin +sating +satire +satires +satiric +satisfaction +satisfactions +satisfactorily +satisfactory +satisfiability +satisfiable +satisfied +satisfies +satisfy +satisfying +saturate +saturated +saturates +saturating +saturation +Saturday +Saturdays +Saturn +Saturnalia +Saturnism +satyr +sauce +saucepan +saucepans +saucer +saucers +sauces +saucy +Saud +Saudi +Saukville +Saul +Sault +Saunders +saunter +sausage +sausages +savage +savaged +savagely +savageness +savager +savagers +savages +savaging +Savannah +save +saved +saver +savers +saves +saving +savings +savior +saviors +Saviour +Savonarola +savor +savored +savoring +savors +savory +Savoy +Savoyard +Savoyards +saw +sawdust +sawed +sawfish +sawing +sawmill +sawmills +saws +sawtooth +sax +Saxon +Saxonization +Saxonizations +Saxonize +Saxonizes +Saxons +Saxony +saxophone +Saxton +say +sayer +sayers +saying +sayings +says +scab +scabbard +scabbards +scabrous +scaffold +scaffolding +scaffoldings +scaffolds +Scala +scalable +scalar +scalars +scald +scalded +scalding +scale +scaled +scales +scaling +scalings +scallop +scalloped +scallops +scalp +scalps +scaly +scamper +scampering +scampers +scan +scandal +scandalous +scandals +Scandinavia +Scandinavian +Scandinavians +scanned +scanner +scanners +scanning +scans +scant +scantier +scantiest +scantily +scantiness +scantly +scanty +scapegoat +scar +Scarborough +scarce +scarcely +scarceness +scarcer +scarcity +scare +scarecrow +scared +scares +scarf +scaring +Scarlatti +scarlet +scars +Scarsdale +scarves +scary +scatter +scatterbrain +scattered +scattering +scatters +scenario +scenarios +scene +scenery +scenes +scenic +scent +scented +scents +scepter +scepters +Schaefer +Schaeffer +Schafer +Schaffner +Schantz +Schapiro +schedulable +schedule +scheduled +scheduler +schedulers +schedules +scheduling +Scheherazade +Schelling +schema +schemas +schemata +schematic +schematically +schematics +scheme +schemed +schemer +schemers +schemes +scheming +Schiller +schism +schizophrenia +Schlesinger +Schlitz +Schloss +Schmidt +Schmitt +Schnabel +Schneider +Schoenberg +Schofield +scholar +scholarly +scholars +scholarship +scholarships +scholastic +scholastically +scholastics +school +schoolboy +schoolboys +schooled +schooler +schoolers +schoolhouse +schoolhouses +schooling +schoolmaster +schoolmasters +schoolroom +schoolrooms +schools +schooner +Schopenhauer +Schottky +Schroeder +Schroedinger +Schubert +Schultz +Schulz +Schumacher +Schuman +Schumann +Schuster +Schuyler +Schuylkill +Schwab +Schwartz +Schweitzer +science +sciences +scientific +scientifically +scientist +scientists +scissor +scissored +scissoring +scissors +sclerosis +sclerotic +scoff +scoffed +scoffer +scoffing +scoffs +scold +scolded +scolding +scolds +scoop +scooped +scooping +scoops +scoot +scope +scoped +scopes +scoping +scorch +scorched +scorcher +scorches +scorching +score +scoreboard +scorecard +scored +scorer +scorers +scores +scoring +scorings +scorn +scorned +scorner +scornful +scornfully +scorning +scorns +Scorpio +scorpion +scorpions +Scot +scotch +Scotchgard +Scotchman +Scotia +Scotian +Scotland +Scots +Scotsman +Scotsmen +Scott +Scottish +Scottsdale +Scotty +scoundrel +scoundrels +scour +scoured +scourge +scouring +scours +scout +scouted +scouting +scouts +scow +scowl +scowled +scowling +scowls +scram +scramble +scrambled +scrambler +scrambles +scrambling +Scranton +scrap +scrape +scraped +scraper +scrapers +scrapes +scraping +scrapings +scrapped +scraps +scratch +scratched +scratcher +scratchers +scratches +scratching +scratchy +scrawl +scrawled +scrawling +scrawls +scrawny +scream +screamed +screamer +screamers +screaming +screams +screech +screeched +screeches +screeching +screen +screened +screening +screenings +screenplay +screens +screw +screwball +screwdriver +screwed +screwing +screws +scribble +scribbled +scribbler +scribbles +scribe +scribes +scribing +Scribners +scrimmage +Scripps +script +scripts +scripture +scriptures +scroll +scrolled +scrolling +scrolls +Scrooge +scrounge +scrub +scrumptious +scruple +scrupulous +scrupulously +scrutinize +scrutinized +scrutinizing +scrutiny +scuba +scud +scuffle +scuffled +scuffles +scuffling +sculpt +sculpted +sculptor +sculptors +sculpts +sculpture +sculptured +sculptures +scurried +scurry +scurvy +scuttle +scuttled +scuttles +scuttling +Scylla +scythe +scythes +Scythia +sea +seaboard +Seaborg +Seabrook +seacoast +seacoasts +seafood +Seagate +Seagram +seagull +seahorse +seal +sealed +sealer +sealing +seals +sealy +seam +seaman +seamed +seamen +seaming +seams +seamy +Sean +seaport +seaports +Seaquarium +sear +search +searched +searcher +searchers +searches +searching +searchingly +searchings +searchlight +seared +searing +searingly +Sears +seas +seashore +seashores +seaside +season +seasonable +seasonably +seasonal +seasonally +seasoned +seasoner +seasoners +seasoning +seasonings +seasons +seat +seated +seating +seats +Seattle +seaward +seaweed +Sebastian +secant +secede +seceded +secedes +seceding +secession +seclude +secluded +seclusion +second +secondaries +secondarily +secondary +seconded +seconder +seconders +secondhand +seconding +secondly +seconds +secrecy +secret +secretarial +secretariat +secretaries +secretary +secrete +secreted +secretes +secreting +secretion +secretions +secretive +secretively +secretly +secrets +sect +sectarian +section +sectional +sectioned +sectioning +sections +sector +sectors +sects +secular +secure +secured +securely +secures +securing +securings +securities +security +sedan +sedate +sedge +Sedgwick +sediment +sedimentary +sediments +sedition +seditious +seduce +seduced +seducer +seducers +seduces +seducing +seduction +seductive +see +seed +seeded +seeder +seeders +seeding +seedings +seedling +seedlings +seeds +seedy +seeing +seek +seeker +seekers +seeking +seeks +Seeley +seem +seemed +seeming +seemingly +seemly +seems +seen +seep +seepage +seeped +seeping +seeps +seer +seers +seersucker +sees +seethe +seethed +seethes +seething +segment +segmentation +segmentations +segmented +segmenting +segments +Segovia +segregate +segregated +segregates +segregating +segregation +Segundo +Seidel +seismic +seismograph +seismology +seize +seized +seizes +seizing +seizure +seizures +seldom +select +selected +selecting +selection +selections +selective +selectively +selectivity +selectman +selectmen +selector +selectors +Selectric +selects +Selena +selenium +self +selfish +selfishly +selfishness +Selfridge +selfsame +Selkirk +sell +seller +sellers +selling +sellout +sells +Selma +seltzer +selves +Selwyn +semantic +semantical +semantically +semanticist +semanticists +semantics +semaphore +semaphores +semblance +semester +semesters +semi +semiautomated +semicolon +semicolons +semiconductor +semiconductors +seminal +seminar +seminarian +seminaries +seminars +seminary +Seminole +semipermanent +semipermanently +Semiramis +Semite +Semitic +Semiticize +Semiticizes +Semitization +Semitizations +Semitize +Semitizes +senate +senates +senator +senatorial +senators +send +sender +senders +sending +sends +Seneca +Senegal +senile +senior +seniority +seniors +sensation +sensational +sensationally +sensations +sense +sensed +senseless +senselessly +senselessness +senses +sensibilities +sensibility +sensible +sensibly +sensing +sensitive +sensitively +sensitiveness +sensitives +sensitivities +sensitivity +sensor +sensors +sensory +sensual +sensuous +sent +sentence +sentenced +sentences +sentencing +sentential +sentiment +sentimental +sentimentally +sentiments +sentinel +sentinels +sentries +sentry +Seoul +separable +separate +separated +separately +separateness +separates +separating +separation +separations +separator +separators +sepia +Sepoy +sept +September +Septembers +sepulcher +sepulchers +sequel +sequels +sequence +sequenced +sequencer +sequencers +sequences +sequencing +sequencings +sequential +sequentiality +sequentialize +sequentialized +sequentializes +sequentializing +sequentially +sequester +Sequoia +Serafin +Serbia +Serbian +Serbians +Serbo- +serendipitous +serendipity +serene +serenely +serenity +serf +serfs +sergeant +sergeants +Sergei +serial +serializability +serializable +serialization +serializations +serialize +serialized +serializes +serializing +serially +serials +series +serif +serious +seriously +seriousness +sermon +sermons +Serpens +serpent +serpentine +serpents +Serra +serum +serums +servant +servants +serve +served +server +servers +serves +service +serviceability +serviceable +serviced +serviceman +servicemen +services +servicing +servile +serving +servings +servitude +servo +servomechanism +sesame +session +sessions +set +setback +Seth +sets +settable +setter +setters +setting +settings +settle +settled +settlement +settlements +settler +settlers +settles +settling +setup +setups +seven +sevenfold +sevens +seventeen +seventeens +seventeenth +seventh +seventies +seventieth +seventy +sever +several +severalfold +severally +severance +severe +severed +severely +severer +severest +severing +severities +severity +Severn +severs +Seville +sew +sewage +Seward +sewed +sewer +sewers +sewing +sews +sex +sexed +sexes +sexist +Sextans +sextet +sextillion +sexton +sextuple +sextuplet +sexual +sexuality +sexually +sexy +Seychelles +Seymour +shabby +shack +shacked +shackle +shackled +shackles +shackling +shacks +shade +shaded +shades +shadier +shadiest +shadily +shadiness +shading +shadings +shadow +shadowed +shadowing +shadows +shadowy +shady +Shafer +Shaffer +shaft +shafts +shaggy +shakable +shakably +shake +shakedown +shaken +shaker +shakers +shakes +Shakespeare +Shakespearean +Shakespearian +Shakespearize +Shakespearizes +shakiness +shaking +shaky +shale +shall +shallow +shallower +shallowly +shallowness +sham +shambles +shame +shamed +shameful +shamefully +shameless +shamelessly +shames +shaming +shampoo +shamrock +shams +Shanghai +Shanghaied +Shanghaiing +Shanghaiings +Shanghais +Shannon +shanties +Shantung +shanty +shape +shaped +shapeless +shapelessly +shapelessness +shapely +shaper +shapers +shapes +shaping +Shapiro +sharable +shard +share +shareable +sharecropper +sharecroppers +shared +shareholder +shareholders +sharer +sharers +shares +Shari +sharing +shark +sharks +Sharon +sharp +Sharpe +sharpen +sharpened +sharpening +sharpens +sharper +sharpest +sharply +sharpness +sharpshoot +Shasta +shatter +shattered +shattering +shatterproof +shatters +Shattuck +shave +shaved +shaven +shaves +shaving +shavings +Shawano +shawl +shawls +Shawnee +she +Shea +sheaf +shear +sheared +Shearer +shearing +shears +sheath +sheathing +sheaths +sheaves +Sheboygan +shed +shedding +Shedir +sheds +Sheehan +sheen +sheep +sheepskin +sheer +sheered +sheet +sheeted +sheeting +sheets +Sheffield +sheik +Sheila +Shelby +Sheldon +shelf +shell +shelled +sheller +Shelley +shelling +shells +shelter +sheltered +sheltering +shelters +Shelton +shelve +shelved +shelves +shelving +Shenandoah +shenanigan +Shepard +shepherd +shepherds +Sheppard +Sheraton +sherbet +Sheridan +sheriff +sheriffs +Sherlock +Sherman +Sherrill +sherry +Sherwin +Sherwood +shibboleth +shied +shield +shielded +shielding +Shields +shies +shift +shifted +shifter +shifters +shiftier +shiftiest +shiftily +shiftiness +shifting +shifts +shifty +Shiite +Shiites +shill +shilling +shillings +Shillong +Shiloh +shimmer +shimmering +shin +shinbone +shine +shined +shiner +shiners +shines +shingle +shingles +shining +shiningly +Shinto +Shintoism +Shintoize +Shintoizes +shiny +ship +shipboard +shipbuilding +Shipley +shipmate +shipment +shipments +shipped +shipper +shippers +shipping +ships +shipshape +shipwreck +shipwrecked +shipwrecks +shipyard +shire +shirk +shirker +shirking +shirks +Shirley +shirt +shirting +shirts +shit +Shiva +shiver +shivered +shiverer +shivering +shivers +Shmuel +shoal +shoals +shock +shocked +shocker +shockers +shocking +shockingly +Shockley +shocks +shod +shoddy +shoe +shoed +shoehorn +shoeing +shoelace +shoemaker +shoes +shoestring +Shoji +shone +shook +shoot +shooter +shooters +shooting +shootings +shoots +shop +shopkeeper +shopkeepers +shopped +shopper +shoppers +shopping +shops +shopworn +shore +shoreline +shores +Shorewood +shorn +short +shortage +shortages +shortcoming +shortcomings +shortcut +shortcuts +shorted +shorten +shortened +shortening +shortens +shorter +shortest +shortfall +shorthand +shorthanded +shorting +shortish +shortly +shortness +shorts +shortsighted +shortstop +Shoshone +shot +shotgun +shotguns +shots +should +shoulder +shouldered +shouldering +shoulders +shout +shouted +shouter +shouters +shouting +shouts +shove +shoved +shovel +shoveled +shovels +shoves +shoving +show +showboat +showcase +showdown +showed +shower +showered +showering +showers +showing +showings +shown +showpiece +showroom +shows +showy +shrank +shrapnel +shred +shredder +shredding +shreds +Shreveport +shrew +shrewd +shrewdest +shrewdly +shrewdness +shrews +shriek +shrieked +shrieking +shrieks +shrill +shrilled +shrilling +shrillness +shrilly +shrimp +shrine +shrines +shrink +shrinkable +shrinkage +shrinking +shrinks +shrivel +shriveled +shroud +shrouded +shrub +shrubbery +shrubs +shrug +shrugs +shrunk +shrunken +Shu +shudder +shuddered +shuddering +shudders +shuffle +shuffleboard +shuffled +shuffles +shuffling +Shulman +shun +shuns +shunt +shut +shutdown +shutdowns +shutoff +shutout +shuts +shutter +shuttered +shutters +shutting +shuttle +shuttlecock +shuttled +shuttles +shuttling +shy +Shylock +Shylockian +shyly +shyness +Siam +Siamese +Sian +Siberia +Siberian +Sibley +sibling +siblings +Sicilian +Siciliana +Sicilians +Sicily +sick +sicken +sicker +sickest +sickle +sickly +sickness +sicknesses +sickroom +side +sidearm +sideband +sideboard +sideboards +sideburns +sidecar +sided +sidelight +sidelights +sideline +sidereal +sides +sidesaddle +sideshow +sidestep +sidetrack +sidewalk +sidewalks +sideways +sidewise +siding +sidings +Sidney +siege +Siegel +sieges +Siegfried +Sieglinda +Siegmund +Siemens +Siena +sierra +sieve +sieves +Sifford +sift +sifted +sifter +sifting +SIGGRAPH +sigh +sighed +sighing +sighs +sight +sighted +sighting +sightings +sightly +sights +sightseeing +sigma +Sigmund +sign +signal +signaled +signaling +signalled +signalling +signally +signals +signature +signatures +signed +signer +signers +signet +significance +significant +significantly +significants +signification +signified +signifies +signify +signifying +signing +signs +Sikh +Sikhes +Sikhs +Sikkim +Sikkimese +Sikorsky +Silas +silence +silenced +silencer +silencers +silences +silencing +silent +silently +silhouette +silhouetted +silhouettes +silica +silicate +silicon +silicone +silk +silken +silkier +silkiest +silkily +Silkine +silks +silky +sill +silliest +silliness +sills +silly +silo +silt +silted +silting +silts +silver +silvered +silvering +Silverman +silvers +silversmith +Silverstein +silverware +silvery +similar +similarities +similarity +similarly +simile +similitude +Simla +simmer +simmered +simmering +simmers +Simmons +Simmonsville +Simms +Simon +Simons +Simonson +simple +simpleminded +simpleness +simpler +simplest +simpleton +simplex +simplicities +simplicity +simplification +simplifications +simplified +simplifier +simplifiers +simplifies +simplify +simplifying +simplistic +simply +Simpson +Sims +SIMULA +Simula +simulate +simulated +simulates +simulating +simulation +simulations +simulator +simulators +simulcast +simultaneity +simultaneous +simultaneously +Sinai +Sinatra +Sinbad +since +sincere +sincerely +sincerest +sincerity +Sinclair +sine +sines +sinew +sinews +sinewy +sinful +sinfully +sinfulness +sing +singable +Singapore +Singborg +singe +singed +singer +singers +singing +singingly +single +singled +singlehanded +singleness +singles +singlet +singleton +singletons +singling +singly +sings +singsong +singular +singularities +singularity +singularly +sinister +sink +sinked +sinker +sinkers +sinkhole +sinking +sinks +sinned +sinner +sinners +sinning +Sino- +sins +sinuous +sinus +sinusoid +sinusoidal +sinusoids +Sioux +sip +siphon +siphoning +sipping +sips +sir +sire +sired +siren +sirens +sires +Sirius +sirs +sirup +sister +sisterly +sisters +Sistine +Sisyphean +Sisyphus +sit +site +sited +sites +siting +sits +sitter +sitters +sitting +sittings +situ +situate +situated +situates +situating +situation +situational +situationally +situations +Siva +six +sixes +sixfold +sixgun +sixpence +sixteen +sixteens +sixteenth +sixth +sixties +sixtieth +sixty +sizable +size +sized +sizes +sizing +sizings +sizzle +skate +skated +skater +skaters +skates +skating +skeletal +skeleton +skeletons +skeptic +skeptical +skeptically +skepticism +skeptics +sketch +sketchbook +sketched +sketches +sketchily +sketching +sketchpad +sketchy +skew +skewed +skewer +skewers +skewing +skews +ski +skid +skidding +skied +skies +skiff +skiing +skill +skilled +skillet +skillful +skillfully +skillfulness +skills +skim +skimmed +skimming +skimp +skimped +skimping +skimps +skimpy +skims +skin +skindive +skinned +skinner +skinners +skinning +skinny +skins +skip +skipped +skipper +skippers +skipping +Skippy +skips +skirmish +skirmished +skirmisher +skirmishers +skirmishes +skirmishing +skirt +skirted +skirting +skirts +skis +skit +Skopje +skulk +skulked +skulker +skulking +skulks +skull +skullcap +skullduggery +skulls +skunk +skunks +sky +Skye +skyhook +skyjack +skylark +skylarking +skylarks +skylight +skylights +skyline +skyrockets +skyscraper +skyscrapers +slab +slack +slacken +slacker +slacking +slackly +slackness +slacks +slain +slam +slammed +slamming +slams +slander +slanderer +slanderous +slanders +slang +slant +slanted +slanting +slants +slap +slapped +slapping +slaps +slapstick +slash +slashed +slashes +slashing +slat +slate +slated +slater +slates +slats +slaughter +slaughtered +slaughterhouse +slaughtering +slaughters +Slav +slave +slaver +slavery +slaves +Slavic +Slavicize +Slavicizes +slavish +Slavization +Slavizations +Slavize +Slavizes +Slavonic +Slavonicize +Slavonicizes +Slavs +slay +slayer +slayers +slaying +slays +sled +sledding +sledge +sledgehammer +sledges +sleds +sleek +sleep +sleeper +sleepers +sleepily +sleepiness +sleeping +sleepless +sleeplessly +sleeplessness +sleeps +sleepwalk +sleepy +sleet +sleeve +sleeves +sleigh +sleighs +sleight +slender +slenderer +slept +Slesinger +sleuth +slew +slewing +slice +sliced +slicer +slicers +slices +slicing +slick +slicker +slickers +slicks +slid +slide +slider +sliders +slides +sliding +slight +slighted +slighter +slightest +slighting +slightly +slightness +slights +slim +slime +slimed +slimly +slimy +sling +slinging +slings +slingshot +slip +slippage +slipped +slipper +slipperiness +slippers +slippery +slipping +slips +slit +slither +slits +sliver +Sloan +Sloane +slob +Slocum +slogan +slogans +sloop +slop +slope +sloped +sloper +slopers +slopes +sloping +slopped +sloppiness +slopping +sloppy +slops +slot +sloth +slothful +sloths +slots +slotted +slotting +slouch +slouched +slouches +slouching +Slovakia +Slovenia +slow +slowdown +slowed +slower +slowest +slowing +slowly +slowness +slows +sludge +slug +sluggish +sluggishly +sluggishness +slugs +sluice +slum +slumber +slumbered +slumming +slump +slumped +slumps +slums +slung +slur +slurp +slurring +slurry +slurs +sly +slyly +smack +smacked +smacking +smacks +small +smaller +smallest +Smalley +smallish +smallness +smallpox +smalltime +Smallwood +smart +smarted +smarter +smartest +smartly +smartness +smash +smashed +smasher +smashers +smashes +smashing +smashingly +smattering +smear +smeared +smearing +smears +smell +smelled +smelling +smells +smelly +smelt +smelter +smelts +smile +smiled +smiles +smiling +smilingly +smirk +smite +smith +smithereens +Smithfield +smiths +Smithson +Smithsonian +Smithtown +smithy +smitten +smock +smocking +smocks +smog +smokable +smoke +smoked +smoker +smokers +smokes +smokescreen +smokestack +smokies +smoking +smoky +smolder +smoldered +smoldering +smolders +smooch +smooth +smoothbore +smoothed +smoother +smoothes +smoothest +smoothing +smoothly +smoothness +smote +smother +smothered +smothering +smothers +Smucker +smudge +smug +smuggle +smuggled +smuggler +smugglers +smuggles +smuggling +smut +smutty +Smyrna +Smythe +snack +snafu +snag +snail +snails +snake +snaked +snakelike +snakes +snap +snapdragon +snapped +snapper +snappers +snappily +snapping +snappy +snaps +snapshot +snapshots +snare +snared +snares +snaring +snark +snarl +snarled +snarling +snatch +snatched +snatches +snatching +snazzy +Snead +sneak +sneaked +sneaker +sneakers +sneakier +sneakiest +sneakily +sneakiness +sneaking +sneaks +sneaky +Sneed +sneer +sneered +sneering +sneers +sneeze +sneezed +sneezes +sneezing +Snider +sniff +sniffed +sniffing +sniffle +sniffs +snifter +snigger +snip +snipe +snippet +snivel +snob +snobbery +snobbish +Snodgrass +snoop +snooped +snooping +snoops +snoopy +snore +snored +snores +snoring +snorkel +snort +snorted +snorting +snorts +snotty +snout +snouts +snow +snowball +Snowbelt +snowed +snowfall +snowflake +snowier +snowiest +snowily +snowing +snowman +snowmen +snows +snowshoe +snowshoes +snowstorm +snowy +snub +snuff +snuffed +snuffer +snuffing +snuffs +snug +snuggle +snuggled +snuggles +snuggling +snugly +snugness +Snyder +so +soak +soaked +soaking +soaks +soap +soaped +soaping +soaps +soapy +soar +soared +soaring +soars +sob +sobbing +sober +sobered +sobering +soberly +soberness +sobers +sobriety +sobs +soccer +sociability +sociable +sociably +social +socialism +socialist +socialists +socialize +socialized +socializes +socializing +socially +societal +societies +society +socioeconomic +sociological +sociologically +sociologist +sociologists +sociology +sock +socked +socket +sockets +socking +socks +Socrates +Socratic +sod +soda +Soddy +sodium +sodomy +sods +sofa +sofas +Sofia +soft +softball +soften +softened +softening +softens +softer +softest +softly +softness +software +softwares +soggy +soil +soiled +soiling +soils +soiree +sojourn +sojourner +sojourners +Sol +solace +solaced +solar +sold +solder +soldered +soldier +soldiering +soldierly +soldiers +sole +solely +solemn +solemnity +solemnly +solemnness +solenoid +soles +solicit +solicitation +solicited +soliciting +solicitor +solicitous +solicits +solicitude +solid +solidarity +solidification +solidified +solidifies +solidify +solidifying +solidity +solidly +solidness +solids +soliloquy +solitaire +solitary +solitude +solitudes +Solly +solo +Solomon +Solon +solos +Soloviev +solstice +solubility +soluble +solution +solutions +solvable +solve +solved +solvent +solvents +solver +solvers +solves +solving +Somali +Somalia +Somalis +somatic +somber +somberly +some +somebody +someday +somehow +someone +someplace +Somers +somersault +Somerset +Somerville +something +sometime +sometimes +somewhat +somewhere +sommelier +Sommerfeld +somnolent +son +sonar +sonata +Sonenberg +song +songbook +songs +sonic +sonnet +sonnets +sonny +Sonoma +Sonora +sons +Sony +soon +sooner +soonest +soot +sooth +soothe +soothed +soother +soothes +soothing +soothsayer +Sophia +Sophias +Sophie +sophisticated +sophistication +sophistry +Sophoclean +Sophocles +sophomore +sophomores +soprano +sorcerer +sorcerers +sorcery +sordid +sordidly +sordidness +sore +sorely +soreness +Sorensen +Sorenson +sorer +sores +sorest +sorghum +sorority +sorrel +Sorrentine +sorrier +sorriest +sorrow +sorrowful +sorrowfully +sorrows +sorry +sort +sorted +sorter +sorters +sortie +sorting +sorts +sought +soul +soulful +souls +sound +sounded +sounder +soundest +sounding +soundings +soundly +soundness +soundproof +sounds +soup +souped +soups +sour +source +sources +sourdough +soured +sourer +sourest +souring +sourly +sourness +sours +Sousa +south +Southampton +southbound +southeast +southeastern +southern +southerner +southerners +southernmost +Southernwood +Southey +Southfield +southland +southpaw +southward +southwest +southwestern +souvenir +sovereign +sovereigns +sovereignty +soviet +soviets +sow +sown +soy +soya +soybean +spa +space +spacecraft +spaced +spacer +spacers +spaces +spaceship +spaceships +spacesuit +Spacewar +spacing +spacings +spacious +spaded +spades +spading +Spafford +Spahn +Spain +Spalding +span +spandrel +Spaniard +Spaniardization +Spaniardizations +Spaniardize +Spaniardizes +Spaniards +spaniel +Spanish +Spanishize +Spanishizes +spank +spanked +spanking +spanks +spanned +spanner +spanners +spanning +spans +SPARC +SPARCstation +spare +spared +sparely +spareness +sparer +spares +sparest +sparing +sparingly +spark +sparked +sparking +sparkle +sparkling +Sparkman +sparks +sparring +sparrow +sparrows +sparse +sparsely +sparseness +sparser +sparsest +Sparta +Spartan +Spartanize +Spartanizes +spasm +spastic +spat +spate +spates +spatial +spatially +spatter +spattered +spatula +Spaulding +spawn +spawned +spawning +spawns +spayed +speak +speakable +speakeasy +speaker +Speakerphone +Speakerphones +speakers +speaking +speaks +spear +speared +spearmint +spears +spec +special +specialist +specialists +specialization +specializations +specialize +specialized +specializes +specializing +specially +specials +specialties +specialty +specie +species +specifiable +specific +specifically +specification +specifications +specificity +specifics +specified +specifier +specifiers +specifies +specify +specifying +specimen +specimens +specious +speck +speckle +speckled +speckles +specks +spectacle +spectacled +spectacles +spectacular +spectacularly +spectator +spectators +specter +specters +Spector +spectra +spectral +spectrogram +spectrograms +spectrograph +spectrographic +spectrography +spectrometer +spectrophotometer +spectrophotometry +spectroscope +spectroscopic +spectroscopy +spectrum +speculate +speculated +speculates +speculating +speculation +speculations +speculative +speculator +speculators +sped +speech +speeches +speechless +speechlessness +speed +speedboat +speeded +speeder +speeders +speedily +speeding +speedometer +speeds +speedup +speedups +speedy +spell +spellbound +spelled +speller +spellers +spelling +spellings +spells +Spencer +Spencerian +spend +spender +spenders +spending +spends +Spenglerian +spent +sperm +Sperry +sphere +spheres +spherical +spherically +spheroid +spheroidal +sphinx +Spica +spice +spiced +spices +spiciness +spicy +spider +spiders +spidery +Spiegel +spies +spigot +spike +spiked +spikes +spill +spilled +spiller +spilling +spills +spilt +spin +spinach +spinal +spinally +spindle +spindled +spindling +spine +spinnaker +spinner +spinners +spinning +spinoff +spins +spinster +spiny +spiral +spiraled +spiraling +spirally +spire +spires +spirit +spirited +spiritedly +spiriting +spirits +spiritual +spiritually +spirituals +Spiro +spit +spite +spited +spiteful +spitefully +spitefulness +spites +spitfire +spiting +spits +spitting +spittle +Spitz +splash +splashed +splashes +splashing +splashy +spleen +splendid +splendidly +splendor +splenetic +splice +spliced +splicer +splicers +splices +splicing +splicings +spline +splines +splint +splinter +splintered +splinters +splintery +split +splits +splitter +splitters +splitting +splurge +spoil +spoilage +spoiled +spoiler +spoilers +spoiling +spoils +Spokane +spoke +spoked +spoken +spokes +spokesman +spokesmen +sponge +sponged +sponger +spongers +sponges +sponging +spongy +sponsor +sponsored +sponsoring +sponsors +sponsorship +spontaneity +spontaneous +spontaneously +spoof +spook +spooky +spool +spooled +spooler +spoolers +spooling +spools +spoon +spooned +spoonful +spooning +spoons +sporadic +spore +spores +sport +sported +sporting +sportingly +sportive +sports +sportsman +sportsmen +sportswear +sportswriter +sportswriting +sporty +Sposato +spot +spotless +spotlessly +spotlight +spots +spotted +spotter +spotters +spotting +spotty +spouse +spouses +spout +spouted +spouting +spouts +Sprague +sprain +sprang +sprawl +sprawled +sprawling +sprawls +spray +sprayed +sprayer +spraying +sprays +spread +spreader +spreaders +spreading +spreadings +spreads +spreadsheet +spree +sprees +sprig +sprightly +spring +springboard +springer +springers +Springfield +springier +springiest +springiness +springing +springs +springtime +springy +sprinkle +sprinkled +sprinkler +sprinkles +sprinkling +sprint +sprinted +sprinter +sprinters +sprinting +sprints +sprite +sprocket +Sproul +sprout +sprouted +sprouting +spruce +spruced +sprung +Spuds +spun +spunk +spur +spurious +spurn +spurned +spurning +spurns +spurs +spurt +spurted +spurting +spurts +sputter +sputtered +spy +spyglass +spying +squabble +squabbled +squabbles +squabbling +squad +squadron +squadrons +squads +squalid +squall +squalls +squander +square +squared +squarely +squareness +squarer +squares +squarest +Squaresville +squaring +squash +squashed +squashing +squat +squats +squatting +squaw +squawk +squawked +squawking +squawks +squeak +squeaked +squeaking +squeaks +squeaky +squeal +squealed +squealing +squeals +squeamish +squeeze +squeezed +squeezer +squeezes +squeezing +squelch +Squibb +squid +squint +squinted +squinting +squire +squires +squirm +squirmed +squirms +squirmy +squirrel +squirreled +squirreling +squirrels +squirt +squishy +Sri +stab +stabbed +stabbing +stabile +stabilities +stability +stabilize +stabilized +stabilizer +stabilizers +stabilizes +stabilizing +stable +stabled +stabler +stables +stabling +stably +stabs +stack +stacked +stacking +stacks +Stacy +stadia +stadium +staff +staffed +staffer +staffers +staffing +Stafford +Staffordshire +staffs +stag +stage +stagecoach +stagecoaches +staged +stager +stagers +stages +stagger +staggered +staggering +staggers +staging +stagnant +stagnate +stagnation +stags +Stahl +staid +stain +stained +staining +stainless +stains +stair +staircase +staircases +stairs +stairway +stairways +stairwell +stake +staked +stakes +stalactite +stale +stalemate +Staley +Stalin +Stalinist +Stalins +stalk +stalked +stalking +stall +stalled +stalling +stallings +stallion +stalls +stalwart +stalwartly +stamen +stamens +Stamford +stamina +stammer +stammered +stammerer +stammering +stammers +stamp +stamped +stampede +stampeded +stampedes +stampeding +stamper +stampers +stamping +stamps +Stan +stanch +stanchest +stanchion +stand +standard +standardization +standardize +standardized +standardizes +standardizing +standardly +standards +standby +standing +standings +Standish +standoff +standpoint +standpoints +stands +standstill +Stanford +Stanhope +Stanley +Stans +Stanton +stanza +stanzas +staphylococcus +staple +stapler +staples +Stapleton +stapling +star +starboard +starch +starched +stardom +stare +stared +starer +stares +starfish +Stargate +staring +stark +Starkey +starkly +starlet +starlight +starling +Starr +starred +starring +starry +stars +start +started +starter +starters +starting +startle +startled +startles +startling +starts +startup +startups +starvation +starve +starved +starves +starving +state +stated +stately +statement +statements +Staten +states +statesman +statesmanlike +statesmen +statewide +static +statically +stating +station +stationary +stationed +stationer +stationery +stationing +stationmaster +stations +statistic +statistical +statistically +statistician +statisticians +statistics +Statler +statue +statues +statuesque +statuesquely +statuesqueness +statuette +stature +status +statuses +statute +statutes +statutorily +statutoriness +statutory +Stauffer +staunch +staunchest +staunchly +Staunton +stave +staved +staves +stay +stayed +staying +stays +stead +steadfast +steadfastly +steadfastness +steadied +steadier +steadies +steadiest +steadily +steadiness +steady +steadying +steak +steaks +steal +stealer +stealing +steals +stealth +stealthily +stealthy +steam +steamboat +steamboats +steamed +steamer +steamers +steaming +steams +steamship +steamships +steamy +Stearns +steed +steel +Steele +steeled +steelers +steeling +steelmaker +steels +steely +Steen +steep +steeped +steeper +steepest +steeping +steeple +steeples +steeply +steepness +steeps +steer +steerable +steered +steering +steers +Stefan +Stegosaurus +Steinbeck +Steinberg +Steiner +Stella +stellar +stem +stemmed +stemming +stems +stench +stenches +stencil +stencils +Stendhal +Stendler +stenographer +stenographers +stenotype +step +stepchild +Stephan +Stephanie +Stephen +Stephens +Stephenson +stepmother +stepmothers +stepped +stepper +stepping +steps +stepson +stepwise +stereo +stereos +stereoscopic +stereotype +stereotyped +stereotypes +stereotypical +sterile +sterilization +sterilizations +sterilize +sterilized +sterilizer +sterilizes +sterilizing +sterling +stern +Sternberg +sternly +sternness +Sterno +sterns +stethoscope +Stetson +Stetsons +Steuben +Steve +stevedore +Steven +Stevens +Stevenson +Stevie +stew +steward +stewardess +stewards +Stewart +stewed +stews +stick +sticker +stickers +stickier +stickiest +stickily +stickiness +sticking +stickleback +sticks +sticky +stiff +stiffen +stiffens +stiffer +stiffest +stiffly +stiffness +stiffs +stifle +stifled +stifles +stifling +stigma +stigmata +stile +stiles +stiletto +still +stillbirth +stillborn +stilled +stiller +stillest +stilling +stillness +stills +Stillwell +stilt +stilts +Stimson +stimulant +stimulants +stimulate +stimulated +stimulates +stimulating +stimulation +stimulations +stimulative +stimuli +stimulus +sting +stinging +stings +stingy +stink +stinker +stinkers +stinking +stinks +stint +stipend +stipends +stipulate +stipulated +stipulates +stipulating +stipulation +stipulations +stir +Stirling +stirred +stirrer +stirrers +stirring +stirringly +stirrings +stirrup +stirs +stitch +stitched +stitches +stitching +stochastic +stochastically +stock +stockade +stockades +stockbroker +stocked +stocker +stockers +stockholder +stockholders +Stockholm +stocking +stockings +stockpile +stockroom +stocks +Stockton +stocky +stodgy +stoichiometry +stoke +Stokes +stole +stolen +stoles +stolid +stomach +stomached +stomacher +stomaches +stomaching +stomp +Stone +stoned +Stonehenge +stones +stoning +stony +stood +stooge +stool +stoop +stooped +stooping +stoops +stop +stopcock +stopcocks +stopgap +stopover +stoppable +stoppage +stopped +stopper +stoppers +stopping +stops +stopwatch +storage +storages +store +stored +storehouse +storehouses +storekeeper +storeroom +stores +Storey +Storeyed +Storeys +storied +stories +storing +stork +storks +storm +stormed +stormier +stormiest +storminess +storming +storms +stormy +story +storyboard +storyteller +Stouffer +stout +stouter +stoutest +stoutly +stoutness +stove +stoves +stow +Stowe +stowed +straddle +strafe +straggle +straggled +straggler +stragglers +straggles +straggling +straight +straightaway +straighten +straightened +straightens +straighter +straightest +straightforward +straightforwardly +straightforwardness +straightness +straightway +strain +strained +strainer +strainers +straining +strains +strait +straiten +straits +strand +stranded +stranding +strands +strange +strangely +strangeness +stranger +strangers +strangest +strangle +strangled +strangler +stranglers +strangles +strangling +stranglings +strangulation +strangulations +strap +straps +Strasbourg +stratagem +stratagems +strategic +strategies +strategist +strategy +Stratford +stratification +stratifications +stratified +stratifies +stratify +stratosphere +stratospheric +Stratton +stratum +Strauss +Stravinsky +straw +strawberries +strawberry +straws +stray +strayed +strays +streak +streaked +streaks +stream +streamed +streamer +streamers +streaming +streamline +streamlined +streamliner +streamlines +streamlining +streams +street +streetcar +streetcars +streeters +streets +strength +strengthen +strengthened +strengthener +strengthening +strengthens +strengths +strenuous +strenuously +streptococcus +stress +stressed +stresses +stressful +stressing +stretch +stretched +stretcher +stretchers +stretches +stretching +strew +strewn +strews +stricken +Strickland +strict +stricter +strictest +strictly +strictness +stricture +stride +strider +strides +striding +strife +strike +strikebreaker +striker +strikers +strikes +striking +strikingly +Strindberg +string +stringed +stringent +stringently +stringer +stringers +stringier +stringiest +stringiness +stringing +strings +stringy +strip +stripe +striped +stripes +stripped +stripper +strippers +stripping +strips +striptease +strive +striven +strives +striving +strivings +strobe +strobed +strobes +stroboscopic +strode +stroke +stroked +stroker +strokers +strokes +stroking +stroll +strolled +stroller +strolling +strolls +Strom +Stromberg +strong +stronger +strongest +Strongheart +stronghold +strongly +strontium +strove +struck +structural +structurally +structure +structured +structurer +structures +structuring +struggle +struggled +struggles +struggling +strung +strut +struts +strutting +strychnine +Stu +Stuart +stub +stubble +Stubblefield +Stubblefields +stubborn +stubbornly +stubbornness +stubby +stubs +stucco +stuck +stud +Studebaker +student +students +studied +studies +studio +studios +studious +studiously +studs +study +studying +stuff +stuffed +stuffier +stuffiest +stuffing +stuffs +stuffy +stumble +stumbled +stumbles +stumbling +stump +stumped +stumping +stumps +stun +stung +stunning +stunningly +stunt +stunts +stupefy +stupefying +stupendous +stupendously +stupid +stupidest +stupidities +stupidity +stupidly +stupor +Sturbridge +sturdiness +sturdy +sturgeon +Sturm +stutter +Stuttgart +Stuyvesant +Stygian +style +styled +styler +stylers +styles +styli +styling +stylish +stylishly +stylishness +stylistic +stylistically +stylized +stylus +Styrofoam +Styx +suave +sub +subatomic +subchannel +subchannels +subclass +subclasses +subcommittees +subcomponent +subcomponents +subcomputation +subcomputations +subconscious +subconsciously +subculture +subcultures +subcycle +subcycles +subdirectories +subdirectory +subdivide +subdivided +subdivides +subdividing +subdivision +subdivisions +subdomains +subdue +subdued +subdues +subduing +subexpression +subexpressions +subfield +subfields +subfile +subfiles +subgoal +subgoals +subgraph +subgraphs +subgroup +subgroups +subinterval +subintervals +subject +subjected +subjecting +subjection +subjective +subjectively +subjectivity +subjects +sublanguage +sublanguages +sublayer +sublayers +sublimation +sublimations +sublime +sublimed +sublist +sublists +submarine +submariner +submariners +submarines +submerge +submerged +submerges +submerging +submission +submissions +submissive +submit +submits +submittal +submitted +submitting +submode +submodes +submodule +submodules +submultiplexed +subnet +subnets +subnetwork +subnetworks +suboptimal +subordinate +subordinated +subordinates +subordination +subparts +subphases +subpoena +subproblem +subproblems +subprocesses +subprogram +subprograms +subproject +subproof +subproofs +subrange +subranges +subroutine +subroutines +subs +subschema +subschemas +subscribe +subscribed +subscriber +subscribers +subscribes +subscribing +subscript +subscripted +subscripting +subscription +subscriptions +subscripts +subsection +subsections +subsegment +subsegments +subsequence +subsequences +subsequent +subsequently +subservient +subset +subsets +subside +subsided +subsides +subsidiaries +subsidiary +subsidies +subsiding +subsidize +subsidized +subsidizes +subsidizing +subsidy +subsist +subsisted +subsistence +subsistent +subsisting +subsists +subslot +subslots +subspace +subspaces +substance +substances +substantial +substantially +substantiate +substantiated +substantiates +substantiating +substantiation +substantiations +substantive +substantively +substantivity +substation +substations +substitutability +substitutable +substitute +substituted +substitutes +substituting +substitution +substitutions +substrate +substrates +substring +substrings +substructure +substructures +subsume +subsumed +subsumes +subsuming +subsystem +subsystems +subtask +subtasks +subterfuge +subterranean +subtitle +subtitled +subtitles +subtle +subtleness +subtler +subtlest +subtleties +subtlety +subtly +subtotal +subtract +subtracted +subtracting +subtraction +subtractions +subtractor +subtractors +subtracts +subtrahend +subtrahends +subtree +subtrees +subunit +subunits +suburb +suburban +suburbia +suburbs +subversion +subversive +subvert +subverted +subverter +subverting +subverts +subway +subways +succeed +succeeded +succeeding +succeeds +success +successes +successful +successfully +succession +successions +successive +successively +successor +successors +succinct +succinctly +succinctness +succor +succumb +succumbed +succumbing +succumbs +such +suck +sucked +sucker +suckers +sucking +suckle +suckling +sucks +suction +Sudan +Sudanese +Sudanic +sudden +suddenly +suddenness +suds +sudsing +sue +sued +sues +Suez +suffer +sufferance +suffered +sufferer +sufferers +suffering +sufferings +suffers +suffice +sufficed +suffices +sufficiency +sufficient +sufficiently +sufficing +suffix +suffixed +suffixer +suffixes +suffixing +suffocate +suffocated +suffocates +suffocating +suffocation +Suffolk +suffrage +suffragette +sugar +sugared +sugaring +sugarings +sugars +suggest +suggested +suggestible +suggesting +suggestion +suggestions +suggestive +suggestively +suggests +suicidal +suicidally +suicide +suicides +suing +suit +suitability +suitable +suitableness +suitably +suitcase +suitcases +suite +suited +suiters +suites +suiting +suitor +suitors +suits +Sukarno +sulfa +sulfur +sulfuric +sulfurous +sulk +sulked +sulkiness +sulking +sulks +sulky +sullen +sullenly +sullenness +Sullivan +sulphate +sulphur +sulphured +sulphuric +sultan +sultans +sultry +Sulzberger +sum +sumac +Sumatra +Sumeria +Sumerian +summand +summands +summaries +summarily +summarization +summarizations +summarize +summarized +summarizes +summarizing +summary +summation +summations +summed +Summer +Summerdale +Summers +summertime +summing +summit +summitry +summon +summoned +summoner +summoners +summoning +summons +summonses +Sumner +sumptuous +sums +Sumter +sun +sunbeam +sunbeams +Sunbelt +sunbonnet +sunburn +sunburnt +Sunday +Sundays +sunder +sundial +sundown +sundries +sundry +sunflower +sung +sunglass +sunglasses +sunk +sunken +sunlight +sunlit +sunned +sunning +sunny +Sunnyvale +sunrise +suns +sunset +sunshine +sunspot +suntan +suntanned +suntanning +super +superb +superblock +superbly +supercomputer +supercomputers +superego +superegos +superficial +superficially +superfluities +superfluity +superfluous +superfluously +supergroup +supergroups +superhuman +superhumanly +superimpose +superimposed +superimposes +superimposing +superintend +superintendent +superintendents +superior +superiority +superiors +superlative +superlatively +superlatives +supermarket +supermarkets +supermini +superminis +supernatural +superpose +superposed +superposes +superposing +superposition +superscript +superscripted +superscripting +superscripts +supersede +superseded +supersedes +superseding +superset +supersets +superstition +superstitions +superstitious +superuser +supervise +supervised +supervises +supervising +supervision +supervisor +supervisors +supervisory +supine +supper +suppers +supplant +supplanted +supplanting +supplants +supple +supplement +supplemental +supplementary +supplemented +supplementing +supplements +suppleness +supplication +supplied +supplier +suppliers +supplies +supply +supplying +support +supportable +supported +supporter +supporters +supporting +supportingly +supportive +supportively +supports +suppose +supposed +supposedly +supposes +supposing +supposition +suppositions +suppress +suppressed +suppresses +suppressing +suppression +suppressor +suppressors +supranational +supremacy +supreme +supremely +surcharge +sure +surely +sureness +sureties +surety +surf +surface +surfaced +surfaceness +surfaces +surfacing +surge +surged +surgeon +surgeons +surgery +surges +surgical +surgically +surging +surliness +surly +surmise +surmised +surmises +surmount +surmounted +surmounting +surmounts +surname +surnames +surpass +surpassed +surpasses +surpassing +surplus +surpluses +surprise +surprised +surprises +surprising +surprisingly +surreal +surrender +surrendered +surrendering +surrenders +surreptitious +surrey +surrogate +surrogates +surround +surrounded +surrounding +surroundings +surrounds +surtax +survey +surveyed +surveying +surveyor +surveyors +surveys +survival +survivals +survive +survived +survives +surviving +survivor +survivors +Sus +Susan +Susanne +susceptible +Susie +suspect +suspected +suspecting +suspects +suspend +suspended +suspender +suspenders +suspending +suspends +suspense +suspenses +suspension +suspensions +suspicion +suspicions +suspicious +suspiciously +Susquehanna +Sussex +sustain +sustained +sustaining +sustains +sustenance +Sutherland +Sutton +suture +sutures +Suwanee +Suzanne +suzerainty +Suzuki +svelte +Svetlana +swab +swabbing +swagger +swaggered +swaggering +Swahili +swain +swains +swallow +swallowed +swallowing +swallows +swallowtail +swam +swami +swamp +swamped +swamping +swamps +swampy +swan +swank +swanky +swanlike +swans +Swansea +Swanson +swap +swapped +swapping +swaps +swarm +swarmed +swarming +swarms +Swarthmore +Swarthout +swarthy +Swartz +swastika +swat +swatted +sway +swayed +swaying +Swaziland +swear +swearer +swearing +swears +sweat +sweated +sweater +sweaters +sweating +sweats +sweatshirt +sweaty +Swede +Sweden +Swedes +Swedish +Sweeney +Sweeneys +sweep +sweeper +sweepers +sweeping +sweepings +sweeps +sweepstakes +sweet +sweeten +sweetened +sweetener +sweeteners +sweetening +sweetenings +sweetens +sweeter +sweetest +sweetheart +sweethearts +sweetish +sweetly +sweetness +sweets +swell +swelled +swelling +swellings +swells +swelter +Swenson +swept +swerve +swerved +swerves +swerving +swift +swifter +swiftest +swiftly +swiftness +swim +swimmer +swimmers +swimming +swimmingly +swims +swimsuit +Swinburne +swindle +swine +swing +swinger +swingers +swinging +swings +Swink +swipe +swirl +swirled +swirling +swish +swished +swiss +switch +switchblade +switchboard +switchboards +switched +switcher +switchers +switches +switching +switchings +switchman +Switzer +Switzerland +swivel +swizzle +swollen +swoon +swoop +swooped +swooping +swoops +sword +swordfish +swords +swore +sworn +swum +swung +Sybil +sycamore +sycophant +sycophantic +Sydney +Sykes +syllable +syllables +syllogism +syllogisms +syllogistic +Sylow +sylvan +Sylvania +Sylvester +Sylvia +Sylvie +symbiosis +symbiotic +symbol +symbolic +symbolically +symbolics +symbolism +symbolization +symbolize +symbolized +symbolizes +symbolizing +symbols +Symington +symmetric +symmetrical +symmetrically +symmetries +symmetry +sympathetic +sympathies +sympathize +sympathized +sympathizer +sympathizers +sympathizes +sympathizing +sympathizingly +sympathy +symphonic +symphonies +symphony +symposia +symposium +symposiums +symptom +symptomatic +symptoms +synagogue +synapse +synapses +synaptic +synchronism +synchronization +synchronize +synchronized +synchronizer +synchronizers +synchronizes +synchronizing +synchronous +synchronously +synchrony +synchrotron +syncopate +syndicate +syndicated +syndicates +syndication +syndrome +syndromes +synergism +synergistic +synergy +Synge +synod +synonym +synonymous +synonymously +synonyms +synopses +synopsis +syntactic +syntactical +syntactically +syntax +syntaxes +synthesis +synthesize +synthesized +synthesizer +synthesizers +synthesizes +synthesizing +synthetic +synthetics +Syracuse +Syria +Syrian +Syrianize +Syrianizes +Syrians +syringe +syringes +syrup +syrupy +system +systematic +systematically +systematize +systematized +systematizes +systematizing +systemic +systems +systemwide +Szilard +tab +tabernacle +tabernacles +table +tableau +tableaus +tablecloth +tablecloths +tabled +tables +tablespoon +tablespoonful +tablespoonfuls +tablespoons +tablet +tablets +tabling +taboo +taboos +tabs +tabular +tabulate +tabulated +tabulates +tabulating +tabulation +tabulations +tabulator +tabulators +tachometer +tachometers +tacit +tacitly +Tacitus +tack +tacked +tacking +tackle +tackles +Tacoma +tact +tactic +tactics +tactile +Taft +tag +tagged +tagging +tags +Tahiti +Tahoe +tail +tailed +tailing +tailor +tailored +tailoring +tailors +tails +taint +tainted +Taipei +Taiwan +Taiwanese +take +taken +taker +takers +takes +taking +takings +tale +talent +talented +talents +tales +talk +talkative +talkatively +talkativeness +talked +talker +talkers +talkie +talking +talks +tall +Talladega +Tallahassee +Tallahatchie +Tallahoosa +Tallchief +taller +tallest +Talleyrand +tallness +tallow +tally +Talmud +Talmudism +Talmudization +Talmudizations +Talmudize +Talmudizes +tame +tamed +tamely +tameness +tamer +tames +Tamil +taming +Tammany +Tammanyize +Tammanyizes +Tampa +tamper +tampered +tampering +tampers +tan +Tanaka +Tananarive +tandem +tang +Tanganyika +tangent +tangential +tangents +tangible +tangibly +tangle +tangled +tangy +tank +tanker +tankers +tanks +Tannenbaum +tanner +tanners +tantalizing +tantalizingly +Tantalus +tantamount +tantrum +tantrums +Tanya +Tanzania +Taoism +Taoist +Taos +tap +tape +taped +taper +tapered +tapering +tapers +tapes +tapestries +tapestry +taping +tapings +tapped +tapper +tappers +tapping +taproot +taproots +taps +tar +Tara +Tarbell +tardiness +tardy +target +targeted +targeting +targets +tariff +tariffs +tarry +Tarrytown +tart +Tartary +tartly +tartness +Tartuffe +Tarzan +task +tasked +tasking +tasks +Tasmania +Tass +tassel +tassels +taste +tasted +tasteful +tastefully +tastefulness +tasteless +tastelessly +taster +tasters +tastes +tasting +Tate +tatter +tattered +tattoo +tattooed +tattoos +tau +taught +taunt +taunted +taunter +taunting +taunts +Taurus +taut +tautly +tautness +tautological +tautologically +tautologies +tautology +tavern +taverns +Tawney +tawny +tax +taxable +taxation +taxed +taxes +taxi +taxicab +taxicabs +taxied +taxiing +taxing +taxis +taxonomic +taxonomically +taxonomy +taxpayer +taxpayers +Taylor +Taylorize +Taylorizes +Taylors +Tchaikovsky +tea +teach +teachable +teacher +teachers +teaches +teaching +teachings +teacup +team +teamed +teaming +teams +tear +teared +tearful +tearfully +tearing +tears +teas +tease +teased +teases +teasing +teaspoon +teaspoonful +teaspoonfuls +teaspoons +technical +technicalities +technicality +technically +technician +technicians +Technion +technique +techniques +technological +technologically +technologies +technologist +technologists +technology +Ted +Teddy +tedious +tediously +tediousness +tedium +teem +teemed +teeming +teems +teen +teenage +teenaged +teenager +teenagers +teens +teeth +teethe +teethed +teethes +teething +Teflon +Tegucigalpa +Teheran +Tehran +Tektronix +telecommunication +telecommunications +Teledyne +Telefunken +telegram +telegrams +telegraph +telegraphed +telegrapher +telegraphers +telegraphic +telegraphing +telegraphs +Telemann +telemetry +teleological +teleologically +teleology +telepathy +telephone +telephoned +telephoner +telephoners +telephones +telephonic +telephoning +telephony +teleprocessing +telescope +telescoped +telescopes +telescoping +Teletex +Teletext +teletype +teletypes +televise +televised +televises +televising +television +televisions +televisor +televisors +Telex +tell +teller +tellers +telling +tells +TELNET +Telnet +temper +temperament +temperamental +temperaments +temperance +temperate +temperately +temperateness +temperature +temperatures +tempered +tempering +tempers +tempest +tempestuous +tempestuously +template +templates +temple +Templeman +temples +Templeton +temporal +temporally +temporaries +temporarily +temporary +tempt +temptation +temptations +tempted +tempter +tempters +tempting +temptingly +tempts +ten +tenacious +tenaciously +tenant +tenants +tend +tended +tendencies +tendency +tender +tenderly +tenderness +tenders +tending +tends +tenement +tenements +TENEX +Tenex +tenfold +Tenneco +Tennessee +Tenney +tennis +Tennyson +tenor +tenors +tens +tense +tensed +tensely +tenseness +tenser +tenses +tensest +tensing +tension +tensions +tent +tentacle +tentacled +tentacles +tentative +tentatively +tented +tenth +tenting +tents +tenure +Teresa +term +termed +terminal +terminally +terminals +terminate +terminated +terminates +terminating +termination +terminations +terminator +terminators +terming +terminologies +terminology +terminus +terms +termwise +ternary +Terpsichore +Terra +terrace +terraced +terraces +terrain +terrains +Terran +Terre +terrestrial +terrestrials +terrible +terribly +terrier +terriers +terrific +terrified +terrifies +terrify +terrifying +territorial +territories +territory +terror +terrorism +terrorist +terroristic +terrorists +terrorize +terrorized +terrorizes +terrorizing +terrors +tertiary +Tess +Tessie +test +testability +testable +testament +testaments +tested +tester +testers +testicle +testicles +testified +testifier +testifiers +testifies +testify +testifying +testimonies +testimony +testing +testings +tests +Teutonic +TeX +Tex +Texaco +Texan +Texans +Texas +Texases +text +textbook +textbooks +textile +textiles +Textron +texts +textual +textually +texture +textured +textures +Thai +Thailand +Thalia +Thames +than +thank +thanked +thankful +thankfully +thankfulness +thanking +thankless +thanklessly +thanklessness +thanks +thanksgiving +thanksgivings +that +thatch +thatches +thats +thaw +thawed +thawing +thaws +Thayer +the +Thea +theater +theaters +theatrical +theatrically +theatricals +Thebes +theft +thefts +their +theirs +Thelma +them +thematic +theme +themes +themselves +then +thence +thenceforth +Theodore +Theodosian +Theodosius +theological +theology +theorem +theorems +theoretic +theoretical +theoretically +theoreticians +theories +theorist +theorists +theorization +theorizations +theorize +theorized +theorizer +theorizers +theorizes +theorizing +theory +therapeutic +therapies +therapist +therapists +therapy +there +thereabouts +thereafter +thereby +therefore +therein +thereof +thereon +Theresa +thereto +thereupon +therewith +thermal +thermodynamic +thermodynamics +Thermofax +thermometer +thermometers +thermostat +thermostats +these +theses +Theseus +thesis +Thessalonian +Thessaly +Thetis +they +thick +thicken +thickens +thicker +thickest +thicket +thickets +thickly +thickness +thief +Thiensville +thieve +thieves +thieving +thigh +thighs +thimble +thimbles +Thimbu +thin +thing +things +think +thinkable +thinkably +thinker +thinkers +thinking +thinks +thinly +thinner +thinness +thinnest +third +thirdly +thirds +thirst +thirsted +thirsts +thirsty +thirteen +thirteens +thirteenth +thirties +thirtieth +thirty +this +thistle +Thomas +Thomistic +Thompson +Thomson +thong +Thor +Thoreau +thorn +Thornburg +thorns +Thornton +thorny +thorough +thoroughfare +thoroughfares +thoroughly +thoroughness +Thorpe +Thorstein +those +though +thought +thoughtful +thoughtfully +thoughtfulness +thoughtless +thoughtlessly +thoughtlessness +thoughts +thousand +thousands +thousandth +Thrace +Thracian +thrash +thrashed +thrasher +thrashes +thrashing +thread +threaded +threader +threaders +threading +threads +threat +threaten +threatened +threatening +threatens +threats +three +threefold +threes +threescore +threshold +thresholds +threw +thrice +thrift +thrifty +thrill +thrilled +thriller +thrillers +thrilling +thrillingly +thrills +thrive +thrived +thrives +thriving +throat +throated +throats +throb +throbbed +throbbing +throbs +throne +Throneberry +thrones +throng +throngs +throttle +throttled +throttles +throttling +through +throughout +throughput +throw +thrower +throwing +thrown +throws +thrush +thrust +thruster +thrusters +thrusting +thrusts +Thuban +thud +thuds +thug +thugs +Thule +thumb +thumbed +thumbing +thumbs +thump +thumped +thumping +thunder +thunderbolt +thunderbolts +thundered +thunderer +thunderers +thundering +thunders +thunderstorm +thunderstorms +Thurber +Thurman +Thursday +Thursdays +thus +thusly +thwart +thwarted +thwarting +thwarts +thyself +Tiber +Tibet +Tibetan +Tiburon +tick +ticked +ticker +tickers +ticket +tickets +ticking +tickle +tickled +tickles +tickling +ticklish +ticks +Ticonderoga +tidal +tidally +tide +tided +tides +tidied +tidiness +tiding +tidings +tidy +tidying +tie +Tieck +tied +Tientsin +tier +tiers +ties +Tiffany +tiger +tigers +tight +tighten +tightened +tightener +tighteners +tightening +tightenings +tightens +tighter +tightest +tightly +tightness +Tigris +Tijuana +tilde +tile +tiled +tiles +tiling +till +tillable +tilled +tiller +tillers +Tillich +Tillie +tilling +tills +tilt +tilted +tilting +tilts +Tim +timber +timbered +timbering +timbers +time +timed +timeless +timelessly +timelessness +timely +timeout +timeouts +timer +timers +times +timeshare +timeshares +timesharing +timestamp +timestamps +timetable +timetables +Timex +timid +timidity +timidly +timing +timings +Timmy +Timon +Timonize +Timonizes +Tims +tin +Tina +tincture +tinge +tinged +tingle +tingled +tingles +tingling +tinier +tiniest +tinily +tininess +tinker +tinkered +tinkering +tinkers +tinkle +tinkled +tinkles +tinkling +tinnier +tinniest +tinnily +tinniness +tinny +tins +Tinseltown +tint +tinted +tinting +tints +tiny +Tioga +tip +Tippecanoe +tipped +tipper +Tipperary +tippers +tipping +tips +tiptoe +Tirana +tire +tired +tiredly +tireless +tirelessly +tirelessness +tires +tiresome +tiresomely +tiresomeness +tiring +tissue +tissues +tit +Titan +tithe +tither +tithes +tithing +title +titled +titles +Tito +tits +titter +titters +Titus +to +toad +toads +toast +toasted +toaster +toasting +toasts +tobacco +Tobago +Toby +today +todays +Todd +toe +toes +together +togetherness +toggle +toggled +toggles +toggling +Togo +toil +toiled +toiler +toilet +toilets +toiling +toils +token +tokens +Tokyo +Toland +told +Toledo +tolerability +tolerable +tolerably +tolerance +tolerances +tolerant +tolerantly +tolerate +tolerated +tolerates +tolerating +toleration +toll +tolled +Tolley +tolls +Tolstoy +Tom +tomahawk +tomahawks +tomato +tomatoes +tomb +Tombigbee +tombs +Tomlinson +Tommie +tomography +tomorrow +tomorrows +Tompkins +ton +tone +toned +toner +tones +tongs +tongue +tongued +tongues +Toni +tonic +tonics +tonight +toning +Tonio +tonnage +tons +tonsil +too +took +tool +tooled +tooler +toolers +tooling +tools +Toomey +tooth +toothbrush +toothbrushes +toothpaste +toothpick +toothpicks +top +Topeka +toper +topic +topical +topically +topics +topmost +topography +topological +topologies +topology +topple +toppled +topples +toppling +tops +Topsy +Torah +torch +torches +tore +Tories +torment +tormented +tormenter +tormenters +tormenting +torn +tornado +tornadoes +Toronto +torpedo +torpedoes +torque +Torquemada +Torrance +torrent +torrents +torrid +tortoise +tortoises +torture +tortured +torturer +torturers +tortures +torturing +torus +toruses +Tory +Toryize +Toryizes +Tosca +Toscanini +Toshiba +toss +tossed +tosses +tossing +total +totaled +totaling +totalities +totality +totalled +totaller +totallers +totalling +totally +totals +Toto +totter +tottered +tottering +totters +touch +touchable +touched +touches +touchier +touchiest +touchily +touchiness +touching +touchingly +touchy +tough +toughen +tougher +toughest +toughly +toughness +Toulouse +tour +toured +touring +tourist +tourists +tournament +tournaments +tours +tow +toward +towards +towed +towel +toweling +towelled +towelling +towels +tower +towered +towering +towers +town +Townley +towns +Townsend +township +townships +Towsley +toy +toyed +toying +Toynbee +Toyota +toys +trace +traceable +traced +tracer +tracers +traces +tracing +tracings +track +tracked +tracker +trackers +tracking +tracks +tract +tractability +tractable +Tractarians +tractive +tractor +tractors +tracts +Tracy +trade +traded +trademark +trademarks +tradeoff +tradeoffs +trader +traders +trades +tradesman +trading +tradition +traditional +traditionally +traditions +traffic +trafficked +trafficker +traffickers +trafficking +traffics +tragedies +tragedy +tragic +tragically +trail +trailed +trailer +trailers +trailing +trailings +trails +train +trained +trainee +trainees +trainer +trainers +training +trains +trait +traitor +traitors +traits +trajectories +trajectory +tramp +tramped +tramping +trample +trampled +trampler +tramples +trampling +tramps +trance +trances +tranquil +tranquility +tranquilly +transact +transaction +transactions +transatlantic +transceive +transceiver +transceivers +transcend +transcended +transcendent +transcending +transcends +transcontinental +transcribe +transcribed +transcriber +transcribers +transcribes +transcribing +transcript +transcription +transcriptions +transcripts +transfer +transferability +transferable +transferal +transferals +transference +transferred +transferrer +transferrers +transferring +transfers +transfinite +transform +transformable +transformation +transformational +transformations +transformed +transformer +transformers +transforming +transforms +transgress +transgressed +transgression +transgressions +transience +transiency +transient +transiently +transients +transistor +transistorize +transistorized +transistorizing +transistors +transit +Transite +transition +transitional +transitioned +transitions +transitive +transitively +transitiveness +transitivity +transitory +translatability +translatable +translate +translated +translates +translating +translation +translational +translations +translator +translators +translucent +transmission +transmissions +transmit +transmits +transmittal +transmitted +transmitter +transmitters +transmitting +transmogrification +transmogrify +transpacific +transparencies +transparency +transparent +transparently +transpire +transpired +transpires +transpiring +transplant +transplanted +transplanting +transplants +transponder +transponders +transport +transportability +transportation +transported +transporter +transporters +transporting +transports +transpose +transposed +transposes +transposing +transposition +Transputer +Transvaal +Transylvania +trap +trapezoid +trapezoidal +trapezoids +trapped +trapper +trappers +trapping +trappings +traps +trash +Trastevere +trauma +traumatic +travail +travel +traveled +traveler +travelers +traveling +travelings +travels +traversal +traversals +traverse +traversed +traverses +traversing +travesties +travesty +Travis +tray +trays +treacheries +treacherous +treacherously +treachery +tread +treading +treads +Treadwell +treason +treasure +treasured +treasurer +treasures +treasuries +treasuring +treasury +treat +treated +treaties +treating +treatise +treatises +treatment +treatments +treats +treaty +treble +tree +trees +treetop +treetops +trek +treks +tremble +trembled +trembles +trembling +tremendous +tremendously +tremor +tremors +trench +trencher +trenches +trend +trending +trends +Trenton +trespass +trespassed +trespasser +trespassers +trespasses +tress +tresses +Trevelyan +trial +trials +triangle +triangles +triangular +triangularly +Triangulum +Trianon +Triassic +tribal +tribe +tribes +tribunal +tribunals +tribune +tribunes +tributary +tribute +tributes +Triceratops +Trichinella +trichotomy +trick +tricked +trickier +trickiest +trickiness +tricking +trickle +trickled +trickles +trickling +tricks +tricky +tried +trier +triers +tries +trifle +trifler +trifles +trifling +trigger +triggered +triggering +triggers +trigonometric +trigonometry +trigram +trigrams +trihedral +trilateral +trill +trilled +trillion +trillions +trillionth +trim +Trimble +trimly +trimmed +trimmer +trimmest +trimming +trimmings +trimness +trims +Trinidad +trinket +trinkets +trio +trip +triple +tripled +triples +triplet +triplets +Triplett +tripling +tripod +trips +Tristan +triumph +triumphal +triumphant +triumphantly +triumphed +triumphing +triumphs +trivia +trivial +trivialities +triviality +trivially +Trobriand +trod +Trojan +troll +trolley +trolleys +trolls +troop +trooper +troopers +troops +Tropez +trophies +trophy +tropic +tropical +tropics +trot +trots +Trotsky +trouble +troubled +troublemaker +troublemakers +troubles +troubleshoot +troubleshooter +troubleshooters +troubleshooting +troubleshoots +troublesome +troublesomely +troubling +trough +trouser +trousers +trout +Troutman +trowel +trowels +Troy +truant +truants +truce +truck +trucked +Truckee +trucker +truckers +trucking +trucks +Trudeau +trudge +trudged +Trudy +true +trued +truer +trues +truest +truing +truism +truisms +Trujillo +Truk +truly +Truman +Trumbull +trump +trumped +trumpet +trumpeter +trumps +truncate +truncated +truncates +truncating +truncation +truncations +trunk +trunks +trust +trusted +trustee +trustees +trustful +trustfully +trustfulness +trusting +trustingly +trusts +trustworthiness +trustworthy +trusty +truth +truthful +truthfully +truthfulness +truths +try +trying +Tsunematsu +tub +tube +tuber +tuberculosis +tubers +tubes +tubing +tubs +tuck +tucked +Tucker +tucking +tucks +Tucson +Tudor +Tuesday +Tuesdays +tuft +tufts +tug +tugs +tuition +Tulane +tulip +tulips +Tulsa +tumble +tumbled +tumbler +tumblers +tumbles +tumbling +tumor +tumors +tumult +tumults +tumultuous +tunable +tune +tuned +tuner +tuners +tunes +tunic +tunics +tuning +Tunis +Tunisia +Tunisian +tunnel +tunneled +tunnels +tuple +tuples +turban +turbans +turbulence +turbulent +turbulently +turf +turgid +turgidly +Turin +Turing +turkey +turkeys +Turkish +Turkize +Turkizes +turmoil +turmoils +turn +turnable +turnaround +turned +turner +turners +turning +turnings +turnip +turnips +turnover +turns +turpentine +turquoise +turret +turrets +turtle +turtleneck +turtles +Tuscaloosa +Tuscan +Tuscanize +Tuscanizes +Tuscany +Tuscarora +Tuskegee +Tutankhamen +Tutankhamon +Tutankhamun +Tutenkhamon +tutor +tutored +tutorial +tutorials +tutoring +tutors +Tuttle +twain +twang +twas +tweed +twelfth +twelve +twelves +twenties +twentieth +twenty +twice +twig +twigs +twilight +twilights +twill +twin +twine +twined +twiner +twinkle +twinkled +twinkler +twinkles +twinkling +twins +twirl +twirled +twirler +twirling +twirls +twist +twisted +twister +twisters +twisting +twists +twitch +twitched +twitching +twitter +twittered +twittering +two +twofold +Twombly +twos +Tyburn +tying +Tyler +Tylerize +Tylerizes +Tyndall +type +typed +typeout +types +typesetter +typewriter +typewriters +typhoid +Typhon +typical +typically +typicalness +typified +typifies +typify +typifying +typing +typist +typists +typo +typographic +typographical +typographically +typography +tyrannical +Tyrannosaurus +tyranny +tyrant +tyrants +Tyson +Tzeltal +ubiquitous +ubiquitously +ubiquity +Udall +Uganda +ugh +uglier +ugliest +ugliness +ugly +Ukraine +Ukrainian +Ukrainians +Ulan +ulcer +ulcers +Ullman +Ulster +ultimate +ultimately +ultra +ultrasonic +ULTRIX +Ultrix +Ulysses +umbrage +umbrella +umbrellas +umpire +umpires +unabated +unabbreviated +unable +unacceptability +unacceptable +unacceptably +unaccountable +unaccustomed +unachievable +unacknowledged +unadulterated +unaesthetically +unaffected +unaffectedly +unaffectedness +unaided +unalienability +unalienable +unalterably +unaltered +unambiguous +unambiguously +unambitious +unanalyzable +unanimity +unanimous +unanimously +unanswerable +unanswered +unanticipated +unarmed +unary +unassailable +unassigned +unassisted +unattainability +unattainable +unattended +unattractive +unattractively +unauthorized +unavailability +unavailable +unavoidable +unavoidably +unaware +unawareness +unawares +unbalanced +unbearable +unbecoming +unbelievable +unbiased +unbind +unblock +unblocked +unblocking +unblocks +unborn +unbound +unbounded +unbreakable +unbridled +unbroken +unbuffered +uncancelled +uncanny +uncapitalized +uncaught +uncertain +uncertainly +uncertainties +uncertainty +unchangeable +unchanged +unchanging +unclaimed +unclassified +uncle +unclean +uncleanly +uncleanness +unclear +uncleared +uncles +unclosed +uncomfortable +uncomfortably +uncommitted +uncommon +uncommonly +uncompromising +uncomputable +unconcerned +unconcernedly +unconditional +unconditionally +unconnected +unconscionable +unconscious +unconsciously +unconsciousness +unconstitutional +unconstrained +uncontrollability +uncontrollable +uncontrollably +uncontrolled +unconventional +unconventionally +unconvinced +unconvincing +uncoordinated +uncorrectable +uncorrected +uncountable +uncountably +uncouth +uncover +uncovered +uncovering +uncovers +undamaged +undaunted +undauntedly +undecidable +undecided +undeclared +undecomposable +undefinability +undefined +undeleted +undeniable +undeniably +under +underbrush +underdone +underestimate +underestimated +underestimates +underestimating +underestimation +underflow +underflowed +underflowing +underflows +underfoot +undergo +undergoes +undergoing +undergone +undergraduate +undergraduates +underground +underlie +underlies +underline +underlined +underlines +underling +underlings +underlining +underlinings +underloaded +underlying +undermine +undermined +undermines +undermining +underneath +underpinning +underpinnings +underplay +underplayed +underplaying +underplays +underscore +underscored +underscores +understand +understandability +understandable +understandably +understanding +understandingly +understandings +understands +understated +understood +undertake +undertaken +undertaker +undertakers +undertakes +undertaking +undertakings +undertook +underwater +underway +underwear +underwent +underworld +underwrite +underwriter +underwriters +underwrites +underwriting +undesirability +undesirable +undetectable +undetected +undetermined +undeveloped +undid +undiminished +undirected +undisciplined +undiscovered +undisturbed +undivided +undo +undocumented +undoes +undoing +undoings +undone +undoubtedly +undress +undressed +undresses +undressing +undue +unduly +uneasily +uneasiness +uneasy +uneconomic +uneconomical +unembellished +unemployed +unemployment +unencrypted +unending +unenlightening +unequal +unequaled +unequally +unequivocal +unequivocally +UNESCO +unessential +unevaluated +uneven +unevenly +unevenness +uneventful +unexcused +unexpanded +unexpected +unexpectedly +unexplained +unexplored +unextended +unfair +unfairly +unfairness +unfaithful +unfaithfully +unfaithfulness +unfamiliar +unfamiliarity +unfamiliarly +unfavorable +unfettered +unfinished +unfit +unfitness +unflagging +unfold +unfolded +unfolding +unfolds +unforeseen +unforgeable +unforgiving +unformatted +unfortunate +unfortunately +unfortunates +unfounded +unfriendliness +unfriendly +unfulfilled +ungrammatical +ungrateful +ungratefully +ungratefulness +ungrounded +unguarded +unguided +unhappier +unhappiest +unhappily +unhappiness +unhappy +unharmed +unhealthy +unheard +unheeded +Unibus +unicorn +unicorns +unicycle +unidentified +unidirectional +unidirectionality +unidirectionally +unification +unifications +unified +unifier +unifiers +unifies +uniform +uniformed +uniformity +uniformly +uniforms +unify +unifying +unilluminating +unimaginable +unimpeded +unimplemented +unimportant +unindented +uninitialized +uninsulated +unintelligible +unintended +unintentional +unintentionally +uninteresting +uninterestingly +uninterpreted +uninterrupted +uninterruptedly +union +unionization +unionize +unionized +unionizer +unionizers +unionizes +unionizing +unions +UniPlus +uniprocessor +unique +uniquely +uniqueness +Uniroyal +UniSoft +unison +unit +Unitarian +Unitarianize +Unitarianizes +Unitarians +unite +united +unites +unities +uniting +units +unity +Univac +univalve +univalves +universal +universality +universally +universals +universe +universes +universities +university +UNIX +Unix +unjust +unjustifiable +unjustified +unjustly +unkind +unkindly +unkindness +unknowable +unknowing +unknowingly +unknown +unknowns +unlabelled +unlawful +unlawfully +unleash +unleashed +unleashes +unleashing +unless +unlike +unlikely +unlikeness +unlimited +unlink +unlinked +unlinking +unlinks +unload +unloaded +unloading +unloads +unlock +unlocked +unlocking +unlocks +unlucky +unmanageable +unmanageably +unmanned +unmarked +unmarried +unmask +unmasked +unmatched +unmentionable +unmerciful +unmercifully +unmistakable +unmistakably +unmodified +unmoved +unnamed +unnatural +unnaturally +unnaturalness +unnecessarily +unnecessary +unneeded +unnerve +unnerved +unnerves +unnerving +unnoticed +unobservable +unobserved +unobtainable +unoccupied +unofficial +unofficially +unopened +unordered +unpack +unpacked +unpacking +unpacks +unpaid +unparalleled +unparsed +unplanned +unpleasant +unpleasantly +unpleasantness +unplug +unpopular +unpopularity +unprecedented +unpredictable +unpredictably +unprescribed +unpreserved +unprimed +unprofitable +unprojected +unprotected +unprovability +unprovable +unproven +unpublished +unqualified +unqualifiedly +unquestionably +unquestioned +unquoted +unravel +unraveled +unraveling +unravels +unreachable +unreal +unrealistic +unrealistically +unreasonable +unreasonableness +unreasonably +unrecognizable +unrecognized +unregulated +unrelated +unreliability +unreliable +unreported +unrepresentable +unresolved +unresponsive +unrest +unrestrained +unrestricted +unrestrictedly +unrestrictive +unroll +unrolled +unrolling +unrolls +unruly +unsafe +unsafely +unsanitary +unsatisfactory +unsatisfiability +unsatisfiable +unsatisfied +unsatisfying +unscrupulous +unseeded +unseen +unselected +unselfish +unselfishly +unselfishness +unsent +unsettled +unsettling +unshaken +unshared +unsigned +unskilled +unslotted +unsolvable +unsolved +unsophisticated +unsound +unspeakable +unspecified +unstable +unsteadiness +unsteady +unstructured +unsuccessful +unsuccessfully +unsuitable +unsuited +unsupported +unsure +unsurprising +unsurprisingly +unsynchronized +untagged +untapped +untenable +unterminated +untested +unthinkable +unthinking +untidiness +untidy +untie +untied +unties +until +untimely +unto +untold +untouchable +untouchables +untouched +untoward +untrained +untranslated +untreated +untried +untrue +untruthful +untruthfulness +untying +unusable +unused +unusual +unusually +unvarying +unveil +unveiled +unveiling +unveils +unwanted +unwelcome +unwholesome +unwieldiness +unwieldy +unwilling +unwillingly +unwillingness +unwind +unwinder +unwinders +unwinding +unwinds +unwise +unwisely +unwiser +unwisest +unwitting +unwittingly +unworthiness +unworthy +unwound +unwrap +unwrapped +unwrapping +unwraps +unwritten +up +upbraid +upcoming +update +updated +updater +updates +updating +upgrade +upgraded +upgrades +upgrading +upheld +uphill +uphold +upholder +upholders +upholding +upholds +upholster +upholstered +upholsterer +upholstering +upholsters +upkeep +upland +uplands +uplift +uplink +uplinks +upload +upon +upper +uppermost +upright +uprightly +uprightness +uprising +uprisings +uproar +uproot +uprooted +uprooting +uproots +upset +upsets +upshot +upshots +upside +upstairs +upstream +Upton +upturn +upturned +upturning +upturns +upward +upwards +Urania +Uranus +urban +Urbana +urchin +urchins +Urdu +urge +urged +urgent +urgently +urges +urging +urgings +Uri +urinate +urinated +urinates +urinating +urination +urine +Uris +urn +urns +Urquhart +Ursa +Ursula +Ursuline +Uruguay +Uruguay'a +Uruguayan +Uruguayans +us +usability +usable +usably +usage +usages +use +used +useful +usefully +usefulness +useless +uselessly +uselessness +Usenet +Usenix +user +users +uses +usher +ushered +ushering +ushers +using +usual +usually +usurp +usurped +usurper +Utah +utensil +utensils +Utica +utilities +utility +utilization +utilizations +utilize +utilized +utilizes +utilizing +utmost +utopia +utopian +Utopianize +Utopianizes +utopians +Utrecht +utter +utterance +utterances +uttered +uttering +utterly +uttermost +utters +Uzi +vacancies +vacancy +vacant +vacantly +vacate +vacated +vacates +vacating +vacation +vacationed +vacationer +vacationers +vacationing +vacations +vacuo +vacuous +vacuously +vacuum +vacuumed +vacuuming +Vaduz +vagabond +vagabonds +vagaries +vagary +vagina +vaginas +vagrant +vagrantly +vague +vaguely +vagueness +vaguer +vaguest +Vail +vain +vainly +vale +valence +valences +valentine +valentines +Valerie +Valery +vales +valet +valets +Valhalla +valiant +valiantly +valid +validate +validated +validates +validating +validation +validity +validly +validness +Valkyrie +Valletta +valley +valleys +Valois +valor +Valparaiso +valuable +valuables +valuably +valuation +valuations +value +valued +valuer +valuers +values +valuing +valve +valves +vampire +van +Vance +Vancement +Vancouver +vandalize +vandalized +vandalizes +vandalizing +Vandenberg +Vanderbilt +Vanderburgh +Vanderpoel +vane +vanes +Vanessa +vanguard +vanilla +vanish +vanished +vanisher +vanishes +vanishing +vanishingly +vanities +vanity +vanquish +vanquished +vanquishes +vanquishing +vans +vantage +vapor +vaporing +vapors +variability +variable +variableness +variables +variably +Varian +variance +variances +variant +variantly +variants +variation +variations +varied +varies +varieties +variety +various +variously +Varitype +Varityping +varnish +varnishes +vary +varying +varyings +vase +vases +Vasquez +vassal +Vassar +vast +vaster +vastest +vastly +vastness +vat +Vatican +Vaticanization +Vaticanizations +Vaticanize +Vaticanizes +vats +vaudeville +Vaudois +Vaughan +Vaughn +vault +vaulted +vaulter +vaulting +vaults +vaunt +vaunted +VAX +VAXes +veal +vector +vectorization +vectorizing +vectors +Veda +veer +veered +veering +veers +Vega +Veganism +Vegas +vegetable +vegetables +vegetarian +vegetarians +vegetate +vegetated +vegetates +vegetating +vegetation +vegetative +vehemence +vehement +vehemently +vehicle +vehicles +vehicular +veil +veiled +veiling +veils +vein +veined +veining +veins +Vela +Velasquez +Vella +velocities +velocity +velvet +vendor +vendors +venerable +veneration +Venetian +Veneto +Venezuela +Venezuelan +vengeance +venial +Venice +venison +Venn +venom +venomous +venomously +vent +vented +ventilate +ventilated +ventilates +ventilating +ventilation +ventricle +ventricles +vents +Ventura +venture +ventured +venturer +venturers +ventures +venturing +venturings +Venus +Venusian +Venusians +Vera +veracity +veranda +verandas +verb +verbal +verbalize +verbalized +verbalizes +verbalizing +verbally +verbose +verbs +Verde +Verderer +Verdi +verdict +verdure +verge +verger +verges +Vergil +verifiability +verifiable +verification +verifications +verified +verifier +verifiers +verifies +verify +verifying +verily +veritable +Verlag +vermin +Vermont +Vern +Verna +vernacular +Verne +Vernon +Verona +Veronica +versa +Versailles +Versatec +versatile +versatility +verse +versed +verses +versing +version +versions +versus +vertebrate +vertebrates +vertex +vertical +vertically +verticalness +vertices +very +vessel +vessels +vest +vested +vestige +vestiges +vestigial +vests +Vesuvius +veteran +veterans +veterinarian +veterinarians +veterinary +veto +vetoed +vetoer +vetoes +vex +vexation +vexed +vexes +vexing +via +viability +viable +viably +vial +vials +vibrate +vibrated +vibrating +vibration +vibrations +vibrator +Vic +vice +viceroy +vices +Vichy +vicinity +vicious +viciously +viciousness +vicissitude +vicissitudes +Vickers +Vicksburg +Vicky +victim +victimize +victimized +victimizer +victimizers +victimizes +victimizing +victims +victor +Victoria +Victorian +Victorianize +Victorianizes +Victorians +victories +victorious +victoriously +victors +victory +Victrola +victual +victualer +victuals +Vida +Vidal +video +videotape +videotapes +Videotex +vie +vied +Vienna +Viennese +Vientiane +vier +vies +Viet +Vietnam +Vietnamese +view +viewable +viewed +viewer +viewers +viewing +viewpoint +viewpoints +views +vigilance +vigilant +vigilante +vigilantes +vigilantly +vignette +vignettes +vigor +vigorous +vigorously +Viking +Vikings +Vikram +vile +vilely +vileness +vilification +vilifications +vilified +vilifies +vilify +vilifying +villa +village +villager +villagers +villages +villain +villainous +villainously +villainousness +villains +villainy +villas +Vince +Vincent +Vinci +vindicate +vindicated +vindication +vindictive +vindictively +vindictiveness +vine +vinegar +vines +vineyard +vineyards +Vinson +vintage +violate +violated +violates +violating +violation +violations +violator +violators +violence +violent +violently +violet +violets +violin +violinist +violinists +violins +viper +vipers +Virgil +virgin +Virginia +Virginian +Virginians +virginity +virgins +Virgo +virtual +virtually +virtue +virtues +virtuoso +virtuosos +virtuous +virtuously +virulent +virus +viruses +visa +visage +visas +viscount +viscounts +viscous +Vishnu +visibility +visible +visibly +Visigoth +Visigoths +vision +visionary +visions +visit +visitation +visitations +visited +visiting +visitor +visitors +visits +visor +visors +vista +vistas +visual +visualize +visualized +visualizer +visualizes +visualizing +visually +vita +vitae +vital +vitality +vitally +vitals +Vito +Vitus +Vivaldi +Vivian +vivid +vividly +vividness +vizier +Vladimir +Vladivostok +vocabularies +vocabulary +vocal +vocally +vocals +vocation +vocational +vocationally +vocations +Vogel +vogue +voice +voiced +voicer +voicers +voices +voicing +void +voided +voider +voiding +voids +volatile +volatilities +volatility +volcanic +volcano +volcanos +volition +Volkswagen +Volkswagens +volley +volleyball +volleyballs +Volstead +volt +Volta +voltage +voltages +Voltaire +Volterra +volts +volume +volumes +voluntarily +voluntary +volunteer +volunteered +volunteering +volunteers +Volvo +vomit +vomited +vomiting +vomits +vortex +Voss +vote +voted +voter +voters +votes +voting +votive +vouch +voucher +vouchers +vouches +vouching +Vought +vow +vowed +vowel +vowels +vower +vowing +vows +voyage +voyaged +voyager +voyagers +voyages +voyaging +voyagings +Vreeland +Vulcan +Vulcanism +vulgar +vulgarly +vulnerabilities +vulnerability +vulnerable +vulture +vultures +Waals +Wabash +Wacke +wacky +Waco +wade +waded +wader +wades +wading +Wadsworth +wafer +wafers +waffle +waffles +waft +wag +wage +waged +wager +wagers +wages +waging +Wagner +Wagnerian +Wagnerize +Wagnerizes +wagon +wagoner +wagons +wags +Wahl +wail +wailed +wailing +wails +Wainwright +waist +waistcoat +waistcoats +waists +wait +Waite +waited +waiter +waiters +waiting +waitress +waitresses +waits +waive +waived +waiver +waiverable +waives +waiving +wake +waked +Wakefield +waken +wakened +wakening +wakes +wakeup +waking +Walbridge +Walcott +Walden +Waldensian +Waldo +Waldorf +Waldron +wales +Walford +Walgreen +walk +walked +walker +walkers +walking +walks +wall +Wallace +walled +Wallenstein +Waller +wallet +wallets +walling +Wallis +wallow +wallowed +wallowing +wallows +Walls +walnut +walnuts +Walpole +walrus +walruses +Walsh +Walt +Walter +Walters +Waltham +Walton +waltz +waltzed +waltzes +waltzing +Walworth +wan +wand +wander +wandered +wanderer +wanderers +wandering +wanderings +wanders +wane +waned +wanes +Wang +waning +wanly +Wansee +Wansley +want +wanted +wanting +wanton +wantonly +wantonness +wants +Wapato +Wappinger +war +warble +warbled +warbler +warbles +warbling +Warburton +ward +warden +wardens +warder +wardrobe +wardrobes +wards +ware +warehouse +warehouses +warehousing +wares +warfare +Warfield +warily +wariness +Waring +warlike +warm +warmed +warmer +warmers +warmest +warming +warmly +warms +warmth +warn +warned +warner +warning +warningly +warnings +Warnock +warns +warp +warped +warping +warps +warrant +warranted +warranties +warranting +warrants +warranty +warred +warring +warrior +warriors +wars +Warsaw +warship +warships +wart +wartime +warts +Warwick +wary +was +wash +Washburn +washed +washer +washers +washes +washing +washings +Washington +Washoe +wasp +wasps +Wasserman +waste +wasted +wasteful +wastefully +wastefulness +wastes +wasting +Watanabe +watch +watched +watcher +watchers +watches +watchful +watchfully +watchfulness +watching +watchings +watchman +watchword +watchwords +water +Waterbury +watered +waterfall +waterfalls +Watergate +Waterhouse +watering +waterings +Waterloo +Waterman +waterproof +waterproofing +Waters +Watertown +waterway +waterways +watery +Watkins +Watson +Wattenberg +Watterson +Watts +Waukesha +Waunona +Waupaca +Waupun +Wausau +Wauwatosa +wave +waved +waveform +waveforms +wavefront +wavefronts +waveguides +Waveland +wavelength +wavelengths +waver +wavers +waves +waving +wax +waxed +waxen +waxer +waxers +waxes +waxing +waxy +way +Wayne +Waynesboro +ways +wayside +wayward +we +weak +weaken +weakened +weakening +weakens +weaker +weakest +weakly +weakness +weaknesses +wealth +wealthiest +wealths +wealthy +wean +weaned +weaning +weapon +weapons +wear +wearable +wearer +wearied +wearier +weariest +wearily +weariness +wearing +wearisome +wearisomely +wears +weary +wearying +weasel +weasels +weather +weathercock +weathercocks +weathered +Weatherford +weathering +weathers +weave +weaver +weaves +weaving +web +Webb +Webber +webs +Webster +Websterville +wedded +wedding +weddings +wedge +wedged +wedges +wedging +wedlock +Wednesday +Wednesdays +weds +wee +weed +weeds +week +weekend +weekends +weekly +Weeks +weep +weeper +weeping +weeps +Wehr +Wei +Weibull +Weider +Weidman +Weierstrass +weigh +weighed +weighing +weighings +weighs +weight +weighted +weighting +weights +weighty +Weinberg +Weiner +Weinstein +weird +weirdly +Weisenheimer +Weiss +Weissman +Weissmuller +Welch +Welcher +Welches +welcome +welcomed +welcomes +welcoming +weld +welded +welder +welding +Weldon +welds +Weldwood +welfare +well +welled +Weller +Welles +Wellesley +welling +Wellington +Wellman +Wells +Wellsville +Welmers +welsh +Welton +wench +wenches +Wendell +Wendy +went +Wentworth +wept +were +Werner +Werther +Wesley +Wesleyan +Wesson +west +westbound +Westbrook +Westchester +western +westerner +westerners +Westfield +Westhampton +Westinghouse +Westminster +Westmore +Weston +Westphalia +Westport +westward +westwards +Westwood +wet +wetly +wetness +wets +wetted +wetter +wettest +wetting +Weyerhauser +whack +whacked +whacking +whacks +whale +Whalen +whaler +whales +whaling +wharf +Wharton +wharves +what +whatever +Whatley +whatsoever +wheat +wheaten +Wheatland +Wheaton +Wheatstone +wheel +wheeled +wheeler +wheelers +wheeling +wheelings +Wheelock +wheels +Whelan +Wheller +whelp +when +whence +whenever +where +whereabouts +whereas +whereby +wherein +whereupon +wherever +whether +which +whichever +while +whim +whimper +whimpered +whimpering +whimpers +whims +whimsical +whimsically +whimsies +whimsy +whine +whined +whines +whining +whip +Whippany +whipped +whipper +whippers +whipping +whippings +Whipple +whips +whirl +whirled +whirling +whirlpool +whirlpools +whirls +whirlwind +whirr +whirring +whisk +whisked +whisker +whiskers +whiskey +whisking +whisks +whisper +whispered +whispering +whisperings +whispers +whistle +whistled +whistler +whistlers +whistles +whistling +whit +Whitaker +Whitcomb +white +Whitehall +Whitehorse +Whiteleaf +Whiteley +whitely +whiten +whitened +whitener +whiteners +whiteness +whitening +whitens +whiter +whites +whitespace +whitest +whitewash +whitewashed +Whitewater +Whitfield +whiting +Whitlock +Whitman +Whitmanize +Whitmanizes +Whitney +Whittaker +Whittier +whittle +whittled +whittles +whittling +whiz +whizzed +whizzes +whizzing +who +whoever +whole +wholehearted +wholeheartedly +wholeness +wholes +wholesale +wholesaler +wholesalers +wholesome +wholesomeness +wholly +whom +whomever +whoop +whooped +whooping +whoops +whore +whores +whorl +whorls +whose +why +Wichita +wick +wicked +wickedly +wickedness +wicker +wicks +wide +wideband +widely +widen +widened +widener +widening +widens +wider +widespread +widest +widget +widow +widowed +widower +widowers +widows +width +widths +Wieland +wield +wielded +wielder +wielding +wields +Wier +wife +wifely +wig +Wiggins +Wightman +wigs +wigwam +Wilbur +Wilcox +wild +wildcat +wildcats +wilder +wilderness +wildest +wildly +wildness +wile +wiles +Wiley +Wilfred +Wilhelm +Wilhelmina +wiliness +Wilkes +Wilkie +Wilkins +Wilkinson +will +Willa +Willamette +Willard +Willcox +willed +Willem +willful +willfully +William +Williams +Williamsburg +Williamson +Willie +Willied +Willies +willing +willingly +willingness +Willis +Willisson +Willoughby +willow +willows +Wills +Willy +Wilma +Wilmette +Wilmington +Wilshire +Wilson +Wilsonian +wilt +wilted +wilting +wilts +Wiltshire +wily +win +wince +winced +winces +Winchell +Winchester +wincing +wind +winded +winder +winders +winding +windmill +windmills +window +windows +winds +Windsor +windy +wine +wined +Winehead +winer +winers +wines +Winfield +wing +winged +winging +wings +Winifred +wining +wink +winked +winker +winking +winks +Winnebago +winner +winners +Winnetka +Winnie +winning +winningly +winnings +Winnipeg +Winnipesaukee +Winograd +Winooski +wins +Winsborough +Winsett +Winslow +Winston +winter +wintered +wintering +Winters +Winthrop +wintry +wipe +wiped +wiper +wipers +wipes +wiping +wire +wired +wireless +wires +wiretap +wiretappers +wiretapping +wiretaps +wiriness +wiring +wiry +Wisconsin +wisdom +wisdoms +wise +wised +wisely +Wisenheimer +wiser +wisest +wish +wished +wisher +wishers +wishes +wishful +wishing +wisp +wisps +wistful +wistfully +wistfulness +wit +witch +witchcraft +witches +witching +with +withal +withdraw +withdrawal +withdrawals +withdrawing +withdrawn +withdraws +withdrew +wither +withers +Witherspoon +withheld +withhold +withholder +withholders +withholding +withholdings +withholds +within +without +withstand +withstanding +withstands +withstood +witness +witnessed +witnesses +witnessing +wits +Witt +Wittgenstein +witty +wives +wizard +wizards +woe +woeful +woefully +woke +Wolcott +wolf +Wolfe +Wolff +Wolfgang +Wolverton +wolves +woman +womanhood +womanly +womb +wombs +women +won +wonder +wondered +wonderful +wonderfully +wonderfulness +wondering +wonderingly +wonderment +wonders +wondrous +wondrously +Wong +wont +wonted +woo +wood +Woodard +Woodberry +Woodbury +woodchuck +woodchucks +woodcock +woodcocks +wooded +wooden +woodenly +woodenness +woodland +Woodlawn +woodman +woodpecker +woodpeckers +Woodrow +Woods +Woodstock +Woodward +Woodwards +woodwork +woodworking +woody +wooed +wooer +woof +woofed +woofer +woofers +woofing +woofs +wooing +wool +woolen +woolly +wools +Woolworth +Woonsocket +woos +Wooster +Worcester +Worcestershire +word +worded +wordily +wordiness +wording +words +Wordsworth +wordy +wore +work +workable +workably +workbench +workbenches +workbook +workbooks +worked +worker +workers +workhorse +workhorses +working +workingman +workings +workload +workman +workmanship +workmen +works +workshop +workshops +workspace +workstation +workstations +world +worldliness +worldly +worlds +worldwide +worm +wormed +worming +worms +worn +worried +worrier +worriers +worries +worrisome +worry +worrying +worryingly +worse +worship +worshiped +worshiper +worshipful +worshiping +worships +worst +worsted +worth +worthiest +worthiness +Worthington +worthless +worthlessness +worths +worthwhile +worthwhileness +worthy +Wotan +would +wound +wounded +wounding +wounds +wove +woven +wrangle +wrangled +wrangler +wrap +wraparound +wrapped +wrapper +wrappers +wrapping +wrappings +wraps +wrath +wreak +wreaks +wreath +wreathed +wreathes +wreck +wreckage +wrecked +wrecker +wreckers +wrecking +wrecks +wren +wrench +wrenched +wrenches +wrenching +wrens +wrest +wrestle +wrestler +wrestles +wrestling +wrestlings +wretch +wretched +wretchedness +wretches +wriggle +wriggled +wriggler +wriggles +wriggling +Wrigley +wring +wringer +wrings +wrinkle +wrinkled +wrinkles +wrist +wrists +wristwatch +wristwatches +writ +writable +write +writer +writers +writes +writhe +writhed +writhes +writhing +writing +writings +writs +written +wrong +wronged +wronging +wrongly +wrongs +Wronskian +wrote +wrought +wrung +Wu +Wuhan +Wyandotte +Wyatt +Wyeth +Wylie +Wyman +Wyner +Wynn +Wyoming +Xanthus +Xavier +Xebec +Xenakis +Xenia +Xenix +Xerox +Xeroxed +Xeroxes +Xeroxing +Xerxes +Xhosa +Yagi +Yakima +Yale +Yalies +Yalta +Yamaha +yank +yanked +Yankee +Yankees +yanking +yanks +Yankton +Yaounde +Yaqui +yard +yards +yardstick +yardsticks +Yarmouth +yarn +yarns +Yates +Yaunde +yawn +yawner +yawning +yea +Yeager +year +yearly +yearn +yearned +yearning +yearnings +years +yeas +yeast +yeasts +Yeats +yell +yelled +yeller +yelling +yellow +yellowed +yellower +yellowest +yellowing +yellowish +Yellowknife +yellowness +yellows +Yellowstone +yelp +yelped +yelping +yelps +Yemen +Yentl +yeoman +yeomen +Yerkes +yes +yesterday +yesterdays +yet +Yiddish +yield +yielded +yielding +yields +Yoder +yoke +yokes +Yoknapatawpha +Yokohama +Yokuts +yon +yonder +Yonkers +Yorick +York +Yorker +Yorkers +Yorkshire +Yorktown +Yosemite +Yost +you +young +younger +youngest +youngly +youngster +youngsters +Youngstown +your +yours +yourself +yourselves +youth +youthes +youthful +youthfully +youthfulness +Ypsilanti +Yuba +Yucatan +Yugoslav +Yugoslavia +Yugoslavian +Yugoslavians +Yuh +Yuki +Yukon +Yuri +Yves +Yvette +Zachary +Zagreb +Zaire +Zambia +Zan +Zanzibar +zeal +Zealand +zealous +zealously +zealousness +zebra +zebras +Zeffirelli +Zeiss +Zellerbach +Zen +zenith +Zennist +zero +zeroed +zeroes +zeroing +zeros +zeroth +zest +Zeus +Ziegfeld +Ziegfelds +Ziegler +Ziggy +zigzag +zillions +Zimmerman +zinc +Zion +Zionism +Zionist +Zionists +Zions +zodiac +Zoe +Zomba +zonal +zonally +zone +zoned +zones +zoning +zoo +zoological +zoologically +zoom +zooms +zoos +Zorn +Zoroaster +Zoroastrian +Zulu +Zulus +Zurich diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/adv-world.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/adv-world.scm new file mode 100644 index 0000000..bc4eb8c --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/adv-world.scm @@ -0,0 +1,83 @@ +;;; Data for adventure game. This file is adv-world.scm + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; setting up the world +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define Soda (instantiate place 'Soda)) +(define BH-Office (instantiate place 'BH-Office)) +(define MJC-Office (instantiate place 'MJC-Office)) +(define art-gallery (instantiate place 'art-gallery)) +(define Pimentel (instantiate place 'Pimentel)) +(define 61A-Lab (instantiate place '61A-Lab)) +(define Sproul-Plaza (instantiate place 'Sproul-Plaza)) +(define Telegraph-Ave (instantiate place 'Telegraph-Ave)) +(define Noahs (instantiate place 'Noahs)) +(define Intermezzo (instantiate place 'Intermezzo)) +(define s-h (instantiate place 'sproul-hall)) + + +(can-go Soda 'up art-gallery) +(can-go art-gallery 'down Soda) +(can-go art-gallery 'west BH-Office) +(can-go BH-Office 'east art-gallery) +(can-go art-gallery 'east MJC-Office) +(can-go MJC-office 'west art-gallery) +(can-go Soda 'south Pimentel) +(can-go Pimentel 'north Soda) +(can-go Pimentel 'south 61A-Lab) +(can-go 61A-Lab 'north Pimentel) +(can-go 61A-Lab 'west s-h) +(can-go s-h 'east 61A-Lab) +(can-go Sproul-Plaza 'east s-h) +(can-go s-h 'west Sproul-Plaza) +(can-go Sproul-Plaza 'north Pimentel) +(can-go Sproul-Plaza 'south Telegraph-Ave) +(can-go Telegraph-Ave 'north Sproul-Plaza) +(can-go Telegraph-Ave 'south Noahs) +(can-go Noahs 'north Telegraph-Ave) +(can-go Noahs 'south Intermezzo) +(can-go Intermezzo 'north Noahs) + +;; Some people. +; MOVED above the add-entry-procedure stuff, to avoid the "The computers +; seem to be down" message that would occur when hacker enters 61a-lab +; -- Ryan Stejskal + +(define Brian (instantiate person 'Brian BH-Office)) +(define hacker (instantiate person 'hacker 61A-lab)) +(define nasty (instantiate thief 'nasty sproul-plaza)) + +(define (sproul-hall-exit) + (error "You can check out any time you'd like, but you can never leave")) + +(define (bh-office-exit) + (print "What's your favorite programming language?") + (let ((answer (read))) + (if (eq? answer 'scheme) + (print "Good answer, but my favorite is Logo!") + (begin (newline) (bh-office-exit))))) + + +(ask s-h 'add-entry-procedure + (lambda () (print "Miles and miles of students are waiting in line..."))) +(ask s-h 'add-exit-procedure sproul-hall-exit) +(ask BH-Office 'add-exit-procedure bh-office-exit) +(ask Noahs 'add-entry-procedure + (lambda () (print "Would you like lox with it?"))) +(ask Noahs 'add-exit-procedure + (lambda () (print "How about a cinnamon raisin bagel for dessert?"))) +(ask Telegraph-Ave 'add-entry-procedure + (lambda () (print "There are tie-dyed shirts as far as you can see..."))) +(ask 61A-Lab 'add-entry-procedure + (lambda () (print "The computers seem to be down"))) +(ask 61A-Lab 'add-exit-procedure + (lambda () (print "The workstations come back to life just in time."))) + +;; Some things. + +(define bagel (instantiate thing 'bagel)) +(ask Noahs 'appear bagel) + +(define coffee (instantiate thing 'coffee)) +(ask Intermezzo 'appear coffee) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/adv.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/adv.scm new file mode 100644 index 0000000..f4a94cb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/adv.scm @@ -0,0 +1,235 @@ +;; ADV.SCM +;; This file contains the definitions for the objects in the adventure +;; game and some utility procedures. + +(define-class (place name) + (instance-vars + (directions-and-neighbors '()) + (things '()) + (people '()) + (entry-procs '()) + (exit-procs '())) + (method (type) 'place) + (method (neighbors) (map cdr directions-and-neighbors)) + (method (exits) (map car directions-and-neighbors)) + (method (look-in direction) + (let ((pair (assoc direction directions-and-neighbors))) + (if (not pair) + '() ;; nothing in that direction + (cdr pair)))) ;; return the place object + (method (appear new-thing) + (if (memq new-thing things) + (error "Thing already in this place" (list name new-thing))) + (set! things (cons new-thing things)) + 'appeared) + (method (enter new-person) + (if (memq new-person people) + (error "Person already in this place" (list name new-person))) + (set! people (cons new-person people)) + (for-each (lambda (proc) (proc)) entry-procs) + 'appeared) + (method (gone thing) + (if (not (memq thing things)) + (error "Disappearing thing not here" (list name thing))) + (set! things (delete thing things)) + 'disappeared) + (method (exit person) + (for-each (lambda (proc) (proc)) exit-procs) + (if (not (memq person people)) + (error "Disappearing person not here" (list name person))) + (set! people (delete person people)) + 'disappeared) + + (method (new-neighbor direction neighbor) + (if (assoc direction directions-and-neighbors) + (error "Direction already assigned a neighbor" (list name direction))) + (set! directions-and-neighbors + (cons (cons direction neighbor) directions-and-neighbors)) + 'connected) + + (method (add-entry-procedure proc) + (set! entry-procs (cons proc entry-procs))) + (method (add-exit-procedure proc) + (set! exit-procs (cons proc exit-procs))) + (method (remove-entry-procedure proc) + (set! entry-procs (delete proc entry-procs))) + (method (remove-exit-procedure proc) + (set! exit-procs (delete proc exit-procs))) + (method (clear-all-procs) + (set! exit-procs '()) + (set! entry-procs '()) + 'cleared) ) + +(define-class (person name place) + (instance-vars + (possessions '()) + (saying "")) + (initialize + (ask place 'enter self)) + (method (type) 'person) + (method (look-around) + (map (lambda (obj) (ask obj 'name)) + (filter (lambda (thing) (not (eq? thing self))) + (append (ask place 'things) (ask place 'people))))) + (method (take thing) + (cond ((not (thing? thing)) (error "Not a thing" thing)) + ((not (memq thing (ask place 'things))) + (error "Thing taken not at this place" + (list (ask place 'name) thing))) + ((memq thing possessions) (error "You already have it!")) + (else + (announce-take name thing) + (set! possessions (cons thing possessions)) + + ;; If somebody already has this object... + (for-each + (lambda (pers) + (if (and (not (eq? pers self)) ; ignore myself + (memq thing (ask pers 'possessions))) + (begin + (ask pers 'lose thing) + (have-fit pers)))) + (ask place 'people)) + + (ask thing 'change-possessor self) + 'taken))) + + (method (lose thing) + (set! possessions (delete thing possessions)) + (ask thing 'change-possessor 'no-one) + 'lost) + (method (talk) (print saying)) + (method (set-talk string) (set! saying string)) + (method (exits) (ask place 'exits)) + (method (notice person) (ask self 'talk)) + (method (go direction) + (let ((new-place (ask place 'look-in direction))) + (cond ((null? new-place) + (error "Can't go" direction)) + (else + (ask place 'exit self) + (announce-move name place new-place) + (for-each + (lambda (p) + (ask place 'gone p) + (ask new-place 'appear p)) + possessions) + (set! place new-place) + (ask new-place 'enter self))))) ) + +(define thing + (let () + (lambda (class-message) + (cond + ((eq? class-message 'instantiate) + (lambda (name) + (let ((self '()) (possessor 'no-one)) + (define (dispatch message) + (cond + ((eq? message 'initialize) + (lambda (value-for-self) + (set! self value-for-self))) + ((eq? message 'send-usual-to-parent) + (error "Can't use USUAL without a parent." 'thing)) + ((eq? message 'name) (lambda () name)) + ((eq? message 'possessor) (lambda () possessor)) + ((eq? message 'type) (lambda () 'thing)) + ((eq? message 'change-possessor) + (lambda (new-possessor) + (set! possessor new-possessor))) + (else (no-method 'thing)))) + dispatch))) + (else (error "Bad message to class" class-message)))))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Implementation of thieves for part two +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define *foods* '(pizza potstickers coffee)) + +(define (edible? thing) + (member? (ask thing 'name) *foods*)) + +(define-class (thief name initial-place) + (parent (person name initial-place)) + (instance-vars + (behavior 'steal)) + (method (type) 'thief) + + (method (notice person) + (if (eq? behavior 'run) + (ask self 'go (pick-random (ask (usual 'place) 'exits))) + (let ((food-things + (filter (lambda (thing) + (and (edible? thing) + (not (eq? (ask thing 'possessor) self)))) + (ask (usual 'place) 'things)))) + (if (not (null? food-things)) + (begin + (ask self 'take (car food-things)) + (set! behavior 'run) + (ask self 'notice person)) )))) ) + +;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Utility procedures +;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; this next procedure is useful for moving around + +(define (move-loop who) + (newline) + (print (ask who 'exits)) + (display "? > ") + (let ((dir (read))) + (if (equal? dir 'stop) + (newline) + (begin (ask who 'go dir) + (move-loop who))))) + + +;; One-way paths connect individual places. + +(define (can-go from direction to) + (ask from 'new-neighbor direction to)) + + +(define (announce-take name thing) + (newline) + (display name) + (display " took ") + (display (ask thing 'name)) + (newline)) + +(define (announce-move name old-place new-place) + (newline) + (newline) + (display name) + (display " moved from ") + (display (ask old-place 'name)) + (display " to ") + (display (ask new-place 'name)) + (newline)) + +(define (have-fit p) + (newline) + (display "Yaaah! ") + (display (ask p 'name)) + (display " is upset!") + (newline)) + + +(define (pick-random set) + (nth (random (length set)) set)) + +(define (delete thing stuff) + (cond ((null? stuff) '()) + ((eq? thing (car stuff)) (cdr stuff)) + (else (cons (car stuff) (delete thing (cdr stuff)))) )) + +(define (person? obj) + (and (procedure? obj) + (member? (ask obj 'type) '(person police thief)))) + +(define (thing? obj) + (and (procedure? obj) + (eq? (ask obj 'type) 'thing))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/ambdiff b/js/games/nluqo.github.io/~bh/61a-pages/Lib/ambdiff new file mode 100644 index 0000000..4d76cda --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/ambdiff @@ -0,0 +1,309 @@ +1,2c1,2 +< ;;;;METACIRCULAR EVALUATOR THAT SEPARATES ANALYSIS FROM EXECUTION +< ;;;; FROM SECTION 4.1.7 OF STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS +--- +> ;;;;AMB EVALUATOR FROM SECTION 4.3 OF +> ;;;; STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS +4c4,7 +< ;;;;Matches code in ch4.scm +--- +> ;;;;Matches code in ch4.scm. +> ;;;; To run the sample programs and exercises, code below also includes +> ;;;; -- enlarged primitive-procedures list +> ;;;; -- support for Let (as noted in footnote 56, p.428) +18c21 +< ;;Note: It is loaded first so that the section 4.1.7 definition +--- +> ;;Note: It is loaded first so that the section 4.2 definition +20c23 +< (load "61a/lib/mceval.scm") +--- +> (load "~/61a/lib/mceval.scm") +22d24 +< ;;;SECTION 4.1.7 +24,25d25 +< (define (mc-eval exp env) +< ((analyze exp) env)) +26a27,33 +> ;;;Code from SECTION 4.3.3, modified as needed to run it +> +> (define (amb? exp) (tagged-list? exp 'amb)) +> (define (amb-choices exp) (cdr exp)) +> +> ;; analyze from 4.1.6, with clause from 4.3.3 added +> ;; and also support for Let +37a45,46 +> ((let? exp) (analyze (let->combination exp))) ;** +> ((amb? exp) (analyze-amb exp)) ;** +41a51,55 +> (define (ambeval exp env succeed fail) +> ((analyze exp) env succeed fail)) +> +> ;;;Simple expressions +> +43c57,58 +< (lambda (env) exp)) +--- +> (lambda (env succeed fail) +> (succeed exp fail))) +47c62,63 +< (lambda (env) qval))) +--- +> (lambda (env succeed fail) +> (succeed qval fail)))) +50c66,68 +< (lambda (env) (lookup-variable-value exp env))) +--- +> (lambda (env succeed fail) +> (succeed (lookup-variable-value exp env) +> fail))) +52,57c70,75 +< (define (analyze-assignment exp) +< (let ((var (assignment-variable exp)) +< (vproc (analyze (assignment-value exp)))) +< (lambda (env) +< (set-variable-value! var (vproc env) env) +< 'ok))) +--- +> (define (analyze-lambda exp) +> (let ((vars (lambda-parameters exp)) +> (bproc (analyze-sequence (lambda-body exp)))) +> (lambda (env succeed fail) +> (succeed (make-procedure vars bproc env) +> fail)))) +59,64c77 +< (define (analyze-definition exp) +< (let ((var (definition-variable exp)) +< (vproc (analyze (definition-value exp)))) +< (lambda (env) +< (define-variable! var (vproc env) env) +< 'ok))) +--- +> ;;;Conditionals and sequences +70,73c83,92 +< (lambda (env) +< (if (true? (pproc env)) +< (cproc env) +< (aproc env))))) +--- +> (lambda (env succeed fail) +> (pproc env +> ;; success continuation for evaluating the predicate +> ;; to obtain pred-value +> (lambda (pred-value fail2) +> (if (true? pred-value) +> (cproc env succeed fail2) +> (aproc env succeed fail2))) +> ;; failure continuation for evaluating the predicate +> fail)))) +75,79d93 +< (define (analyze-lambda exp) +< (let ((vars (lambda-parameters exp)) +< (bproc (analyze-sequence (lambda-body exp)))) +< (lambda (env) (make-procedure vars bproc env)))) +< +81,82c95,102 +< (define (sequentially proc1 proc2) +< (lambda (env) (proc1 env) (proc2 env))) +--- +> (define (sequentially a b) +> (lambda (env succeed fail) +> (a env +> ;; success continuation for calling a +> (lambda (a-value fail2) +> (b env succeed fail2)) +> ;; failure continuation for calling a +> fail))) +92a113,143 +> ;;;Definitions and assignments +> +> (define (analyze-definition exp) +> (let ((var (definition-variable exp)) +> (vproc (analyze (definition-value exp)))) +> (lambda (env succeed fail) +> (vproc env +> (lambda (val fail2) +> (define-variable! var val env) +> (succeed 'ok fail2)) +> fail)))) +> +> (define (analyze-assignment exp) +> (let ((var (assignment-variable exp)) +> (vproc (analyze (assignment-value exp)))) +> (lambda (env succeed fail) +> (vproc env +> (lambda (val fail2) ; *1* +> (let ((old-value +> (lookup-variable-value var env))) +> (set-variable-value! var val env) +> (succeed 'ok +> (lambda () ; *2* +> (set-variable-value! var +> old-value +> env) +> (fail2))))) +> fail)))) +> +> ;;;Procedure applications +> +96,99c147,156 +< (lambda (env) +< (execute-application (fproc env) +< (map (lambda (aproc) (aproc env)) +< aprocs))))) +--- +> (lambda (env succeed fail) +> (fproc env +> (lambda (proc fail2) +> (get-args aprocs +> env +> (lambda (args fail3) +> (execute-application +> proc args succeed fail3)) +> fail2)) +> fail)))) +101c158,174 +< (define (execute-application proc args) +--- +> (define (get-args aprocs env succeed fail) +> (if (null? aprocs) +> (succeed '() fail) +> ((car aprocs) env +> ;; success continuation for this aproc +> (lambda (arg fail2) +> (get-args (cdr aprocs) +> env +> ;; success continuation for recursive +> ;; call to get-args +> (lambda (args fail3) +> (succeed (cons arg args) +> fail3)) +> fail2)) +> fail))) +> +> (define (execute-application proc args succeed fail) +103c176,177 +< (apply-primitive-procedure proc args)) +--- +> (succeed (apply-primitive-procedure proc args) +> fail)) +108c182,184 +< (procedure-environment proc)))) +--- +> (procedure-environment proc)) +> succeed +> fail)) +113a190,291 +> ;;;amb expressions +> +> (define (analyze-amb exp) +> (let ((cprocs (map analyze (amb-choices exp)))) +> (lambda (env succeed fail) +> (define (try-next choices) +> (if (null? choices) +> (fail) +> ((car choices) env +> succeed +> (lambda () +> (try-next (cdr choices)))))) +> (try-next cprocs)))) +> +> ;;;Driver loop +> +> (define input-prompt ";;; Amb-Eval input:") +> (define output-prompt ";;; Amb-Eval value:") +> +> (define (driver-loop) +> (define (internal-loop try-again) +> (prompt-for-input input-prompt) +> (let ((input (read))) +> (if (eq? input 'try-again) +> (try-again) +> (begin +> (newline) +> (display ";;; Starting a new problem ") +> (ambeval input +> the-global-environment +> ;; ambeval success +> (lambda (val next-alternative) +> (announce-output output-prompt) +> (user-print val) +> (internal-loop next-alternative)) +> ;; ambeval failure +> (lambda () +> (announce-output +> ";;; There are no more values of") +> (user-print input) +> (driver-loop))))))) +> (internal-loop +> (lambda () +> (newline) +> (display ";;; There is no current problem") +> (driver-loop)))) +> +> +> +> ;;; Support for Let (as noted in footnote 56, p.428) +> +> (define (let? exp) (tagged-list? exp 'let)) +> (define (let-bindings exp) (cadr exp)) +> (define (let-body exp) (cddr exp)) +> +> (define (let-var binding) (car binding)) +> (define (let-val binding) (cadr binding)) +> +> (define (make-combination operator operands) (cons operator operands)) +> +> (define (let->combination exp) +> ;;make-combination defined in earlier exercise +> (let ((bindings (let-bindings exp))) +> (make-combination (make-lambda (map let-var bindings) +> (let-body exp)) +> (map let-val bindings)))) +> +> +> +> ;; A longer list of primitives -- suitable for running everything in 4.3 +> ;; Overrides the list in ch4-mceval.scm +> ;; Has Not to support Require; various stuff for code in text (including +> ;; support for Prime?); integer? and sqrt for exercise code; +> ;; eq? for ex. solution +> +> (define primitive-procedures +> (list (list 'car car) +> (list 'cdr cdr) +> (list 'cons cons) +> (list 'null? null?) +> (list 'list list) +> (list 'append append) +> (list 'memq memq) +> (list 'member member) +> (list 'not not) +> (list '+ +) +> (list '- -) +> (list '* *) +> (list '= =) +> (list '> >) +> (list '>= >=) +> (list 'abs abs) +> (list 'remainder remainder) +> (list 'integer? integer?) +> (list 'sqrt sqrt) +> (list 'eq? eq?) +> (list 'equal? equal?) +> (list 'pair? pair?) +> ;; more primitives +> )) +> +> +116,117c294,300 +< (define input-prompt ";;; A-Eval input:") +< (define output-prompt ";;; A-Eval value:") +--- +> (define (mce) +> (set! the-global-environment (setup-environment)) +> (ambeval '(define (require p) (if (not p) (amb))) +> the-global-environment +> (lambda (a b) #t) +> (lambda () #t)) +> (driver-loop)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/ambeval.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/ambeval.scm new file mode 100644 index 0000000..e9fbeb2 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/ambeval.scm @@ -0,0 +1,300 @@ +;;;;AMB EVALUATOR FROM SECTION 4.3 OF +;;;; STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS + +;;;;Matches code in ch4.scm. +;;;; To run the sample programs and exercises, code below also includes +;;;; -- enlarged primitive-procedures list +;;;; -- support for Let (as noted in footnote 56, p.428) + +;;;;This file can be loaded into Scheme as a whole. +;;;;**NOTE**This file loads the metacircular evaluator of +;;;; sections 4.1.1-4.1.4, since it uses the expression representation, +;;;; environment representation, etc. +;;;; You may need to change the (load ...) expression to work in your +;;;; version of Scheme. + +;;;;Then you can initialize and start the evaluator by evaluating +;;;; the expression (mce). + + +;;**implementation-dependent loading of evaluator file +;;Note: It is loaded first so that the section 4.2 definition +;; of eval overrides the definition from 4.1.1 +(load "~/61a/Lib/mceval.scm") + + + +;;;Code from SECTION 4.3.3, modified as needed to run it + +(define (amb? exp) (tagged-list? exp 'amb)) +(define (amb-choices exp) (cdr exp)) + +;; analyze from 4.1.6, with clause from 4.3.3 added +;; and also support for Let +(define (analyze exp) + (cond ((self-evaluating? exp) + (analyze-self-evaluating exp)) + ((quoted? exp) (analyze-quoted exp)) + ((variable? exp) (analyze-variable exp)) + ((assignment? exp) (analyze-assignment exp)) + ((definition? exp) (analyze-definition exp)) + ((if? exp) (analyze-if exp)) + ((lambda? exp) (analyze-lambda exp)) + ((begin? exp) (analyze-sequence (begin-actions exp))) + ((cond? exp) (analyze (cond->if exp))) + ((let? exp) (analyze (let->combination exp))) ;** + ((amb? exp) (analyze-amb exp)) ;** + ((application? exp) (analyze-application exp)) + (else + (error "Unknown expression type -- ANALYZE" exp)))) + +(define (ambeval exp env succeed fail) + ((analyze exp) env succeed fail)) + +;;;Simple expressions + +(define (analyze-self-evaluating exp) + (lambda (env succeed fail) + (succeed exp fail))) + +(define (analyze-quoted exp) + (let ((qval (text-of-quotation exp))) + (lambda (env succeed fail) + (succeed qval fail)))) + +(define (analyze-variable exp) + (lambda (env succeed fail) + (succeed (lookup-variable-value exp env) + fail))) + +(define (analyze-lambda exp) + (let ((vars (lambda-parameters exp)) + (bproc (analyze-sequence (lambda-body exp)))) + (lambda (env succeed fail) + (succeed (make-procedure vars bproc env) + fail)))) + +;;;Conditionals and sequences + +(define (analyze-if exp) + (let ((pproc (analyze (if-predicate exp))) + (cproc (analyze (if-consequent exp))) + (aproc (analyze (if-alternative exp)))) + (lambda (env succeed fail) + (pproc env + ;; success continuation for evaluating the predicate + ;; to obtain pred-value + (lambda (pred-value fail2) + (if (true? pred-value) + (cproc env succeed fail2) + (aproc env succeed fail2))) + ;; failure continuation for evaluating the predicate + fail)))) + +(define (analyze-sequence exps) + (define (sequentially a b) + (lambda (env succeed fail) + (a env + ;; success continuation for calling a + (lambda (a-value fail2) + (b env succeed fail2)) + ;; failure continuation for calling a + fail))) + (define (loop first-proc rest-procs) + (if (null? rest-procs) + first-proc + (loop (sequentially first-proc (car rest-procs)) + (cdr rest-procs)))) + (let ((procs (map analyze exps))) + (if (null? procs) + (error "Empty sequence -- ANALYZE")) + (loop (car procs) (cdr procs)))) + +;;;Definitions and assignments + +(define (analyze-definition exp) + (let ((var (definition-variable exp)) + (vproc (analyze (definition-value exp)))) + (lambda (env succeed fail) + (vproc env + (lambda (val fail2) + (define-variable! var val env) + (succeed 'ok fail2)) + fail)))) + +(define (analyze-assignment exp) + (let ((var (assignment-variable exp)) + (vproc (analyze (assignment-value exp)))) + (lambda (env succeed fail) + (vproc env + (lambda (val fail2) ; *1* + (let ((old-value + (lookup-variable-value var env))) + (set-variable-value! var val env) + (succeed 'ok + (lambda () ; *2* + (set-variable-value! var + old-value + env) + (fail2))))) + fail)))) + +;;;Procedure applications + +(define (analyze-application exp) + (let ((fproc (analyze (operator exp))) + (aprocs (map analyze (operands exp)))) + (lambda (env succeed fail) + (fproc env + (lambda (proc fail2) + (get-args aprocs + env + (lambda (args fail3) + (execute-application + proc args succeed fail3)) + fail2)) + fail)))) + +(define (get-args aprocs env succeed fail) + (if (null? aprocs) + (succeed '() fail) + ((car aprocs) env + ;; success continuation for this aproc + (lambda (arg fail2) + (get-args (cdr aprocs) + env + ;; success continuation for recursive + ;; call to get-args + (lambda (args fail3) + (succeed (cons arg args) + fail3)) + fail2)) + fail))) + +(define (execute-application proc args succeed fail) + (cond ((primitive-procedure? proc) + (succeed (apply-primitive-procedure proc args) + fail)) + ((compound-procedure? proc) + ((procedure-body proc) + (extend-environment (procedure-parameters proc) + args + (procedure-environment proc)) + succeed + fail)) + (else + (error + "Unknown procedure type -- EXECUTE-APPLICATION" + proc)))) + +;;;amb expressions + +(define (analyze-amb exp) + (let ((cprocs (map analyze (amb-choices exp)))) + (lambda (env succeed fail) + (define (try-next choices) + (if (null? choices) + (fail) + ((car choices) env + succeed + (lambda () + (try-next (cdr choices)))))) + (try-next cprocs)))) + +;;;Driver loop + +(define input-prompt ";;; Amb-Eval input:") +(define output-prompt ";;; Amb-Eval value:") + +(define (driver-loop) + (define (internal-loop try-again) + (prompt-for-input input-prompt) + (let ((input (read))) + (if (eq? input 'try-again) + (try-again) + (begin + (newline) + (display ";;; Starting a new problem ") + (ambeval input + the-global-environment + ;; ambeval success + (lambda (val next-alternative) + (announce-output output-prompt) + (user-print val) + (internal-loop next-alternative)) + ;; ambeval failure + (lambda () + (announce-output + ";;; There are no more values of") + (user-print input) + (driver-loop))))))) + (internal-loop + (lambda () + (newline) + (display ";;; There is no current problem") + (driver-loop)))) + + + +;;; Support for Let (as noted in footnote 56, p.428) + +(define (let? exp) (tagged-list? exp 'let)) +(define (let-bindings exp) (cadr exp)) +(define (let-body exp) (cddr exp)) + +(define (let-var binding) (car binding)) +(define (let-val binding) (cadr binding)) + +(define (make-combination operator operands) (cons operator operands)) + +(define (let->combination exp) + ;;make-combination defined in earlier exercise + (let ((bindings (let-bindings exp))) + (make-combination (make-lambda (map let-var bindings) + (let-body exp)) + (map let-val bindings)))) + + + +;; A longer list of primitives -- suitable for running everything in 4.3 +;; Overrides the list in ch4-mceval.scm +;; Has Not to support Require; various stuff for code in text (including +;; support for Prime?); integer? and sqrt for exercise code; +;; eq? for ex. solution + +(define primitive-procedures + (list (list 'car car) + (list 'cdr cdr) + (list 'cons cons) + (list 'null? null?) + (list 'list list) + (list 'append append) + (list 'memq memq) + (list 'member member) + (list 'not not) + (list '+ +) + (list '- -) + (list '* *) + (list '= =) + (list '> >) + (list '>= >=) + (list 'abs abs) + (list 'remainder remainder) + (list 'integer? integer?) + (list 'sqrt sqrt) + (list 'eq? eq?) + (list 'equal? equal?) + (list 'pair? pair?) +;; more primitives + )) + + +;;; Added at Berkeley: + +(define (mce) + (set! the-global-environment (setup-environment)) + (ambeval '(define (require p) (if (not p) (amb))) + the-global-environment + (lambda (a b) #t) + (lambda () #t)) + (driver-loop)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/analyze.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/analyze.scm new file mode 100644 index 0000000..3fee1cc --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/analyze.scm @@ -0,0 +1,117 @@ +;;;;METACIRCULAR EVALUATOR THAT SEPARATES ANALYSIS FROM EXECUTION +;;;; FROM SECTION 4.1.7 OF STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS + +;;;;Matches code in ch4.scm + +;;;;This file can be loaded into Scheme as a whole. +;;;;**NOTE**This file loads the metacircular evaluator of +;;;; sections 4.1.1-4.1.4, since it uses the expression representation, +;;;; environment representation, etc. +;;;; You may need to change the (load ...) expression to work in your +;;;; version of Scheme. + +;;;;Then you can initialize and start the evaluator by evaluating +;;;; the expression (mce). + + +;;**implementation-dependent loading of evaluator file +;;Note: It is loaded first so that the section 4.1.7 definition +;; of eval overrides the definition from 4.1.1 +(load "61a/Lib/mceval.scm") + +;;;SECTION 4.1.7 + +(define (mc-eval exp env) + ((analyze exp) env)) + +(define (analyze exp) + (cond ((self-evaluating? exp) + (analyze-self-evaluating exp)) + ((quoted? exp) (analyze-quoted exp)) + ((variable? exp) (analyze-variable exp)) + ((assignment? exp) (analyze-assignment exp)) + ((definition? exp) (analyze-definition exp)) + ((if? exp) (analyze-if exp)) + ((lambda? exp) (analyze-lambda exp)) + ((begin? exp) (analyze-sequence (begin-actions exp))) + ((cond? exp) (analyze (cond->if exp))) + ((application? exp) (analyze-application exp)) + (else + (error "Unknown expression type -- ANALYZE" exp)))) + +(define (analyze-self-evaluating exp) + (lambda (env) exp)) + +(define (analyze-quoted exp) + (let ((qval (text-of-quotation exp))) + (lambda (env) qval))) + +(define (analyze-variable exp) + (lambda (env) (lookup-variable-value exp env))) + +(define (analyze-assignment exp) + (let ((var (assignment-variable exp)) + (vproc (analyze (assignment-value exp)))) + (lambda (env) + (set-variable-value! var (vproc env) env) + 'ok))) + +(define (analyze-definition exp) + (let ((var (definition-variable exp)) + (vproc (analyze (definition-value exp)))) + (lambda (env) + (define-variable! var (vproc env) env) + 'ok))) + +(define (analyze-if exp) + (let ((pproc (analyze (if-predicate exp))) + (cproc (analyze (if-consequent exp))) + (aproc (analyze (if-alternative exp)))) + (lambda (env) + (if (true? (pproc env)) + (cproc env) + (aproc env))))) + +(define (analyze-lambda exp) + (let ((vars (lambda-parameters exp)) + (bproc (analyze-sequence (lambda-body exp)))) + (lambda (env) (make-procedure vars bproc env)))) + +(define (analyze-sequence exps) + (define (sequentially proc1 proc2) + (lambda (env) (proc1 env) (proc2 env))) + (define (loop first-proc rest-procs) + (if (null? rest-procs) + first-proc + (loop (sequentially first-proc (car rest-procs)) + (cdr rest-procs)))) + (let ((procs (map analyze exps))) + (if (null? procs) + (error "Empty sequence -- ANALYZE")) + (loop (car procs) (cdr procs)))) + +(define (analyze-application exp) + (let ((fproc (analyze (operator exp))) + (aprocs (map analyze (operands exp)))) + (lambda (env) + (execute-application (fproc env) + (map (lambda (aproc) (aproc env)) + aprocs))))) + +(define (execute-application proc args) + (cond ((primitive-procedure? proc) + (apply-primitive-procedure proc args)) + ((compound-procedure? proc) + ((procedure-body proc) + (extend-environment (procedure-parameters proc) + args + (procedure-environment proc)))) + (else + (error + "Unknown procedure type -- EXECUTE-APPLICATION" + proc)))) + +;;; Added at Berkeley: + +(define input-prompt ";;; A-Eval input:") +(define output-prompt ";;; A-Eval value:") diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/animal.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/animal.scm new file mode 100644 index 0000000..424cacc --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/animal.scm @@ -0,0 +1,66 @@ +(define (animal node) + (define (type node) (car node)) + (define (question node) (cadr node)) + (define (yespart node) (caddr node)) + (define (nopart node) (cadddr node)) + (define (answer node) (cadr node)) + (define (leaf? node) (eq? (type node) 'leaf)) + (define (branch? node) (eq? (type node) 'branch)) + (define (set-yes! node x) + (set-car! (cddr node) x)) + (define (set-no! node x) + (set-car! (cdddr node) x)) + + (define (yorn) + (let ((yn (read))) + (cond ((eq? yn 'yes) #t) + ((eq? yn 'no) #f) + (else (display "Please type YES or NO") + (yorn))))) + + (display (question node)) + (display " ") + (let ((yn (yorn)) (correct #f) (newquest #f)) + (let ((next (if yn (yespart node) (nopart node)))) + (cond ((branch? next) (animal next)) + (else (display "Is it a ") + (display (answer next)) + (display "? ") + (cond ((yorn) "I win!") + (else (newline) + (display "I give up, what is it? ") + (set! correct (read)) + (newline) + (display "Please tell me a question whose answer ") + (display "is YES for a ") + (display correct) + (newline) + (display "and NO for a ") + (display (answer next)) + (display ".") + (newline) + (display "Enclose the question in quotation marks.") + (newline) + (set! newquest (read)) + (if yn + (set-yes! node (make-branch newquest + (make-leaf correct) + next)) + (set-no! node (make-branch newquest + (make-leaf correct) + next))) + "Thanks. Now I know better."))))))) + +(define (make-branch q y n) + (list 'branch q y n)) + +(define (make-leaf a) + (list 'leaf a)) + +(define animal-list + (make-branch "Does it have wings?" + (make-leaf 'parrot) + (make-leaf 'rabbit))) + + +(define (animal-game) (animal animal-list)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/apl-meta.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/apl-meta.scm new file mode 100644 index 0000000..8147708 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/apl-meta.scm @@ -0,0 +1,260 @@ +;;; apl-meta.scm APL version of metacircular evaluator. + +;;; SETTING UP THE ENVIRONMENT + +;;; APL primitives aren't part of the environment. They are not subject +;;; to redefinition, for example. They are kept in a separate list. So +;;; the initial environment is empty. But define! only works if there is +;;; a non-empty environment, so we fake something. + +(define the-global-environment '()) + +;;; INITIALIZATION AND DRIVER LOOP + +;;; The following code initializes the machine and starts the APL +;;; system. You should not call it very often, because it will clobber +;;; the global environment, and you will lose any definitions you have +;;; accumulated. + +(define (initialize-apl) + (set! the-global-environment + (extend-environment '(no-name) '(no-value) '())) + (set! apl-operators + (list (make-scalar-op '+ (lambda (x) x) +) + (make-scalar-op '- - -) + (make-scalar-op '* + (lambda (x) (cond ((< x 0) -1) ((= x 0) 0) (else 1))) + *) + (make-scalar-op '% / /) + (make-scalar-op 'bar abs rem) + (make-scalar-op '= error (apl-pred2 =)) + (make-scalar-op '< error (apl-pred2 <)) + (make-scalar-op '> error (apl-pred2 >)) + (make-op '/ error compress) + (make-op 'iota iota error) + (make-op 'rho shape reshape) + (make-op 'comma ravel cat) + (make-op 'gets error 'set!))) + (apl-loop)) + +;;; APPLYING PRIMITIVE PROCEDURES + +;;; The mechanism for applying primitive procedures is somewhat +;;; different from the one given in the course notes. We can recognize +;;; primitive procedures (which are all inherited from Scheme) by asking +;;; Scheme if the object we have is a Scheme procedure. + +(define (primitive-procedure? p) + (applicable? p)) + +;;; To apply a primitive procedure, we ask the underlying Scheme system +;;; to perform the application. (Of course, an implementation on a +;;; low-level machine would perform the application in some other way.) + +(define (apply-primitive-procedure p args) + (apply p args)) + + +;;; Now for the code from the book!!! + + +;;; Section 4.1.1 + +(define (mini-eval exp env) + (cond ((self-evaluating? exp) exp) + ((variable? exp) (lookup-variable-value exp env)) + ((assignment? exp) (eval-assignment exp env)) + ((application? exp) + (mini-apply (mini-eval (operator exp) env) + (list-of-values (operands exp) env) + env)) + (else (error "Unknown expression type -- MINI-EVAL" exp)))) + +(define (mini-apply procedure arguments env) + (cond ((primitive-procedure? procedure) + (apply-primitive-procedure procedure arguments)) + ((compound-procedure? procedure) + (eval-sequence (procedure-body procedure) + (extend-environment + (parameters procedure) + arguments + env))) + (else + (error "Unknown procedure type -- MINI-APPLY" procedure)))) + +(define (list-of-values exps env) + (cond ((no-operands? exps) '()) + (else (cons (mini-eval (first-operand exps) env) + (list-of-values (rest-operands exps) + env))))) + +(define (eval-sequence exps env) + (cond ((last-exp? exps) (mini-eval (first-exp exps) env)) + (else (mini-eval (first-exp exps) env) + (eval-sequence (rest-exps exps) env)))) + +(define (eval-assignment exp env) + (let ((new-value (mini-eval (assignment-value exp) env))) + (set-variable-value! (assignment-variable exp) + new-value + env) + new-value)) + +;;; Section 4.1.2 -- Representing expressions + +;;; numbers + +(define (self-evaluating? exp) (number? exp)) + +;;; variables + +(define (variable? exp) (symbol? exp)) + +;;; assignment + +(define (assignment? exp) + (if (not (pair? exp)) + #f + (eq? (car exp) 'set!))) + +(define (assignment-variable exp) (cadr exp)) + +(define (assignment-value exp) (caddr exp)) + +;;; sequences + +(define (last-exp? seq) (null? (cdr seq))) + +(define (first-exp seq) (car seq)) + +(define (rest-exps seq) (cdr seq)) + +;;; procedure applications + +(define (application? exp) + (if (not (pair? exp)) + #f + (procedure? (car exp)))) + +(define (procedure? exp) + (or (applicable? exp) (compound-procedure? exp))) + +(define (operator app) (car app)) + +(define (operands app) (cdr app)) + +(define (no-operands? args) (null? args)) + +(define (first-operand args) (car args)) + +(define (rest-operands args) (cdr args)) + +;;; Representation of procedure objects + +(define (make-procedure lambda-exp env) + (list 'procedure lambda-exp env)) + +(define (compound-procedure? proc) + (if (not (pair? proc)) + #f + (eq? (car proc) 'procedure))) + +(define (parameters proc) (cadr (cadr proc))) + +(define (procedure-body proc) (cddr (cadr proc))) + +(define (procedure-environment proc) (caddr proc)) + +;;; Section 4.1.3 + +;;; Operations on environments + +(define (lookup-variable-value var env) + (if (assq var apl-operators) + var + (let ((b (binding-in-env var env))) + (if (found-binding? b) + (binding-value b) + (error "Unbound variable" var))))) + +(define (binding-in-env var env) + (if (no-more-frames? env) + no-binding + (let ((b (binding-in-frame var (first-frame env)))) + (if (found-binding? b) + b + (binding-in-env var (rest-frames env)))))) + +(define (extend-environment variables values base-env) + (adjoin-frame (make-frame variables values) base-env)) + +(define (set-variable-value! var val env) + (let ((b (binding-in-env var env))) + (if (found-binding? b) + (set-binding-value! b val) + (error "Unbound variable" var)))) + +(define (define-variable! var val env) + (let ((b (binding-in-frame var (first-frame env)))) + (if (found-binding? b) + (set-binding-value! b val) + (set-first-frame! + env + (adjoin-binding (make-binding var val) + (first-frame env)))))) + +;;; Representing environments + +(define (first-frame env) (car env)) + +(define (rest-frames env) (cdr env)) + +(define (no-more-frames? env) (null? env)) + +(define (adjoin-frame frame env) (cons frame env)) + +(define (set-first-frame! env new-frame) + (set-car! env new-frame)) + +;;; Representing frames + +(define (make-frame variables values) + (cond ((and (null? variables) (null? values)) '()) + ((null? variables) + (error "Too many values supplied" values)) + ((null? values) + (error "Too few values supplied" variables)) + (else + (cons (make-binding (car variables) (car values)) + (make-frame (cdr variables) (cdr values)))))) + +(define (adjoin-binding binding frame) + (cons binding frame)) + +(define (assq key bindings) + (cond ((null? bindings) no-binding) + ((eq? key (binding-variable (car bindings))) + (car bindings)) + (else (assq key (cdr bindings))))) + +(define (binding-in-frame var frame) + (assq var frame)) + +(define (found-binding? b) + (not (eq? b no-binding))) + +(define no-binding '()) + +;;; Representing bindings + +(define (make-binding variable value) + (cons variable value)) + +(define (binding-variable binding) + (car binding)) + +(define (binding-value binding) + (cdr binding)) + +(define (set-binding-value! binding value) + (set-cdr! binding value)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/apl.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/apl.scm new file mode 100644 index 0000000..3af4acf --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/apl.scm @@ -0,0 +1,254 @@ +;;; APL interpreter project apl.scm + +(define (----YOU-FILL-THIS-IN----) '()) ; just so file will load + +;;; Step 1: convert scalar procedures to array procedures + +(define (single x) ; reduce order of single-element list + (cond ((not (pair? x)) x) + ((null? (cdr x)) (single (car x))) + (else x))) + +(define (apl-dyadic op) ; turn dyadic scalar function into APL array fn + (define (newop x y) + (let ((xx (single x)) + (yy (single y))) + (cond ((and (number? xx) (number? yy)) + (----YOU-FILL-THIS-IN----)) + ((number? xx) (map (----YOU-FILL-THIS-IN----) yy)) + ((number? yy) (map (----YOU-FILL-THIS-IN----) xx)) + (else (map newop xx yy))))) + newop) + +;;; Step 2: APL primitive operations + +(define (iota n) ; monadic iota + (define (iter x n) + (if (> x n) + '() + (cons x (iter (1+ x) n)))) + (iter 1 (single n))) + +(define (reshape shape l) ; dyadic rho + (define (circular l) + (define (c1 pair) + (if (null? (cdr pair)) + (set-cdr! pair l) + (c1 (cdr pair)))) + (c1 l) + l) + (define token + (let ((source (circular (ravel l)))) + (lambda () + (let ((out (car source))) + (set! source (cdr source)) + out)))) + (define (string n shape) + (if (= n 0) + '() + (let ((top (re1 shape))) + (cons top (string (-1+ n) shape))))) + (define (re1 shape) + (if (null? shape) + (token) + (string (car shape) (cdr shape)))) + (re1 shape)) + +(define (cat a b) ; dyadic comma + (define (depth l) + (if (not (pair? l)) + 0 + (1+ (depth (car l))))) + (define (max x y) + (if (> x y) x y)) + (define (shapeup l dims) + (if (= dims (depth l)) + l + (shapeup (cons l '()) dims))) + (let ((dim (max (depth a) (depth b)))) + (append (shapeup a dim) (shapeup b dim)))) + +(define (ravel l) ; monadic comma + (define (r1 this rest) + (cond ((null? this) (ravel rest)) + ((not (pair? this)) (cons this (ravel rest))) + (else (r1 (car this) (cons (cdr this) rest))))) + (cond ((null? l) '()) + ((not (pair? l)) (cons l '())) + (else (r1 (car l) (cdr l))))) + +(define (abs x) ; monadic bar + (if (< x 0) (- x) x)) + +(define (rem x y) ; dyadic bar + (remainder y x)) + +;;; data abstraction for APL operators + +(define (tri-op name nil mon dy) + (list name nil mon dy)) + +(define (apl-operator? op) + (assq op apl-operators)) + +(define (niladic op) + (cadr (assq op apl-operators))) + +(define (monadic op) + (caddr (assq op apl-operators))) + +(define (dyadic op) + (cadddr (assq op apl-operators))) + +(define (make-niladic name body) + (set! apl-operators (cons (tri-op name body error error) apl-operators))) + +(define (make-monadic name body) + (set! apl-operators (cons (tri-op name error body error) apl-operators))) + +(define (make-dyadic name body) + (set! apl-operators (cons (tri-op name error error body) apl-operators))) + +(define (make-op op mon dy) ; abbreviation for primitives, never niladic + (tri-op op error mon dy)) + +(define (make-scalar-op op mon dy) + (make-op op (apl-monadic mon) (apl-dyadic dy))) + +;;; Table of operations + +(define (apl-pred2 op) ; turn Lisp predicate (t/f) into APL (0/1) + (lambda (x y) + (if (op x y) 1 0))) + +(define apl-operators + (list (make-scalar-op '+ (lambda (x) x) +) + (make-scalar-op '- - -) + (make-scalar-op '* + (lambda (x) (cond ((< x 0) -1) + ((= x 0) 0) + (else 1))) + *) + (make-scalar-op '% / /) + (make-scalar-op 'bar abs rem) + (make-scalar-op '= error (apl-pred2 =)) + (make-scalar-op '< error (apl-pred2 <)) + (make-scalar-op '> error (apl-pred2 >)) + (make-op '/ error compress) + (make-op 'iota iota error) + (make-op 'rho shape reshape) + (make-op 'comma ravel cat))) + +;;; APL higher-order operations + +(define (reduce op l) ; higher-order / + (if (null? (cdr l)) + (car l) + ((dyadic op) (car l) (reduce op (cdr l))))) + +(define (apl-hof? op) + (assq op apl-hofs)) + +(define (hof op) + (cdr (assq op apl-hofs))) + +(define apl-hofs (list (cons '/ reduce))) + +;;; Step 3: Syntax conversion, infix to prefix + +(define (get-operand l) + (cond ((null? l) '()) + ((list? (car l)) + (get-dyad (get-operand (car l)) (cdr l))) + ((number? (car l)) (get-vector l)) + ((apl-operator? (car l)) + (cond ((null? (cdr l)) (error "dangling operator" (car l))) + ((apl-hof? (cadr l)) + (list (hof (cadr l)) (car l) (get-operand (cddr l)))) + (else + (list (monadic (car l)) (get-operand (cdr l)))))) + (else (get-dyad (car l) (cdr l))))) + +(define (get-dyad left l) + (cond ((null? l) left) + ((apl-operator? (car l)) + (----YOU PUT SOMETHING HERE----)) + (else + (error "operand where operator expected" (car l))))) + +(define (get-vector l) + (define (gv vect l) + (cond ((null? l) vect) + ((number? (car l)) + (----YOU PUT SOMETHING HERE----)) + (else (get-dyad vect l)))) + (gv '() l)) + +;;; mini-evaluator + +(define (apl-loop) + (define (maybe-display val) + (if (eq? val 'no-value) '() (display val))) + (newline) + (display "APL> ") + (maybe-display (apl-eval (get-operand (read)))) + (apl-loop)) + +(define (apl-eval l) + (cond ((not (pair? l)) l) + ((procedure? (car l)) (apply (car l) (map apl-eval (cdr l)))) + (else l))) + +(define *keyboard-interrupt-handler* reset) + +;;; Step 11: Procedure definition + +(define (convert-syntax l) + (cond ((not (pair? l)) l) + ((eq? (car l) 'del) (proc-definition (cdr l)) 'no-name) + (else (get-operand l)))) + +(define (proc-definition l) + (cond ((null? (cdr l)) + (make-niladic (car l) (make-procedure '() '() '() (proc-body)))) + ((eq? (cadr l) 'gets) + (proc-result (car l) (cddr l))) + (else (----YOU-FILL-THIS-IN----)))) + +(define (proc-result outvar l) + (define (count-to-locals l) + (cond ((null? l) 0) + ((eq? (car l) ':) 0) + (else (1+ (count-to-locals (cdr l)))))) + (define (locals l) + (cond ((null? l) '()) + ((eq? (car l) ':) + (cons (cadr l) (locals (cddr l)))) + (else (error "bad format in locals" l)))) + (let ((adic (count-to-locals l))) + (cond ((= adic 1) + (make-niladic (car l) + (make-procedure outvar + '() + (locals (cdr l)) + (proc-body)))) + ((= adic 2) + (make-monadic (car l) + (make-procedure outvar + (list (cadr l)) + (locals (cddr l)) + (proc-body)))) + ((= adic 3) + (----YOU-FILL-THIS-IN----)) + (else (error "too many args in function definition" l))))) + +(define (proc-body) + (define (proc-body-loop lineno) + (display "[") + (display lineno) + (display "] ") + (let ((next (read))) + (if (eq? next 'del) + '() + (cons next (proc-body-loop (1+ lineno)))))) + (proc-body-loop 1)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/berkeley.scmm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/berkeley.scmm new file mode 100644 index 0000000..9dec781 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/berkeley.scmm @@ -0,0 +1,1918 @@ +;;; berkeley.scm 3.14 9/23/98 +;;; This version purports to work on Unix SCM, PC SCM, and Mac Gambit +;;; all without the least little version skew! + +;; 3.1 add uniform graphics interface +;; 3.2 fix scm untrace messing up butlast +;; 3.3 fix setheading in scm +;; 3.4 number->string doesn't blow up if given string (for trace) +;; 3.5 fix (/) without breaking (/ 3) +;; 3.6 fix number->string in MIT Scheme (don't set! it) +;; 3.7 big rewrite for SICP second edition changes +;; 3.8 SICP concurrency features added +;; 3.9 define-handler hacked for obscure scm bug +;; 3.10 fix scm parallel-execute to start the timer! +;; 3.11 not enough primitives protected in redefinition of define in scm +;; 3.12 stream-map with multiple streams +;; 3.13 number->string extra args +;; 3.14 protect define against redefining map + +;;; This file makes SCM 4e1 and Gambit 2.2 compatible with both +;;; Structure and Interpretation of Computer Programs (Abelson, +;;; Sussman, and Sussman) and Simply Scheme (Harvey and Wright). +;;; This should be sufficient to make Scheme fully compatible with +;;; Harvey and Wright, and compatible with SICP with the exception of +;;; first-class environments and pre-R4RS stuff like false empty lists. +;;; (It should be fully compatible with SICP second edition.) + +(if (equal? 'foo (symbol->string 'foo)) + (error "Berkeley.scm already loaded!!") + #f) + +(define scm? (not (exact? (/ 1 3)))) +;;; Notice that *after* loading this file, (/ 1 3) is never exact, +;;; so we have to check first thing. Naked Gambit has exact rationals, +;;; but naked SCM doesn't. + +;;; Let's not have any random messages please. +(if scm? + (begin + (eval '(define *dev-null* (make-soft-port (vector (lambda (x) #f) + (lambda (x) #f) + #f #f #f) + OPEN_WRITE))) + (set-current-error-port *dev-null*))) + +(define nil '()) +(define true #t) +(define false #f) + +(if scm? + (eval '(define (runtime) + (/ (get-internal-run-time) internal-time-units-per-second)))) + +;; crude timing program (time (foo..)) +(if scm? + (eval '(define time (procedure->macro + (lambda(x env) + `(let*((start (runtime)) + (result ,(cadr x)) + (end (- (runtime) start))) + (write end)(display " seconds")(newline) + result))))) + (eval '(define-macro (time . args) `(let*((start (runtime)) + (result ,(car args)) + (end (- (runtime) start))) + (write end) + (display " seconds") + (newline) + result)))) + +;; Originally from Jolly Chen. Modified by Justin Gibbs. + +(if (and scm? (eq? (software-type) 'unix)) + (begin + (eval '(define (expand-name st) + ;; given a string like "~cs60a/lib" expand it to + ;; "home/po/k/classes../cs60a/lib" + (let ((file (tmpnam)) + (res '())) + (system (string-append "/bin/csh -cf \"glob " st " > " file "\"")) + ;; Why read-line won't work here, I don't know + (let ((port (open-io-file file))) + (set! res (read-string port)) + (system (string-append "/bin/rm " file)) + (close-io-port port) + res)))) + ;;; Load. + ;;; Original Code from default SCM Init.scm. Modified by Justin Gibbs. + ;;; This load is identical to the load in Init.scm save that we use + ;;; csh to glob our file names for us. This leaves open the option + ;;; of using wild cards and "~" in the argument to load. Load does + ;;; not understand multifile arguments -- a feature that would be nice + ;;; to add later, since we already can glob on '*'s and '?'s. + (eval '(define (load file) + ;;; Only change is the addition of the following line. + (define filesuf (expand-name file)) + (define cep (current-error-port)) + (set! file filesuf) + (cond ((> (verbose) 1) + (display ";loading " cep) (write file cep) (newline cep))) + (force-output cep) + (or (try-load file) + ;;HERE is where the suffix gets specified + (begin (set! filesuf (string-append file (scheme-file-suffix))) + (try-load filesuf)) + (and (procedure? could-not-open) (could-not-open) #f) + (error "LOAD couldn't find file " file)) + (errno 0) + (cond ((> (verbose) 1) + (display ";done loading " cep) + (write filesuf cep) + (newline cep) + (force-output cep))))))) + + +;;; SICP stuff: + +(define (print x) + (display x) + (newline)) + +;; Define tagged data ADT: + +(define (attach-tag type-tag contents) + (cons type-tag contents)) + +(define (type-tag datum) + (if (pair? datum) + (car datum) + (error "Bad tagged datum -- TYPE-TAG" datum))) + +(define (contents datum) + (if (pair? datum) + (cdr datum) + (error "Bad tagged datum -- CONTENTS" datum))) + +;;For Section 3.1.2 -- written as suggested in footnote, +;; though the values of a, b, m may not be very "appropriately chosen" +(define (rand-update x) + (let ((a 27) (b 26) (m 127)) + (modulo (+ (* a x) b) m))) + +;;For Section 3.3.4, used by and-gate +;;Note: logical-and should test for valid signals, as logical-not does +(define (logical-and x y) + (if (and (= x 1) (= y 1)) + 1 + 0)) + +;; concurrency stuff + +(if scm? + (eval '(define test-and-set! + (let ((arb (make-arbiter 'scratchnsniff))) + (lambda (cell) + (if (try-arbiter arb) + (begin (process:schedule!) + (test-and-set! cell)) + (let ((result (car cell))) + (set-car! cell #t) + (release-arbiter arb) + result)))))) + (eval '(define test-and-set! + (let ((sem (make-semaphore))) + (lambda (cell) + (semaphore-wait sem) + (let ((result (car cell))) + (set-car! cell #t) + (semaphore-signal sem) + result)))))) + +(if scm? (eval '(require 'process))) + +(if scm? + (eval '(define (parallel-execute . thunks) + (for-each (lambda (thunk) (add-process! (lambda (foo) (thunk)))) + thunks) + (alarm-interrupt) + (process:schedule!))) + (eval '(define (parallel-execute . thunks) + (for-each (lambda (thunk) (future (thunk))) thunks)))) + +(if scm? + (eval '(define (stop) (alarm 0) (set! process:queue (make-queue))))) + +;;For Section 3.5.2, to check power series (exercises 3.59-3.62) +;;Evaluate and accumulate n terms of the series s at the given x +;;Uses horner-eval from ex 2.34 +(define (eval-power-series s x n) + (horner-eval x (first-n-of-series s n))) +(define (first-n-of-series s n) + (if (= n 0) + '() + (cons (stream-car s) (first-n-of-series (stream-cdr s) (- n 1))))) + +;; Streams: + +;; Reimplement delay so that promises are procedures + +(define (memo-proc proc) + (let ((already-run? #f) (result #f)) + (lambda () + (if (not already-run?) + (begin (set! result (proc)) + (set! already-run? #t) + result) + result)))) + +(if scm? + (eval '(define delay (procedure->macro + (lambda (x env) + `(memo-proc (lambda () ,(cadr x))))))) + (eval '(define-macro (delay . args) + `(memo-proc (lambda () ,(car args)))))) + +(define (force delayed-object) + (delayed-object)) + +(if scm? + (eval '(define cons-stream + (procedure->macro + (lambda(x env)`(cons ,(cadr x) (delay ,(caddr x))))))) + (eval '(define-macro (cons-stream . args) + `(cons ,(car args) (delay ,(cadr args)))))) + +(define (stream-car stream) (car stream)) + +(define (stream-cdr st) + (force (cdr st))) + +(define the-empty-stream '()) + +(define (stream-null? stream) (eq? stream the-empty-stream)) + +(define (stream? obj) + (or (stream-null? obj) + (and (pair? obj) (procedure? (cdr obj))))) + +(define (stream-accumulate combiner initial-value stream) + (if (stream-null? stream) + initial-value + (combiner (stream-car stream) + (stream-accumulate combiner + initial-value + (stream-cdr stream))))) + +(define (accumulate-delayed combiner initial-value stream) + (if (stream-null? stream) + initial-value + (combiner (stream-car stream) + (delay + (accumulate-delayed combiner + initial-value + (stream-cdr stream)))))) + +(define (interleave s1 s2) + (if (stream-null? s1) + s2 + (cons-stream (stream-car s1) + (interleave s2 (stream-cdr s1))))) + +(define (interleave-delayed s1 delayed-s2) + (if (stream-null? s1) + (force delayed-s2) + (cons-stream (stream-car s1) + (interleave-delayed (force delayed-s2) + (delay (stream-cdr s1)))))) + +(define (stream-flatten stream) + (accumulate-delayed interleave-delayed + the-empty-stream + stream)) + +(define (stream-ref s n) + (if (= n 0) + (stream-car s) + (stream-ref (stream-cdr s) (- n 1)))) + +(define (stream-map proc . s) + (if (stream-null? (car s)) + the-empty-stream + (cons-stream (apply proc (map stream-car s)) + (apply stream-map proc (map stream-cdr s))))) + +(define (stream-for-each proc s) + (if (stream-null? s) + 'done + (begin + (proc (stream-car s)) + (stream-for-each proc (stream-cdr s))))) + +(define (display-stream s) + (stream-for-each + (lambda (element) (newline) (display element)) + s)) + +(define (stream-flatmap f s) + (stream-flatten (stream-map f s))) + +(define (stream-append s1 s2) + (if (stream-null? s1) + s2 + (cons-stream (stream-car s1) + (stream-append (stream-cdr s1) s2)))) + +(define (list->stream l) + (if (null? l) + the-empty-stream + (cons-stream (car l) (list->stream (cdr l))) )) + +(define (make-stream . elements) + (list->stream elements)) + +(define (enumerate-interval low high) + (if (> low high) + '() + (cons low (enumerate-interval (+ low 1) high)))) + +(define (flatmap proc seq) + (accumulate append '() (map proc seq))) + +(define (stream-enumerate-interval low high) + (if (> low high) + the-empty-stream + (cons-stream low (stream-enumerate-interval (+ low 1) high)))) + +(define range stream-enumerate-interval) + +(define (stream-filter pred stream) + (cond ((stream-null? stream) the-empty-stream) + ((pred (stream-car stream)) + (cons-stream (stream-car stream) + (stream-filter pred (stream-cdr stream)))) + (else (stream-filter pred (stream-cdr stream))))) + +(define (show-stream strm . args) + (if (null? args) + (ss1 strm 10 10) + (ss1 strm (car args) (car args)))) + +(define ss show-stream) + +(define (ss1 strm this all) + (cond ((null? strm) '()) + ((= this 0) '(...)) + ((and (pair? strm) (procedure? (cdr strm))) + (cons (ss1 (stream-car strm) all all) + (ss1 (stream-cdr strm) (- this 1) all))) + (else strm))) + +(define div quotient) + +(define / + (let ((old/ /)) + (lambda args + (let ((quo (apply old/ args))) + (if (integer? quo) + quo + (exact->inexact quo)))))) + +(define 1+ + (let ((+ +)) + (lambda (x) (+ x 1)))) + +(define (-1+ x) (- x 1)) + +(define (nth n l) (list-ref l n)) + +(define (load-noisily file-name) + (define (iter port) + (let ((the-expression (read port))) + (cond ((eof-object? the-expression) #t) + (else + (display (eval the-expression)) + (newline) + (iter port))))) + (let ((port (open-input-file file-name))) + (iter port) + (close-input-port port) + 'ok)) + + +;;; Get and put for section 2.3 + +(define (get key1 key2) + (let ((subtable (assoc key1 (cdr the-get/put-table)))) + (if (not subtable) + #f + (let ((record (assoc key2 (cdr subtable)))) + (if (not record) + #f + (cdr record)))))) + +(define (put key1 key2 value) + (let ((subtable (assoc key1 (cdr the-get/put-table)))) + (if (not subtable) + (set-cdr! the-get/put-table + (cons (list key1 + (cons key2 value)) + (cdr the-get/put-table))) + (let ((record (assoc key2 (cdr subtable)))) + (if (not record) + (set-cdr! subtable + (cons (cons key2 value) + (cdr subtable))) + (set-cdr! record value))))) + 'ok) + +(define the-get/put-table (list '*table*)) + + +;;; simply.scm version 3.6 (4/13/94) + +;;; This file uses Scheme features we don't talk about in _Simply_Scheme_. +;;; Read at your own risk. + +;; Make number->string remove leading "+" if necessary + +(if (char=? #\+ (string-ref (number->string 1.0) 0)) + (let ((old-ns number->string) + (char=? char=?) + (string-ref string-ref) + (substring substring) + (string-length string-length)) + (set! number->string + (lambda args + (let ((result (apply old-ns args))) + (if (char=? #\+ (string-ref result 0)) + (substring result 1 (string-length result)) + result))))) + 'no-problem) + +(define number->string + (let ((old-ns number->string) + (string? string?)) + (lambda args + (if (string? (car args)) + (car args) + (apply old-ns args))))) + +;; Get strings in error messages to print nicely (especially "") + +(define whoops + (let ((string? string?) + (string-append string-append) + (error error) + (cons cons) + (map map) + (apply apply)) + (define (error-printform x) + (if (string? x) + (string-append "\"" x "\"") + x)) + (lambda (string . args) + (apply error (cons string (map error-printform args)))))) + + +;; ROUND returns an inexact integer if its argument is inexact, +;; but we think it should always return an exact integer. +;; (It matters because some Schemes print inexact integers as "+1.0".) +;; The (exact 1) test is for PC Scheme, in which nothing is exact. +(if (and (inexact? (round (sqrt 2))) (exact? 1)) + (let ((old-round round) + (inexact->exact inexact->exact)) + (set! round + (lambda (number) + (inexact->exact (old-round number))))) + 'no-problem) + +;; Remainder and quotient blow up if their argument isn't an integer. +;; Unfortunately, in SCM, (* 365.25 24 60 60) *isn't* an integer. + +(if (inexact? (* .25 4)) + (let ((rem remainder) + (quo quotient) + (inexact->exact inexact->exact) + (integer? integer?)) + (set! remainder + (lambda (x y) + (rem (if (integer? x) (inexact->exact x) x) + (if (integer? y) (inexact->exact y) y)))) + (set! quotient + (lambda (x y) + (quo (if (integer? x) (inexact->exact x) x) + (if (integer? y) (inexact->exact y) y))))) + 'done) + + +;; Random +;; If your version of Scheme has RANDOM, you should take this out. +;; (It gives the same sequence of random numbers every time.) + +(define random + (let ((*seed* 1) (quotient quotient) (modulo modulo) (+ +) (- -) (* *) (> >)) + (lambda (x) + (let* ((hi (quotient *seed* 127773)) + (low (modulo *seed* 127773)) + (test (- (* 16807 low) (* 2836 hi)))) + (if (> test 0) + (set! *seed* test) + (set! *seed* (+ test 2147483647)))) + (modulo *seed* x)))) + + +;;; Logo-style word/sentence implementation + +(define word? + (let ((number? number?) + (symbol? symbol?) + (string? string?)) + (lambda (x) + (or (symbol? x) (number? x) (string? x))))) + +(define sentence? + (let ((null? null?) + (pair? pair?) + (word? word?) + (car car) + (cdr cdr)) + (define (list-of-words? l) + (cond ((null? l) #t) + ((pair? l) + (and (word? (car l)) (list-of-words? (cdr l)))) + (else #f))) + list-of-words?)) + +(define empty? + (let ((null? null?) + (string? string?) + (string=? string=?)) + (lambda (x) + (or (null? x) + (and (string? x) (string=? x "")))))) + + +(define char-rank + ;; 0 Letter in good case or special initial + ;; 1 ., + or - + ;; 2 Digit + ;; 3 Letter in bad case or weird character + (let ((*the-char-ranks* (make-vector 256 3)) + (= =) + (+ +) + (string-ref string-ref) + (string-length string-length) + (vector-set! vector-set!) + (char->integer char->integer) + (symbol->string symbol->string) + (vector-ref vector-ref)) + (define (rank-string str rank) + (define (helper i len) + (if (= i len) + 'done + (begin (vector-set! *the-char-ranks* + (char->integer (string-ref str i)) + rank) + (helper (+ i 1) len)))) + (helper 0 (string-length str))) + (rank-string (symbol->string 'abcdefghijklmnopqrstuvwxyz) 0) + (rank-string "!$%&*/:<=>?~_^" 0) + (rank-string "+-." 1) + (rank-string "0123456789" 2) + (lambda (char) ;; value of char-rank + (vector-ref *the-char-ranks* (char->integer char))))) + +(define string->word + (let ((= =) (<= <=) (+ +) (- -) + (char-rank char-rank) + (string-ref string-ref) + (string-length string-length) + (string=? string=?) + (not not) + (char=? char=?) + (string->number string->number) + (string->symbol string->symbol)) + (lambda (string) + (define (subsequents? string i length) + (cond ((= i length) #t) + ((<= (char-rank (string-ref string i)) 2) + (subsequents? string (+ i 1) length)) + (else #f))) + (define (special-id? string) + (or (string=? string "+") + (string=? string "-") + (string=? string "..."))) + (define (ok-symbol? string) + (if (string=? string "") + #f + (let ((rank1 (char-rank (string-ref string 0)))) + (cond ((= rank1 0) (subsequents? string 1 (string-length string))) + ((= rank1 1) (special-id? string)) + (else #f))))) + (define (nn-helper string i len seen-point?) + (cond ((= i len) + (if seen-point? + (not (char=? (string-ref string (- len 1)) #\0)) + #t)) + ((char=? #\. (string-ref string i)) + (cond (seen-point? #f) + ((= (+ i 2) len) #t) ; Accepts "23.0" + (else (nn-helper string (+ i 1) len #t)))) + ((= 2 (char-rank (string-ref string i))) + (nn-helper string (+ i 1) len seen-point?)) + (else #f))) + (define (narrow-number? string) + (if (string=? string "") + #f + (let* ((c0 (string-ref string 0)) + (start 0) + (len (string-length string)) + (cn (string-ref string (- len 1)))) + (if (and (char=? c0 #\-) (not (= len 1))) + (begin + (set! start 1) + (set! c0 (string-ref string 1))) + #f) + (cond ((not (= (char-rank cn) 2)) #f) ; Rejects "-" among others + ((char=? c0 #\.) #f) + ((char=? c0 #\0) + (cond ((= len 1) #t) ; Accepts "0" but not "-0" + ((= len 2) #f) ; Rejects "-0" and "03" + ((char=? (string-ref string (+ start 1)) #\.) + (nn-helper string (+ start 2) len #t)) + (else #f))) + (else (nn-helper string start len #f)))))) + + ;; The body of string->word: + (cond ((narrow-number? string) (string->number string)) + ((ok-symbol? string) (string->symbol string)) + (else string))))) + +(define char->word + (let ((= =) + (char-rank char-rank) + (make-string make-string) + (string->symbol string->symbol) + (string->number string->number) + (char=? char=?)) + (lambda (char) + (let ((rank (char-rank char)) + (string (make-string 1 char))) + (cond ((= rank 0) (string->symbol string)) + ((= rank 2) (string->number string)) + ((char=? char #\+) '+) + ((char=? char #\-) '-) + (else string)))))) + +(define word->string + (let ((number? number?) + (string? string?) + (number->string number->string) + (symbol->string symbol->string)) + (lambda (wd) + (cond ((string? wd) wd) + ((number? wd) (number->string wd)) + (else (symbol->string wd)))))) + +(define count + (let ((word? word?) + (string-length string-length) + (word->string word->string) + (length length)) + (lambda (stuff) + (if (word? stuff) + (string-length (word->string stuff)) + (length stuff))))) + +(define word + (let ((string->word string->word) + (apply apply) + (string-append string-append) + (map map) + (word? word?) + (word->string word->string) + (whoops whoops)) + (lambda x + (string->word + (apply string-append + (map (lambda (arg) + (if (word? arg) + (word->string arg) + (whoops "Invalid argument to WORD: " arg))) + x)))))) + +(define se + (let ((pair? pair?) + (null? null?) + (word? word?) + (car car) + (cons cons) + (cdr cdr) + (whoops whoops)) + (define (paranoid-append a original-a b) + (cond ((null? a) b) + ((word? (car a)) + (cons (car a) (paranoid-append (cdr a) original-a b))) + (else (whoops "Argument to SENTENCE not a word or sentence" + original-a )))) + (define (combine-two a b) ;; Note: b is always a list + (cond ((pair? a) (paranoid-append a a b)) + ((null? a) b) + ((word? a) (cons a b)) + (else (whoops "Argument to SENTENCE not a word or sentence:" a)))) + ;; Helper function so recursive calls don't show up in TRACE + (define (real-se args) + (if (null? args) + '() + (combine-two (car args) (real-se (cdr args))))) + (lambda args + (real-se args)))) + +(define sentence se) + +(define first + (let ((pair? pair?) + (char->word char->word) + (string-ref string-ref) + (word->string word->string) + (car car) + (empty? empty?) + (whoops whoops) + (word? word?)) + (define (word-first wd) + (char->word (string-ref (word->string wd) 0))) + (lambda (x) + (cond ((pair? x) (car x)) + ((empty? x) (whoops "Invalid argument to FIRST: " x)) + ((word? x) (word-first x)) + (else (whoops "Invalid argument to FIRST: " x)))))) + +(define last + (let ((pair? pair?) + (- -) + (word->string word->string) + (char->word char->word) + (string-ref string-ref) + (string-length string-length) + (empty? empty?) + (cdr cdr) + (car car) + (whoops whoops) + (word? word?)) + (define (word-last wd) + (let ((s (word->string wd))) + (char->word (string-ref s (- (string-length s) 1))))) + (define (list-last lst) + (if (empty? (cdr lst)) + (car lst) + (list-last (cdr lst)))) + (lambda (x) + (cond ((pair? x) (list-last x)) + ((empty? x) (whoops "Invalid argument to LAST: " x)) + ((word? x) (word-last x)) + (else (whoops "Invalid argument to LAST: " x)))))) + +(define bf + (let ((pair? pair?) + (substring substring) + (string-length string-length) + (string->word string->word) + (word->string word->string) + (cdr cdr) + (empty? empty?) + (whoops whoops) + (word? word?)) + (define string-bf + (lambda (s) + (substring s 1 (string-length s)))) + (define (word-bf wd) + (string->word (string-bf (word->string wd)))) + (lambda (x) + (cond ((pair? x) (cdr x)) + ((empty? x) (whoops "Invalid argument to BUTFIRST: " x)) + ((word? x) (word-bf x)) + (else (whoops "Invalid argument to BUTFIRST: " x)))))) + +(define butfirst bf) + +(define bl + (let ((pair? pair?) (- -) + (cdr cdr) + (cons cons) + (car car) + (substring substring) + (string-length string-length) + (string->word string->word) + (word->string word->string) + (empty? empty?) + (whoops whoops) + (word? word?)) + (define (list-bl list) + (if (null? (cdr list)) + '() + (cons (car list) (list-bl (cdr list))))) + (define (string-bl s) + (substring s 0 (- (string-length s) 1))) + (define (word-bl wd) + (string->word (string-bl (word->string wd)))) + (lambda (x) + (cond ((pair? x) (list-bl x)) + ((empty? x) (whoops "Invalid argument to BUTLAST: " x)) + ((word? x) (word-bl x)) + (else (whoops "Invalid argument to BUTLAST: " x)))))) + +(define butlast bl) + +(define item + (let ((> >) (- -) (< <) (integer? integer?) (list-ref list-ref) + (char->word char->word) + (string-ref string-ref) + (word->string word->string) + (not not) + (whoops whoops) + (count count) + (word? word?) + (list? list?)) + (define (word-item n wd) + (char->word (string-ref (word->string wd) (- n 1)))) + (lambda (n stuff) + (cond ((not (integer? n)) + (whoops "Invalid first argument to ITEM (must be an integer): " + n)) + ((< n 1) + (whoops "Invalid first argument to ITEM (must be positive): " + n)) + ((> n (count stuff)) + (whoops "No such item: " n stuff)) + ((word? stuff) (word-item n stuff)) + ((list? stuff) (list-ref stuff (- n 1))) + (else (whoops "Invalid second argument to ITEM: " stuff)))))) + +(define equal? + ;; Note that EQUAL? assumes strings are numbers. + ;; (strings-are-numbers #f) doesn't change this behavior. + (let ((vector-length vector-length) + (= =) + (vector-ref vector-ref) + (+ +) + (string? string?) + (symbol? symbol?) + (null? null?) + (pair? pair?) + (car car) + (cdr cdr) + (eq? eq?) + (string=? string=?) + (symbol->string symbol->string) + (number? number?) + (string->word string->word) + (vector? vector?) + (eqv? eqv?)) + (define (vector-equal? v1 v2) + (let ((len1 (vector-length v1)) + (len2 (vector-length v2))) + (define (helper i) + (if (= i len1) + #t + (and (equal? (vector-ref v1 i) (vector-ref v2 i)) + (helper (+ i 1))))) + (if (= len1 len2) + (helper 0) + #f))) + (lambda (x y) + (cond ((null? x) (null? y)) + ((null? y) #f) + ((pair? x) + (and (pair? y) + (equal? (car x) (car y)) + (equal? (cdr x) (cdr y)))) + ((pair? y) #f) + ((symbol? x) + (or (and (symbol? y) (eq? x y)) + (and (string? y) (string=? (symbol->string x) y)))) + ((symbol? y) + (and (string? x) (string=? x (symbol->string y)))) + ((number? x) + (or (and (number? y) (= x y)) + (and (string? y) + (let ((possible-num (string->word y))) + (and (number? possible-num) + (= x possible-num)))))) + ((number? y) + (and (string? x) + (let ((possible-num (string->word x))) + (and (number? possible-num) + (= possible-num y))))) + ((string? x) (and (string? y) (string=? x y))) + ((string? y) #f) + ((vector? x) (and (vector? y) (vector-equal? x y))) + ((vector? y) #f) + (else (eqv? x y)))))) + +(define member? + (let ((> >) (- -) (< <) + (null? null?) + (symbol? symbol?) + (eq? eq?) + (car car) + (not not) + (symbol->string symbol->string) + (string=? string=?) + (cdr cdr) + (equal? equal?) + (word->string word->string) + (string-length string-length) + (whoops whoops) + (string-ref string-ref) + (char=? char=?) + (list? list?) + (number? number?) + (empty? empty?) + (word? word?) + (string? string?)) + (define (symbol-in-list? symbol string lst) + (cond ((null? lst) #f) + ((and (symbol? (car lst)) + (eq? symbol (car lst)))) + ((string? (car lst)) + (cond ((not string) + (symbol-in-list? symbol (symbol->string symbol) lst)) + ((string=? string (car lst)) #t) + (else (symbol-in-list? symbol string (cdr lst))))) + (else (symbol-in-list? symbol string (cdr lst))))) + (define (word-in-list? wd lst) + (cond ((null? lst) #f) + ((equal? wd (car lst)) #t) + (else (word-in-list? wd (cdr lst))))) + (define (word-in-word? small big) + (let ((one-letter-str (word->string small))) + (if (> (string-length one-letter-str) 1) + (whoops "Invalid arguments to MEMBER?: " small big) + (let ((big-str (word->string big))) + (char-in-string? (string-ref one-letter-str 0) + big-str + (- (string-length big-str) 1)))))) + (define (char-in-string? char string i) + (cond ((< i 0) #f) + ((char=? char (string-ref string i)) #t) + (else (char-in-string? char string (- i 1))))) + (lambda (x stuff) + (cond ((empty? stuff) #f) + ((word? stuff) (word-in-word? x stuff)) + ((not (list? stuff)) + (whoops "Invalid second argument to MEMBER?: " stuff)) + ((symbol? x) (symbol-in-list? x #f stuff)) + ((or (number? x) (string? x)) + (word-in-list? x stuff)) + (else (whoops "Invalid first argument to MEMBER?: " x)))))) + +(define before? + (let ((not not) + (word? word?) + (whoops whoops) + (string<? string<?) + (word->string word->string)) + (lambda (wd1 wd2) + (cond ((not (word? wd1)) + (whoops "Invalid first argument to BEFORE? (not a word): " wd1)) + ((not (word? wd2)) + (whoops "Invalid second argument to BEFORE? (not a word): " wd2)) + (else (string<? (word->string wd1) (word->string wd2))))))) + + +;;; Higher Order Functions + +(define filter + (let ((null? null?) + (car car) + (cons cons) + (cdr cdr) + (not not) + (procedure? procedure?) + (whoops whoops) + (list? list?)) + (lambda (pred l) + ;; Helper function so recursive calls don't show up in TRACE + (define (real-filter l) + (cond ((null? l) '()) + ((pred (car l)) + (cons (car l) (real-filter (cdr l)))) + (else (real-filter (cdr l))))) + (cond ((not (procedure? pred)) + (whoops "Invalid first argument to FILTER (not a procedure): " + pred)) + ((not (list? l)) + (whoops "Invalid second argument to FILTER (not a list): " l)) + (else (real-filter l)))))) + +(define keep + (let ((+ +) (= =) (pair? pair?) + (substring substring) + (char->word char->word) + (string-ref string-ref) + (string-set! string-set!) + (word->string word->string) + (string-length string-length) + (string->word string->word) + (make-string make-string) + (procedure? procedure?) + (whoops whoops) + (word? word?) + (null? null?)) + (lambda (pred w-or-s) + (define (keep-string in i out out-len len) + (cond ((= i len) (substring out 0 out-len)) + ((pred (char->word (string-ref in i))) + (string-set! out out-len (string-ref in i)) + (keep-string in (+ i 1) out (+ out-len 1) len)) + (else (keep-string in (+ i 1) out out-len len)))) + (define (keep-word wd) + (let* ((string (word->string wd)) + (len (string-length string))) + (string->word + (keep-string string 0 (make-string len) 0 len)))) + (cond ((not (procedure? pred)) + (whoops "Invalid first argument to KEEP (not a procedure): " + pred)) + ((pair? w-or-s) (filter pred w-or-s)) + ((word? w-or-s) (keep-word w-or-s)) + ((null? w-or-s) '()) + (else + (whoops "Bad second argument to KEEP (not a word or sentence): " + w-or-s)))))) + +(define appearances + (let ((count count) + (keep keep) + (equal? equal?)) + (lambda (item aggregate) + (count (keep (lambda (element) (equal? item element)) aggregate))))) + +(define every + (let ((= =) (+ +) + (se se) + (char->word char->word) + (string-ref string-ref) + (empty? empty?) + (first first) + (bf bf) + (not not) + (procedure? procedure?) + (whoops whoops) + (word? word?) + (word->string word->string) + (string-length string-length)) + (lambda (fn stuff) + (define (string-every string i length) + (if (= i length) + '() + (se (fn (char->word (string-ref string i))) + (string-every string (+ i 1) length)))) + (define (sent-every sent) + ;; This proc. can't be optimized or else it will break the + ;; exercise where we ask them to reimplement sentences as + ;; vectors and then see if every still works. + (if (empty? sent) + sent ; Can't be '() or exercise breaks. + (se (fn (first sent)) + (sent-every (bf sent))))) + (cond ((not (procedure? fn)) + (whoops "Invalid first argument to EVERY (not a procedure):" + fn)) + ((word? stuff) + (let ((string (word->string stuff))) + (string-every string 0 (string-length string)))) + (else (sent-every stuff)))))) + +;; In _Simply Scheme_, accumulate works on words and sentences, and takes +;; two arguments. In SICP, accumulate works on lists, and takes three +;; arguments. This version does both. Sorry. + +(define accumulate + (let ((not not) + (empty? empty?) + (bf bf) + (first first) + (procedure? procedure?) + (whoops whoops) + (member member) + (list list)) + (lambda (combiner stuff . extra) + (define (real-accumulate stuff) + (if (empty? (bf stuff)) + (first stuff) + (combiner (first stuff) (real-accumulate (bf stuff))))) + (define (sicp-accumulate initial stuff) + (if (null? stuff) + initial + (combiner (car stuff) (sicp-accumulate initial (cdr stuff))))) + (cond ((not (procedure? combiner)) + (whoops "Invalid first argument to ACCUMULATE (not a procedure):" + combiner)) + ((null? extra) ; Simply Scheme version + (cond ((not (empty? stuff)) (real-accumulate stuff)) + ((member combiner (list + * word se)) (combiner)) + (else + (whoops "Can't accumulate empty input with that combiner")))) + ((not (null? (cdr extra))) + (whoops "Too many arguments to accumulate")) + (else (sicp-accumulate stuff (car extra))))))) + +(define reduce + (let ((null? null?) + (cdr cdr) + (car car) + (not not) + (procedure? procedure?) + (whoops whoops) + (member member) + (list list)) + (lambda (combiner stuff) + (define (real-reduce stuff) + (if (null? (cdr stuff)) + (car stuff) + (combiner (car stuff) (real-reduce (cdr stuff))))) + (cond ((not (procedure? combiner)) + (whoops "Invalid first argument to REDUCE (not a procedure):" + combiner)) + ((not (null? stuff)) (real-reduce stuff)) + ((member combiner (list + * word se append)) (combiner)) + (else (whoops "Can't reduce empty input with that combiner")))))) + +(define repeated + (let ((= =) (- -)) + (lambda (fn number) + (if (= number 0) + (lambda (x) x) + (lambda (x) + ((repeated fn (- number 1)) (fn x))))))) + + +;; Tree stuff +(define make-node cons) +(define datum car) +(define children cdr) + + +;; I/O + +(define show + (let ((= =) + (length length) + (display display) + (car car) + (newline newline) + (not not) + (output-port? output-port?) + (apply apply) + (whoops whoops)) + (lambda args + (cond + ((= (length args) 1) + (display (car args)) + (newline)) + ((= (length args) 2) + (if (not (output-port? (car (cdr args)))) + (whoops "Invalid second argument to SHOW (not an output port): " + (car (cdr args)))) + (apply display args) + (newline (car (cdr args)))) + (else (whoops "Incorrect number of arguments to procedure SHOW")))))) + +(define show-line + (let ((>= >=) + (length length) + (whoops whoops) + (null? null?) + (current-output-port current-output-port) + (car car) + (not not) + (list? list?) + (display display) + (for-each for-each) + (cdr cdr) + (newline newline)) + (lambda (line . args) + (if (>= (length args) 2) + (whoops "Too many arguments to show-line") + (let ((port (if (null? args) (current-output-port) (car args)))) + (cond ((not (list? line)) + (whoops "Invalid argument to SHOW-LINE (not a list):" line)) + ((null? line) #f) + (else + (display (car line) port) + (for-each (lambda (wd) (display " " port) (display wd port)) + (cdr line)))) + (newline port)))))) + +(define read-string + (let ((read-char read-char) + (eqv? eqv?) + (apply apply) + (string-append string-append) + (substring substring) + (reverse reverse) + (cons cons) + (>= >=) (+ +) + (string-set! string-set!) + (length length) + (whoops whoops) + (null? null?) + (current-input-port current-input-port) + (car car) + (cdr cdr) + (eof-object? eof-object?) + (list list) + (make-string make-string) + (peek-char peek-char)) + (define (read-string-helper chars all-length chunk-length port) + (let ((char (read-char port)) + (string (car chars))) + (cond ((or (eof-object? char) (eqv? char #\newline)) + (apply string-append + (reverse + (cons + (substring (car chars) 0 chunk-length) + (cdr chars))))) + ((>= chunk-length 80) + (let ((newstring (make-string 80))) + (string-set! newstring 0 char) + (read-string-helper (cons newstring chars) + (+ all-length 1) + 1 + port))) + (else + (string-set! string chunk-length char) + (read-string-helper chars + (+ all-length 1) + (+ chunk-length 1) + port))))) + (lambda args + (if (>= (length args) 2) + (whoops "Too many arguments to read-string") + (let ((port (if (null? args) (current-input-port) (car args)))) + (if (eof-object? (peek-char port)) + (read-char port) + (read-string-helper (list (make-string 80)) 0 0 port))))))) + +(define read-line + (let ((= =) + (list list) + (string->word string->word) + (substring substring) + (char-whitespace? char-whitespace?) + (string-ref string-ref) + (+ +) + (string-length string-length) + (apply apply) + (read-string read-string)) + (lambda args + (define (tokenize string) + (define (helper i start len) + (cond ((= i len) + (if (= i start) + '() + (list (string->word (substring string start i))))) + ((char-whitespace? (string-ref string i)) + (if (= i start) + (helper (+ i 1) (+ i 1) len) + (cons (string->word (substring string start i)) + (helper (+ i 1) (+ i 1) len)))) + (else (helper (+ i 1) start len)))) + (if (eof-object? string) + string + (helper 0 0 (string-length string)))) + (tokenize (apply read-string args))))) + +(define *the-open-inports* '()) +(define *the-open-outports* '()) + +(define align + (let ((< <) (abs abs) (* *) (expt expt) (>= >=) (- -) (+ +) (= =) + (null? null?) + (car car) + (round round) + (number->string number->string) + (string-length string-length) + (string-append string-append) + (make-string make-string) + (substring substring) + (string-set! string-set!) + (number? number?) + (word->string word->string)) + (lambda (obj width . rest) + (define (align-number obj width rest) + (let* ((sign (< obj 0)) + (num (abs obj)) + (prec (if (null? rest) 0 (car rest))) + (big (round (* num (expt 10 prec)))) + (cvt0 (number->string big)) + (cvt (if (< num 1) (string-append "0" cvt0) cvt0)) + (pos-str (if (>= (string-length cvt0) prec) + cvt + (string-append + (make-string (- prec (string-length cvt0)) #\0) + cvt))) + (string (if sign (string-append "-" pos-str) pos-str)) + (length (+ (string-length string) + (if (= prec 0) 0 1))) + (left (- length (+ 1 prec))) + (result (if (= prec 0) + string + (string-append + (substring string 0 left) + "." + (substring string left (- length 1)))))) + (cond ((= length width) result) + ((< length width) + (string-append (make-string (- width length) #\space) result)) + (else (let ((new (substring result 0 width))) + (string-set! new (- width 1) #\+) + new))))) + (define (align-word string) + (let ((length (string-length string))) + (cond ((= length width) string) + ((< length width) + (string-append string (make-string (- width length) #\space))) + (else (let ((new (substring string 0 width))) + (string-set! new (- width 1) #\+) + new))))) + (if (number? obj) + (align-number obj width rest) + (align-word (word->string obj)))))) + +(define open-output-file + (let ((oof open-output-file) + (cons cons)) + (lambda (filename) + (let ((port (oof filename))) + (set! *the-open-outports* (cons port *the-open-outports*)) + port)))) + +(define open-input-file + (let ((oif open-input-file) + (cons cons)) + (lambda (filename) + (let ((port (oif filename))) + (set! *the-open-inports* (cons port *the-open-inports*)) + port)))) + +(define remove! + (let ((null? null?) + (cdr cdr) + (eq? eq?) + (set-cdr! set-cdr!) + (car car)) + (lambda (thing lst) + (define (r! prev) + (cond ((null? (cdr prev)) lst) + ((eq? thing (car (cdr prev))) + (set-cdr! prev (cdr (cdr prev))) + lst) + (else (r! (cdr prev))))) + (cond ((null? lst) lst) + ((eq? thing (car lst)) (cdr lst)) + (else (r! lst)))))) + +(define close-input-port + (let ((cip close-input-port) + (remove! remove!)) + (lambda (port) + (set! *the-open-inports* (remove! port *the-open-inports*)) + (cip port)))) + +(define close-output-port + (let ((cop close-output-port) + (remove! remove!)) + (lambda (port) + (set! *the-open-outports* (remove! port *the-open-outports*)) + (cop port)))) + +(define close-all-ports + (let ((for-each for-each) + (close-input-port close-input-port) + (close-output-port close-output-port)) + (lambda () + (for-each close-input-port *the-open-inports*) + (for-each close-output-port *the-open-outports*) + 'closed))) + +;; Make arithmetic work on numbers in string form: +(define maybe-num + (let ((string? string?) + (string->number string->number)) + (lambda (arg) + (if (string? arg) + (let ((num (string->number arg))) + (if num num arg)) + arg)))) + +(define logoize + (let ((apply apply) + (map map) + (maybe-num maybe-num)) + (lambda (fn) + (lambda args + (apply fn (map maybe-num args)))))) + +;; special case versions of logoize, since (lambda args ...) is expensive +(define logoize-1 + (let ((maybe-num maybe-num)) + (lambda (fn) + (lambda (x) (fn (maybe-num x)))))) + +(define logoize-2 + (let ((maybe-num maybe-num)) + (lambda (fn) + (lambda (x y) (fn (maybe-num x) (maybe-num y)))))) + +(define strings-are-numbers + (let ((are-they? #f) + (real-* *) + (real-+ +) + (real-- -) + (real-/ /) + (real-< <) + (real-<= <=) + (real-= =) + (real-> >) + (real->= >=) + (real-abs abs) + (real-acos acos) + (real-asin asin) + (real-atan atan) + (real-ceiling ceiling) + (real-cos cos) + (real-even? even?) + (real-exp exp) + (real-expt expt) + (real-floor floor) + (real-align align) + (real-gcd gcd) + (real-integer? integer?) + (real-item item) + (real-lcm lcm) + (real-list-ref list-ref) + (real-log log) + (real-make-vector make-vector) + (real-max max) + (real-min min) + (real-modulo modulo) + (real-negative? negative?) + (real-number? number?) + (real-odd? odd?) + (real-positive? positive?) + (real-quotient quotient) + (real-random random) + (real-remainder remainder) + (real-repeated repeated) + (real-round round) + (real-sin sin) + (real-sqrt sqrt) + (real-tan tan) + (real-truncate truncate) + (real-vector-ref vector-ref) + (real-vector-set! vector-set!) + (real-zero? zero?) + (maybe-num maybe-num) + (number->string number->string) + (cons cons) + (car car) + (cdr cdr) + (eq? eq?) + (show show) + (logoize logoize) + (logoize-1 logoize-1) + (logoize-2 logoize-2) + (not not) + (whoops whoops)) + + (lambda (yesno) + (cond ((and are-they? (eq? yesno #t)) + (show "Strings are already numbers")) + ((eq? yesno #t) + (set! are-they? #t) + (set! * (logoize real-*)) + (set! + (logoize real-+)) + (set! - (logoize real--)) + (set! / (logoize real-/)) + (set! < (logoize real-<)) + (set! <= (logoize real-<=)) + (set! = (logoize real-=)) + (set! > (logoize real->)) + (set! >= (logoize real->=)) + (set! abs (logoize-1 real-abs)) + (set! acos (logoize-1 real-acos)) + (set! asin (logoize-1 real-asin)) + (set! atan (logoize real-atan)) + (set! ceiling (logoize-1 real-ceiling)) + (set! cos (logoize-1 real-cos)) + (set! even? (logoize-1 real-even?)) + (set! exp (logoize-1 real-exp)) + (set! expt (logoize-2 real-expt)) + (set! floor (logoize-1 real-floor)) + (set! align (logoize align)) + (set! gcd (logoize real-gcd)) + (set! integer? (logoize-1 real-integer?)) + (set! item (lambda (n stuff) + (real-item (maybe-num n) stuff))) + (set! lcm (logoize real-lcm)) + (set! list-ref (lambda (lst k) + (real-list-ref lst (maybe-num k)))) + (set! log (logoize-1 real-log)) + (set! max (logoize real-max)) + (set! min (logoize real-min)) + (set! modulo (logoize-2 real-modulo)) + (set! negative? (logoize-1 real-negative?)) + (set! number? (logoize-1 real-number?)) + (set! odd? (logoize-1 real-odd?)) + (set! positive? (logoize-1 real-positive?)) + (set! quotient (logoize-2 real-quotient)) + (set! random (logoize real-random)) + (set! remainder (logoize-2 real-remainder)) + (set! round (logoize-1 real-round)) + (set! sin (logoize-1 real-sin)) + (set! sqrt (logoize-1 real-sqrt)) + + (set! tan (logoize-1 real-tan)) + (set! truncate (logoize-1 real-truncate)) + (set! zero? (logoize-1 real-zero?)) + (set! vector-ref + (lambda (vec i) (real-vector-ref vec (maybe-num i)))) + (set! vector-set! + (lambda (vec i val) + (real-vector-set! vec (maybe-num i) val))) + (set! make-vector + (lambda (num . args) + (apply real-make-vector (cons (maybe-num num) + args)))) + (set! list-ref + (lambda (lst i) (real-list-ref lst (maybe-num i)))) + (set! repeated + (lambda (fn n) (real-repeated fn (maybe-num n))))) + ((and (not are-they?) (not yesno)) + (show "Strings are already not numbers")) + ((not yesno) + (set! are-they? #f) (set! * real-*) (set! + real-+) + (set! - real--) (set! / real-/) (set! < real-<) + (set! <= real-<=) (set! = real-=) (set! > real->) + (set! >= real->=) (set! abs real-abs) (set! acos real-acos) + (set! asin real-asin) (set! atan real-atan) + (set! ceiling real-ceiling) (set! cos real-cos) + (set! even? real-even?) + (set! exp real-exp) (set! expt real-expt) + (set! floor real-floor) (set! align real-align) + (set! gcd real-gcd) (set! integer? real-integer?) + (set! item real-item) + (set! lcm real-lcm) (set! list-ref real-list-ref) + (set! log real-log) (set! max real-max) (set! min real-min) + (set! modulo real-modulo) (set! odd? real-odd?) + (set! quotient real-quotient) (set! random real-random) + (set! remainder real-remainder) (set! round real-round) + (set! sin real-sin) (set! sqrt real-sqrt) (set! tan real-tan) + (set! truncate real-truncate) (set! zero? real-zero?) + (set! positive? real-positive?) (set! negative? real-negative?) + (set! number? real-number?) (set! vector-ref real-vector-ref) + (set! vector-set! real-vector-set!) + (set! make-vector real-make-vector) + (set! list-ref real-list-ref) (set! item real-item) + (set! repeated real-repeated)) + (else (whoops "Strings-are-numbers: give a #t or a #f"))) + are-they?))) + + +;; By default, strings are numbers: +(strings-are-numbers #t) + +(if scm? + (begin + (eval '(define (trace:untracef fun sym) + (cond ((memq sym *traced-procedures*) + (set! *traced-procedures* + (remove! sym *traced-procedures*)) + (untracef fun)) + (else + (display "WARNING: not traced " (current-error-port)) + (display sym (current-error-port)) + (newline (current-error-port)) + fun)))) + (eval '(define (edit file) + (ed file) + (load file))) + (eval '(define read + (let ((old-read read)) + (lambda args + (let* ((result (apply old-read args)) + (char (apply peek-char args))) + (if (end-of-line-char? char) + (apply read-char args) + '()) + result))))) + (eval `(define (end-of-line-char? char) + (eq? char ,(integer->char 10)))) + + ;; Don't get confusing "unspecified", and don't allow (define ((f x) y)..) + (eval '(define base:define define)) + (eval '(define define-fixup + (let ((pair? pair?) + (map map) + (eq? eq?) + (car car) + (list list) + (cdr cdr) + (cadr cadr) + (caadr caadr) + (cons cons) + (cdadr cdadr) + (cddr cddr)) + (lambda (exps) + (map (lambda (exp) + (if (and (pair? exp) + (eq? (car exp) 'define) + (pair? (cdr exp)) + (pair? (cadr exp))) + (list 'define + (caadr exp) + (cons 'lambda + (cons (cdadr exp) + (cddr exp)))) + exp)) + exps))))) + (eval '(define define-handler + (let ((cons cons) + (null? null?) + (car car) + (cdr cdr) + (remove! remove!) + (cddr cddr) + (pair? pair?) + (cadr cadr) + (list list) + (member member) + (caadr caadr)) + (lambda (exp env) + (cond ((or (null? (cdr exp)) (null? (cddr exp))) + (error "Badly formed DEFINE")) + ((not (pair? (cadr exp))) + (cond ((not (null? env)) (cons 'base:define (cdr exp))) + ((member (cadr exp) + '(define quote set! if cond else lambda + and or let cons-stream delay + begin quasiquote)) + (error "Can't redefine special form" (cadr exp))) + (else (eval (cons 'base:define (cdr exp))) + (set! *traced-procedures* + (remove! (cadr exp) + *traced-procedures*)) + (list 'quote (cadr exp))))) + ((pair? (caadr exp)) + (error "Badly formed DEFINE")) + (else + (cond ((not (null? env)) + (cons 'base:define (cdr exp))) + ((member (caadr exp) + '(define quote set! if cond else lambda + and or let cons-stream delay + begin quasiquote)) + (error "Can't redefine special form" (caadr exp))) + (else (eval (cons 'base:define + (define-fixup (cdr exp)))) + (set! *traced-procedures* + (remove! (caadr exp) + *traced-procedures*)) + (list 'quote (caadr exp)))))))))) + (eval '(define define (procedure->macro define-handler))) + (eval '(define fix-message + (let ((cons cons) + (car car) + (cdr cdr) + (procedure? procedure?) + (eval eval) + (set! set!)) + (procedure->macro + (lambda (exp env) + (let ((old (string->symbol + (string-append "base:" + (symbol->string (cadr exp)))))) + (eval `(define ,old ,(cadr exp))) + (if (procedure? (eval (cadr exp))) + `(set! ,(cadr exp) + (lambda args + (apply ,old args) + 'okay)) + `(set! ,(cadr exp) + (procedure->macro + (lambda (exp env) + `(begin ,(cons ',old (cdr exp)) + 'okay))))))))))) + (fix-message load) + (fix-message vector-set!) + (fix-message display) + (fix-message write) + (fix-message newline) + (fix-message close-input-port) + (fix-message close-output-port) + (fix-message for-each) + (fix-message set-car!) + (fix-message set-cdr!) + (fix-message transcript-on) + (fix-message transcript-off) + ;; (fix-message set!) + (eval '(define base:set! set!)) + (eval '(set! set! + (procedure->macro + (lambda (exp env) + (if (member (cadr exp) + '(define quote set! if cond else lambda and or + let cons-stream delay + begin quasiquote)) + (error "Can't redefine special form" (cadr exp)) + `(begin (base:set! ,(cadr exp) ,(caddr exp)) + 'okay)))))) + (set-current-error-port (current-output-port)) + + (verbose 1))) + +(if scm? + (begin + (eval '(define scm-xcenter 0)) + (eval '(define scm-ycenter 0)) + (eval '(define pen-color 7)) + (eval '(define bg-color 0)) + (eval '(define color-makers '#((set-color! 0) + (set-color! 9) + (set-color! 10) + (set-color! 11) + (set-color! 12) + (set-color! 13) + (set-color! 14) + (set-color! 15)))) + (eval '(define (clearscreen) + (graphics-mode!) + (clear-graphics!) + (goto-center!) + (set! scm-xcenter (where-x)) + (set! scm-ycenter (where-y)) + (turn-to! -90) + (setpc pen-color) + (if turtle-shown (show-turtle #t)))) + (eval '(define (internal-fd dist) + (if (pendown?) + (draw dist) + (move dist)))) + (eval '(define (internal-rt turn) + (turn-left turn))) + (eval '(define (internal-setxy newx newy) + ((if (pendown?) draw-to! move-to!) + (+ newx scm-xcenter) + (- scm-ycenter newy)))) + (eval '(define (internal-setheading newh) + (turn-to! (+ -90 newh)))) + (eval '(define (xcor) + (- (where-x) scm-xcenter))) + (eval '(define (ycor) + (- scm-ycenter (where-y)))) + (eval '(define (heading) + (- 90 (what-direction))))) + (begin + (eval '(define gambit-xcor 0)) + (eval '(define gambit-ycor 0)) + (eval '(define gambit-heading 0)) + (eval '(define pen-color 0)) + (eval '(define bg-color 7)) + (eval '(define color-makers '#((set-rgb-color 0 0 0) + (set-rgb-color 0 0 1) + (set-rgb-color 0 1 0) + (set-rgb-color 0 1 1) + (set-rgb-color 1 0 0) + (set-rgb-color 1 0 1) + (set-rgb-color 1 1 0) + (set-rgb-color 1 1 1)))) + (eval '(define (clearscreen) + (clear-graphics) + (position-pen 0 0) + (set! gambit-xcor 0) + (set! gambit-ycor 0) + (set! gambit-heading 0) + (if turtle-shown (show-turtle #t)))) + (eval '(define (internal-fd dist) + (set! gambit-xcor (+ gambit-xcor + (* dist (degree-sin gambit-heading)))) + (set! gambit-ycor (+ gambit-ycor + (* dist (degree-cos gambit-heading)))) + ((if (pendown?) draw-line-to position-pen) + gambit-xcor gambit-ycor))) + (eval '(define (internal-rt turn) + (set! gambit-heading (+ gambit-heading turn)) + (while (lambda () (< gambit-heading 0)) + (lambda () (set! gambit-heading (+ gambit-heading 360)))) + (while (lambda () (>= gambit-heading 360)) + (lambda () (set! gambit-heading (- gambit-heading 360)))))) + (eval '(define (while condition action) + (if (condition) (begin (action) (while condition action))))) + (eval '(define (degree-sin angle) + (sin (/ (* angle 3.141592654) 180)))) + (eval '(define (degree-cos angle) + (cos (/ (* angle 3.141592654) 180)))) + (eval '(define (internal-setxy newx newy) + (set! gambit-xcor newx) + (set! gambit-ycor newy) + ((if (pendown?) draw-line-to position-pen) + gambit-xcor gambit-ycor))) + (eval '(define (internal-setheading newh) + (set! gambit-heading newh) + (while (lambda () (< gambit-heading 0)) + (lambda () (set! gambit-heading (+ gambit-heading 360)))) + (while (lambda () (>= gambit-heading 360)) + (lambda () (set! gambit-heading (- gambit-heading 360)))))) + (eval '(define (xcor) gambit-xcor)) + (eval '(define (ycor) gambit-ycor)) + (eval '(define (heading) gambit-heading)))) + +(define turtle-shown #t) +(define (showturtle) + (if (not turtle-shown) (show-turtle #t)) + (set! turtle-shown #t)) +(define st showturtle) +(define (hideturtle) + (if turtle-shown (show-turtle #f)) + (set! turtle-shown #f)) +(define ht hideturtle) +(define (shown?) turtle-shown) + +(define (forward dist) + (if turtle-shown (show-turtle #f)) + (internal-fd dist) + (if turtle-shown (show-turtle #t))) +(define (right angle) + (if turtle-shown (show-turtle #f)) + (internal-rt angle) + (if turtle-shown (show-turtle #t))) +(define (setxy newx newy) + (if turtle-shown (show-turtle #f)) + (internal-setxy newx newy) + (if turtle-shown (show-turtle #t))) +(define (setheading newh) + (if turtle-shown (show-turtle #f)) + (internal-setheading newh) + (if turtle-shown (show-turtle #t))) + +(define (back dist) + (forward (- dist))) +(define fd forward) +(define bk back) +(define (left turn) + (right (- turn))) +(define lt left) +(define rt right) +(define (setx newx) + (setxy newx (ycor))) +(define (sety newy) + (setxy (xcor) newy)) +(define pendown-flag #t) +(define penerase-flag #f) +(define (pendown?) pendown-flag) +(define (pendown) + (set! pendown-flag #t) + (set! penerase-flag #f) + (set! true-pen-color pen-color) + (eval (vector-ref color-makers true-pen-color))) +(define pd pendown) +(define (penup) + (set! pendown-flag #f)) +(define pu penup) +(define (home) (setxy 0 0)) +(define cs clearscreen) +(define (pos) (list (xcor) (ycor))) +(define (setpencolor newc) + (eval (vector-ref color-makers newc)) + (set! pen-color newc) + (if turtle-shown (show-turtle #t)) + (if penerase-flag + (eval (vector-ref color-makers bg-color)) + (set! true-pen-color newc))) +(define setpc setpencolor) +(define (pencolor) pen-color) +(define pc pencolor) + +(define true-pen-color pen-color) +(define (penerase) + (set! true-pen-color bg-color) + (set! pendown-flag #t) + (set! penerase-flag #t) + (eval (vector-ref color-makers true-pen-color))) +(define pe penerase) + +(define turtle-base-angle (/ (* (acos (/ 1 3)) 180) 3.141592654)) +(define (show-turtle show-flag) + (let ((olderase penerase-flag) + (olddown pendown-flag)) + (if show-flag (pendown) (penerase)) + (internal-rt -90) + (internal-fd 5) + (internal-rt (- 180 turtle-base-angle)) + (internal-fd 15) + (internal-rt (* 2 turtle-base-angle)) + (internal-fd 15) + (internal-rt (- 180 turtle-base-angle)) + (internal-fd 5) + (internal-rt 90) + (if olddown + (if olderase (penerase) (pendown)) + (penup)))) + +(if scm? + (eval '(define repeat (procedure->macro + (lambda(x env) + `(repeat-helper ,(cadr x) (lambda () . ,(cddr x))))))) + (eval '(define-macro (repeat . args) + `(repeat-helper ,(car args) (lambda () . ,(cdr args)))))) + +(define (repeat-helper num thunk) + (if (<= num 0) + 'done + (begin (thunk) (repeat-helper (- num 1) thunk)))) + +(if scm? + (eval '(define call/cc call-with-current-continuation))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/bst.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/bst.scm new file mode 100644 index 0000000..5815eae --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/bst.scm @@ -0,0 +1,28 @@ +(define (entry tree) (car tree)) + +(define (left-branch tree) (cadr tree)) + +(define (right-branch tree) (caddr tree)) + +(define (make-tree entry left right) + (list entry left right)) + +(define (element-of-set? x set) + (cond ((null? set) #f) + ((= x (entry set)) #t) + ((< x (entry set)) + (element-of-set? x (left-branch set))) + ((> x (entry set)) + (element-of-set? x (right-branch set))))) + +(define (adjoin-set x set) + (cond ((null? set) (make-tree x '() '())) + ((= x (entry set)) set) + ((< x (entry set)) + (make-tree (entry set) + (adjoin-set x (left-branch set)) + (right-branch set))) + ((> x (entry set)) + (make-tree (entry set) + (left-branch set) + (adjoin-set x (right-branch set)))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/calc.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/calc.scm new file mode 100644 index 0000000..7d667dd --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/calc.scm @@ -0,0 +1,29 @@ +;; Scheme calculator -- evaluate simple expressions + +; The read-eval-print loop: + +(define (calc) + (display "calc: ") + (flush) + (print (calc-eval (read))) + (calc)) + +; Evaluate an expression: + +(define (calc-eval exp) + (cond ((number? exp) exp) + ((list? exp) (calc-apply (car exp) (map calc-eval (cdr exp)))) + (else (error "Calc: bad expression:" exp)))) + +; Apply a function to arguments: + +(define (calc-apply fn args) + (cond ((eq? fn '+) (accumulate + 0 args)) + ((eq? fn '-) (cond ((null? args) (error "Calc: no args to -")) + ((= (length args) 1) (- (car args))) + (else (- (car args) (accumulate + 0 (cdr args)))))) + ((eq? fn '*) (accumulate * 1 args)) + ((eq? fn '/) (cond ((null? args) (error "Calc: no args to /")) + ((= (length args) 1) (/ (car args))) + (else (/ (car args) (accumulate * 1 (cdr args)))))) + (else (error "Calc: bad operator:" fn)))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/chapter1.code b/js/games/nluqo.github.io/~bh/61a-pages/Lib/chapter1.code new file mode 100644 index 0000000..438f49f --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/chapter1.code @@ -0,0 +1,805 @@ +;;;;CODE FROM CHAPTER 1 OF STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS + +;;; Examples from the book are commented out with ;: so that they +;;; are easy to find and so that they will be omitted if you evaluate a +;;; chunk of the file (programs with intervening examples) in Scheme. + +;;; BEWARE: Although the whole file can be loaded into Scheme, +;;; don't expect the programs to work if you do so. For example, +;;; the redefinition of + in exercise 1.9 wreaks havoc with the +;;; last version of square defined here. + + +;;;SECTION 1.1.1 + +;; interpreter examples + +;: 486 + +;: (+ 137 349) +;: (- 1000 334) +;: (* 5 99) +;: (/ 10 5) +;: (+ 2.7 10) + +;: (+ 21 35 12 7) +;: (* 25 4 12) + +;: (+ (* 3 5) (- 10 6)) + +;: (+ (* 3 (+ (* 2 4) (+ 3 5))) (+ (- 10 7) 6)) + +;: (+ (* 3 +;: (+ (* 2 4) +;: (+ 3 5))) +;: (+ (- 10 7) +;: 6)) + + +;;;SECTION 1.1.2 + +;: (define size 2) +;: size +;: (* 5 size) + +;: (define pi 3.14159) +;: (define radius 10) +;: (* pi (* radius radius)) +;: (define circumference (* 2 pi radius)) +;: circumference + + +;;;SECTION 1.1.3 + +;: (* (+ 2 (* 4 6)) +;: (+ 3 5 7)) + + +;;;SECTION 1.1.4 + +(define (square x) (* x x)) + +;: (square 21) +;: (square (+ 2 5)) +;: (square (square 3)) + +(define (sum-of-squares x y) + (+ (square x) (square y))) + +;: (sum-of-squares 3 4) + +(define (f a) + (sum-of-squares (+ a 1) (* a 2))) + +;: (f 5) + + +;;;SECTION 1.1.5 + +;: (f 5) +;: (sum-of-squares (+ 5 1) (* 5 2)) +;: (+ (square 6) (square 10)) +;: (+ (* 6 6) (* 10 10)) +;: (+ 36 100) + +;: (f 5) +;: (sum-of-squares (+ 5 1) (* 5 2)) +;: (+ (square (+ 5 1)) (square (* 5 2)) ) +;: (+ (* (+ 5 1) (+ 5 1)) (* (* 5 2) (* 5 2))) +;: (+ (* 6 6) (* 10 10)) +;: (+ 36 100) +;: 136 + + +;;;SECTION 1.1.6 + +(define (abs x) + (cond ((> x 0) x) + ((= x 0) 0) + ((< x 0) (- x)))) + +(define (abs x) + (cond ((< x 0) (- x)) + (else x))) + +(define (abs x) + (if (< x 0) + (- x) + x)) + +;: (and (> x 5) (< x 10)) + +(define (>= x y) + (or (> x y) (= x y))) + +(define (>= x y) + (not (< x y))) + + +;;EXERCISE 1.1 +;: 10 + +;: (+ 5 3 4) + +;: (- 9 1) + +;: (/ 6 2) + +;: (+ (* 2 4) (- 4 6)) + +;: (define a 3) + +;: (define b (+ a 1)) + +;: (+ a b (* a b)) + +;: (= a b) + +;: (if (and (> b a) (< b (* a b))) +;: b +;: a) + +;: (cond ((= a 4) 6) +;: ((= b 4) (+ 6 7 a)) +;: (else 25)) + +;: (+ 2 (if (> b a) b a)) + +;: (* (cond ((> a b) a) +;: ((< a b) b) +;: (else -1)) +;: (+ a 1)) + +;;EXERCISE 1.4 +(define (a-plus-abs-b a b) + ((if (> b 0) + -) a b)) + +;;EXERCISE 1.5 +(define (p) (p)) + +(define (test x y) + (if (= x 0) + 0 + y)) + +;: (test 0 (p)) + + +;;;SECTION 1.1.7 + +(define (sqrt-iter guess x) + (if (good-enough? guess x) + guess + (sqrt-iter (improve guess x) + x))) + +(define (improve guess x) + (average guess (/ x guess))) + +(define (average x y) + (/ (+ x y) 2)) + +(define (good-enough? guess x) + (< (abs (- (square guess) x)) 0.001)) + +(define (sqrt x) + (sqrt-iter 1.0 x)) + + +;: (sqrt 9) +;: (sqrt (+ 100 37)) +;: (sqrt (+ (sqrt 2) (sqrt 3))) +;: (square (sqrt 1000)) + + +;;EXERCISE 1.6 +(define (new-if predicate then-clause else-clause) + (cond (predicate then-clause) + (else else-clause))) + +;: (new-if (= 2 3) 0 5) + +;: (new-if (= 1 1) 0 5) + +(define (sqrt-iter guess x) + (new-if (good-enough? guess x) + guess + (sqrt-iter (improve guess x) + x))) + + +;;;SECTION 1.1.8 + +(define (square x) (* x x)) + +(define (square x) + (exp (double (log x)))) + +(define (double x) (+ x x)) + + +;; As in 1.1.7 +(define (sqrt x) + (sqrt-iter 1.0 x)) + +(define (sqrt-iter guess x) + (if (good-enough? guess x) + guess + (sqrt-iter (improve guess x) x))) + +(define (good-enough? guess x) + (< (abs (- (square guess) x)) 0.001)) + +(define (improve guess x) + (average guess (/ x guess))) + + +;; Block-structured +(define (sqrt x) + (define (good-enough? guess x) + (< (abs (- (square guess) x)) 0.001)) + (define (improve guess x) + (average guess (/ x guess))) + (define (sqrt-iter guess x) + (if (good-enough? guess x) + guess + (sqrt-iter (improve guess x) x))) + (sqrt-iter 1.0 x)) + +;; Taking advantage of lexical scoping +(define (sqrt x) + (define (good-enough? guess) + (< (abs (- (square guess) x)) 0.001)) + (define (improve guess) + (average guess (/ x guess))) + (define (sqrt-iter guess) + (if (good-enough? guess) + guess + (sqrt-iter (improve guess)))) + (sqrt-iter 1.0)) + +;;;SECTION 1.2.1 + +;; Recursive + +(define (factorial n) + (if (= n 1) + 1 + (* n (factorial (- n 1))))) + + +;; Iterative + +(define (factorial n) + (fact-iter 1 1 n)) + +(define (fact-iter product counter max-count) + (if (> counter max-count) + product + (fact-iter (* counter product) + (+ counter 1) + max-count))) + +;; Iterative, block-structured (from footnote) +(define (factorial n) + (define (iter product counter) + (if (> counter n) + product + (iter (* counter product) + (+ counter 1)))) + (iter 1 1)) + + +;;EXERCISE 1.9 +(define (+ a b) + (if (= a 0) + b + (inc (+ (dec a) b)))) + +(define (+ a b) + (if (= a 0) + b + (+ (dec a) (inc b)))) + +;;EXERCISE 1.10 +(define (A x y) + (cond ((= y 0) 0) + ((= x 0) (* 2 y)) + ((= y 1) 2) + (else (A (- x 1) + (A x (- y 1)))))) + +;: (A 1 10) + +;: (A 2 4) + +;: (A 3 3) + +(define (f n) (A 0 n)) + +(define (g n) (A 1 n)) + +(define (h n) (A 2 n)) + +(define (k n) (* 5 n n)) + + +;;;SECTION 1.2.2 + +;; Recursive + +(define (fib n) + (cond ((= n 0) 0) + ((= n 1) 1) + (else (+ (fib (- n 1)) + (fib (- n 2)))))) + +;; Iterative + +(define (fib n) + (fib-iter 1 0 n)) + +(define (fib-iter a b count) + (if (= count 0) + b + (fib-iter (+ a b) a (- count 1)))) + + +;; Counting change + +(define (count-change amount) + (cc amount 5)) + +(define (cc amount kinds-of-coins) + (cond ((= amount 0) 1) + ((or (< amount 0) (= kinds-of-coins 0)) 0) + (else (+ (cc amount + (- kinds-of-coins 1)) + (cc (- amount + (first-denomination kinds-of-coins)) + kinds-of-coins))))) + +(define (first-denomination kinds-of-coins) + (cond ((= kinds-of-coins 1) 1) + ((= kinds-of-coins 2) 5) + ((= kinds-of-coins 3) 10) + ((= kinds-of-coins 4) 25) + ((= kinds-of-coins 5) 50))) + +;: (count-change 100) + + +;;;SECTION 1.2.3 + +;;EXERCISE 1.15 +(define (cube x) (* x x x)) + +(define (p x) (- (* 3 x) (* 4 (cube x)))) + +(define (sine angle) + (if (not (> (abs angle) 0.1)) + angle + (p (sine (/ angle 3.0))))) + + +;;;SECTION 1.2.4 + +;; Linear recursion +(define (expt b n) + (if (= n 0) + 1 + (* b (expt b (- n 1))))) + + +;; Linear iteration +(define (expt b n) + (expt-iter b n 1)) + +(define (expt-iter b counter product) + (if (= counter 0) + product + (expt-iter b + (- counter 1) + (* b product)))) + +;; Logarithmic iteration +(define (fast-expt b n) + (cond ((= n 0) 1) + ((even? n) (square (fast-expt b (/ n 2)))) + (else (* b (fast-expt b (- n 1)))))) + +(define (even? n) + (= (remainder n 2) 0)) + + +;;EXERCISE 1.17 +(define (* a b) + (if (= b 0) + 0 + (+ a (* a (- b 1))))) + +;;EXERCISE 1.19 +(define (fib n) + (fib-iter 1 0 0 1 n)) + +(define (fib-iter a b p q count) + (cond ((= count 0) b) + ((even? count) + (fib-iter a + b + ;;?? compute p + ;;?? compute q + (/ count 2))) + (else (fib-iter (+ (* b q) (* a q) (* a p)) + (+ (* b p) (* a q)) + p + q + (- count 1))))) + + +;;;SECTION 1.2.5 + +(define (gcd a b) + (if (= b 0) + a + (gcd b (remainder a b)))) + + +;;;SECTION 1.2.6 + +;; prime? + +(define (smallest-divisor n) + (find-divisor n 2)) + +(define (find-divisor n test-divisor) + (cond ((> (square test-divisor) n) n) + ((divides? test-divisor n) test-divisor) + (else (find-divisor n (+ test-divisor 1))))) + +(define (divides? a b) + (= (remainder b a) 0)) + +(define (prime? n) + (= n (smallest-divisor n))) + + +;; fast-prime? + +(define (expmod base exp m) + (cond ((= exp 0) 1) + ((even? exp) + (remainder (square (expmod base (/ exp 2) m)) + m)) + (else + (remainder (* base (expmod base (- exp 1) m)) + m)))) + +(define (fermat-test n) + (define (try-it a) + (= (expmod a n n) a)) + (try-it (+ 1 (random (- n 1))))) + +(define (fast-prime? n times) + (cond ((= times 0) true) + ((fermat-test n) (fast-prime? n (- times 1))) + (else false))) + + +;;EXERCISE 1.22 +(define (timed-prime-test n) + (newline) + (display n) + (start-prime-test n (runtime))) + +(define (start-prime-test n start-time) + (if (prime? n) + (report-prime (- (runtime) start-time)))) + +(define (report-prime elapsed-time) + (display " *** ") + (display elapsed-time)) + +;;EXERCISE 1.25 +(define (expmod base exp m) + (remainder (fast-expt base exp) m)) + +;;EXERCISE 1.26 +(define (expmod base exp m) + (cond ((= exp 0) 1) + ((even? exp) + (remainder (* (expmod base (/ exp 2) m) + (expmod base (/ exp 2) m)) + m)) + (else + (remainder (* base (expmod base (- exp 1) m)) + m)))) + +;;;SECTION 1.3 + +(define (cube x) (* x x x)) + +;;;SECTION 1.3.1 + +(define (sum-integers a b) + (if (> a b) + 0 + (+ a (sum-integers (+ a 1) b)))) + +(define (sum-cubes a b) + (if (> a b) + 0 + (+ (cube a) (sum-cubes (+ a 1) b)))) + +(define (pi-sum a b) + (if (> a b) + 0 + (+ (/ 1.0 (* a (+ a 2))) (pi-sum (+ a 4) b)))) + +(define (sum term a next b) + (if (> a b) + 0 + (+ (term a) + (sum term (next a) next b)))) + + +;; Using sum + +(define (inc n) (+ n 1)) + +(define (sum-cubes a b) + (sum cube a inc b)) + +;: (sum-cubes 1 10) + + +(define (identity x) x) + +(define (sum-integers a b) + (sum identity a inc b)) + +;: (sum-integers 1 10) + + +(define (pi-sum a b) + (define (pi-term x) + (/ 1.0 (* x (+ x 2)))) + (define (pi-next x) + (+ x 4)) + (sum pi-term a pi-next b)) + +;: (* 8 (pi-sum 1 1000)) + + +(define (integral f a b dx) + (define (add-dx x) (+ x dx)) + (* (sum f (+ a (/ dx 2)) add-dx b) + dx)) + +;: (integral cube 0 1 0.01) + +;: (integral cube 0 1 0.001) + + +;;EXERCISE 1.32 +;: (accumulate combiner null-value term a next b) + +;;;SECTION 1.3.2 + +(define (pi-sum a b) + (sum (lambda (x) (/ 1.0 (* x (+ x 2)))) + a + (lambda (x) (+ x 4)) + b)) + +(define (integral f a b dx) + (* (sum f + (+ a (/ dx 2.0)) + (lambda (x) (+ x dx)) + b) + dx)) + +(define (plus4 x) (+ x 4)) + +(define plus4 (lambda (x) (+ x 4))) + +;: ((lambda (x y z) (+ x y (square z))) 1 2 3) + + +;; Using let + +(define (f x y) + (define (f-helper a b) + (+ (* x (square a)) + (* y b) + (* a b))) + (f-helper (+ 1 (* x y)) + (- 1 y))) + +(define (f x y) + ((lambda (a b) + (+ (* x (square a)) + (* y b) + (* a b))) + (+ 1 (* x y)) + (- 1 y))) + +(define (f x y) + (let ((a (+ 1 (* x y))) + (b (- 1 y))) + (+ (* x (square a)) + (* y b) + (* a b)))) + +;: (+ (let ((x 3)) +;: (+ x (* x 10))) +;: x) + +;: (let ((x 3) +;: (y (+ x 2))) +;: (* x y)) + +(define (f x y) + (define a (+ 1 (* x y))) + (define b (- 1 y)) + (+ (* x (square a)) + (* y b) + (* a b))) + + +;;EXERCISE 1.34 +(define (f g) + (g 2)) + +;: (f square) + +;: (f (lambda (z) (* z (+ z 1)))) + + +;;;SECTION 1.3.3 + +;; Half-interval method + +(define (search f neg-point pos-point) + (let ((midpoint (average neg-point pos-point))) + (if (close-enough? neg-point pos-point) + midpoint + (let ((test-value (f midpoint))) + (cond ((positive? test-value) + (search f neg-point midpoint)) + ((negative? test-value) + (search f midpoint pos-point)) + (else midpoint)))))) + +(define (close-enough? x y) + (< (abs (- x y)) 0.001)) + +(define (half-interval-method f a b) + (let ((a-value (f a)) + (b-value (f b))) + (cond ((and (negative? a-value) (positive? b-value)) + (search f a b)) + ((and (negative? b-value) (positive? a-value)) + (search f b a)) + (else + (error "Values are not of opposite sign" a b))))) + + +;: (half-interval-method sin 2.0 4.0) + +;: (half-interval-method (lambda (x) (- (* x x x) (* 2 x) 3)) +;: 1.0 +;: 2.0) + + +;; Fixed points + +(define tolerance 0.00001) + +(define (fixed-point f first-guess) + (define (close-enough? v1 v2) + (< (abs (- v1 v2)) tolerance)) + (define (try guess) + (let ((next (f guess))) + (if (close-enough? guess next) + next + (try next)))) + (try first-guess)) + + +;: (fixed-point cos 1.0) + +;: (fixed-point (lambda (y) (+ (sin y) (cos y))) +;: 1.0) + + +(define (sqrt x) + (fixed-point (lambda (y) (/ x y)) + 1.0)) + +(define (sqrt x) + (fixed-point (lambda (y) (average y (/ x y))) + 1.0)) + + +;;EXERCISE 1.37 +;: (cont-frac (lambda (i) 1.0) +;: (lambda (i) 1.0) +;: k) + + +;;;SECTION 1.3.4 + +(define (average-damp f) + (lambda (x) (average x (f x)))) + +;: ((average-damp square) 10) + +(define (sqrt x) + (fixed-point (average-damp (lambda (y) (/ x y))) + 1.0)) + +(define (cube-root x) + (fixed-point (average-damp (lambda (y) (/ x (square y)))) + 1.0)) + + +;; Newton's method + +(define (deriv g) + (lambda (x) + (/ (- (g (+ x dx)) (g x)) + dx))) +(define dx 0.00001) + + +(define (cube x) (* x x x)) + +;: ((deriv cube) 5) + +(define (newton-transform g) + (lambda (x) + (- x (/ (g x) ((deriv g) x))))) + +(define (newtons-method g guess) + (fixed-point (newton-transform g) guess)) + + +(define (sqrt x) + (newtons-method (lambda (y) (- (square y) x)) + 1.0)) + + +;; Fixed point of transformed function + +(define (fixed-point-of-transform g transform guess) + (fixed-point (transform g) guess)) + +(define (sqrt x) + (fixed-point-of-transform (lambda (y) (/ x y)) + average-damp + 1.0)) + +(define (sqrt x) + (fixed-point-of-transform (lambda (y) (- (square y) x)) + newton-transform + 1.0)) + + +;;EXERCISE 1.40 +;: (newtons-method (cubic a b c) 1) + + +;;EXERCISE 1.41 +;: (((double (double double)) inc) 5) + + +;;EXERCISE 1.42 +;: ((compose square inc) 6) + + +;;EXERCISE 1.43 +;: ((repeated square 2) 5) + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/chapter2.code b/js/games/nluqo.github.io/~bh/61a-pages/Lib/chapter2.code new file mode 100644 index 0000000..78dcccd --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/chapter2.code @@ -0,0 +1,1966 @@ +; -----***CH2.SCM*** +;;;;CODE FROM CHAPTER 2 OF STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS + +;;; Examples from the book are commented out with ;: so that they +;;; are easy to find and so that they will be omitted if you evaluate a +;;; chunk of the file (programs with intervening examples) in Scheme. + +;;; BEWARE: Although the whole file can be loaded into Scheme, +;;; you won't want to do so. For example, you generally do +;;; not want to use the procedural representation of pairs +;;; (cons, car, cdr as defined in section 2.1.3) instead of +;;; Scheme's primitive pairs. + +;;; Some things require code from other chapters -- see ch2support.scm + + +(define (linear-combination a b x y) + (+ (* a x) (* b y))) + +(define (linear-combination a b x y) + (add (mul a x) (mul b y))) + + +;;;SECTION 2.1.1 + +(define (add-rat x y) + (make-rat (+ (* (numer x) (denom y)) + (* (numer y) (denom x))) + (* (denom x) (denom y)))) + +(define (sub-rat x y) + (make-rat (- (* (numer x) (denom y)) + (* (numer y) (denom x))) + (* (denom x) (denom y)))) + +(define (mul-rat x y) + (make-rat (* (numer x) (numer y)) + (* (denom x) (denom y)))) + +(define (div-rat x y) + (make-rat (* (numer x) (denom y)) + (* (denom x) (numer y)))) + +(define (equal-rat? x y) + (= (* (numer x) (denom y)) + (* (numer y) (denom x)))) + +;: (define x (cons 1 2)) +;: +;: (car x) +;: (cdr x) + +;: (define x (cons 1 2)) +;: (define y (cons 3 4)) +;: (define z (cons x y)) +;: (car (car z)) +;: (car (cdr z)) + +(define (make-rat n d) (cons n d)) + +(define (numer x) (car x)) + +(define (denom x) (cdr x)) + +;;footnote -- alternative definitions +(define make-rat cons) +(define numer car) +(define denom cdr) + +(define (print-rat x) + (newline) + (display (numer x)) + (display "/") + (display (denom x))) + + +;: (define one-half (make-rat 1 2)) +;: +;: (print-rat one-half) +;: +;: (define one-third (make-rat 1 3)) +;: +;: (print-rat (add-rat one-half one-third)) +;: (print-rat (mul-rat one-half one-third)) +;: (print-rat (add-rat one-third one-third)) + + +;; reducing to lowest terms in constructor +;; (uses gcd from 1.2.5 -- see ch2support.scm) + +(define (make-rat n d) + (let ((g (gcd n d))) + (cons (/ n g) (/ d g)))) + + +;: (print-rat (add-rat one-third one-third)) + + +;;;SECTION 2.1.2 + +;; reducing to lowest terms in selectors +;; (uses gcd from 1.2.5 -- see ch2support.scm) + +(define (make-rat n d) + (cons n d)) + +(define (numer x) + (let ((g (gcd (car x) (cdr x)))) + (/ (car x) g))) + +(define (denom x) + (let ((g (gcd (car x) (cdr x)))) + (/ (cdr x) g))) + + +;; EXERCISE 2.2 +(define (print-point p) + (newline) + (display "(") + (display (x-point p)) + (display ",") + (display (y-point p)) + (display ")")) + + +;;;SECTION 2.1.3 +(define (cons x y) + (define (dispatch m) + (cond ((= m 0) x) + ((= m 1) y) + (else (error "Argument not 0 or 1 -- CONS" m)))) + dispatch) + +(define (car z) (z 0)) + +(define (cdr z) (z 1)) + + +;; EXERCISE 2.4 + +(define (cons x y) + (lambda (m) (m x y))) + +(define (car z) + (z (lambda (p q) p))) + + +;; EXERCISE 2.6 +(define zero (lambda (f) (lambda (x) x))) + +(define (add-1 n) + (lambda (f) (lambda (x) (f ((n f) x))))) + + +;;;SECTION 2.1.4 + +(define (add-interval x y) + (make-interval (+ (lower-bound x) (lower-bound y)) + (+ (upper-bound x) (upper-bound y)))) + +(define (mul-interval x y) + (let ((p1 (* (lower-bound x) (lower-bound y))) + (p2 (* (lower-bound x) (upper-bound y))) + (p3 (* (upper-bound x) (lower-bound y))) + (p4 (* (upper-bound x) (upper-bound y)))) + (make-interval (min p1 p2 p3 p4) + (max p1 p2 p3 p4)))) + +(define (div-interval x y) + (mul-interval x + (make-interval (/ 1.0 (upper-bound y)) + (/ 1.0 (lower-bound y))))) + +;; EXERCISE 2.7 + +(define (make-interval a b) (cons a b)) + + +;;;SECTION 2.1.4 again + +(define (make-center-width c w) + (make-interval (- c w) (+ c w))) + +(define (center i) + (/ (+ (lower-bound i) (upper-bound i)) 2)) + +(define (width i) + (/ (- (upper-bound i) (lower-bound i)) 2)) + +;; parallel resistors + +(define (par1 r1 r2) + (div-interval (mul-interval r1 r2) + (add-interval r1 r2))) + +(define (par2 r1 r2) + (let ((one (make-interval 1 1))) + (div-interval one + (add-interval (div-interval one r1) + (div-interval one r2))))) + +;;;SECTION 2.2.1 + +;: (cons 1 +;: (cons 2 +;: (cons 3 +;: (cons 4 nil)))) + + +;: (define one-through-four (list 1 2 3 4)) +;: +;: one-through-four +;: (car one-through-four) +;: (cdr one-through-four) +;: (car (cdr one-through-four)) +;: (cons 10 one-through-four) + +(define (list-ref items n) + (if (= n 0) + (car items) + (list-ref (cdr items) (- n 1)))) + +;: (define squares (list 1 4 9 16 25)) + +;: (list-ref squares 3) + +(define (length items) + (if (null? items) + 0 + (+ 1 (length (cdr items))))) + +;: (define odds (list 1 3 5 7)) + +;: (length odds) + +(define (length items) + (define (length-iter a count) + (if (null? a) + count + (length-iter (cdr a) (+ 1 count)))) + (length-iter items 0)) + +;: (append squares odds) +;: (append odds squares) + + +(define (append list1 list2) + (if (null? list1) + list2 + (cons (car list1) (append (cdr list1) list2)))) + + +;; EXERCISE 2.17 +;: (last-pair (list 23 72 149 34)) + + +;; EXERCISE 2.18 +;: (reverse (list 1 4 9 16 25)) + +;; EXERCISE 2.19 +(define us-coins (list 50 25 10 5 1)) + +(define uk-coins (list 100 50 20 10 5 2 1 0.5)) + +;: (cc 100 us-coins) + +(define (cc amount coin-values) + (cond ((= amount 0) 1) + ((or (< amount 0) (no-more? coin-values)) 0) + (else + (+ (cc amount + (except-first-denomination coin-values)) + (cc (- amount + (first-denomination coin-values)) + coin-values))))) + +;; EXERCISE 2.20 +;: (same-parity 1 2 3 4 5 6 7) +;: (same-parity 2 3 4 5 6 7) + + +;; Mapping over lists + +(define (scale-list items factor) + (if (null? items) + nil + (cons (* (car items) factor) + (scale-list (cdr items) factor)))) + +;: (scale-list (list 1 2 3 4 5) 10) + +;: (map + (list 1 2 3) (list 40 50 60) (list 700 800 900)) + +;: (map (lambda (x y) (+ x (* 2 y))) +;: (list 1 2 3) +;: (list 4 5 6)) + +(define (map proc items) + (if (null? items) + nil + (cons (proc (car items)) + (map proc (cdr items))))) + +;: (map abs (list -10 2.5 -11.6 17)) + +;: (map (lambda (x) (* x x)) +;: (list 1 2 3 4)) + +(define (scale-list items factor) + (map (lambda (x) (* x factor)) + items)) + + +;; EXERCISE 2.21 +;: (square-list (list 1 2 3 4)) + + +;; EXERCISE 2.22 +(define (square-list items) + (define (iter things answer) + (if (null? things) + answer + (iter (cdr things) + (cons (square (car things)) + answer)))) + (iter items nil)) + +(define (square-list items) + (define (iter things answer) + (if (null? things) + answer + (iter (cdr things) + (cons answer + (square (car things)))))) + (iter items nil)) + + +;; EXERCISE 2.23 + +;: (for-each (lambda (x) (newline) (display x)) +;: (list 57 321 88)) + + + +;;;SECTION 2.2.2 +;: (cons (list 1 2) (list 3 4)) +;: +;: (define x (cons (list 1 2) (list 3 4))) +;: (length x) +;: (count-leaves x) +;: +;: (list x x) +;: (length (list x x)) +;: (count-leaves (list x x)) + +(define (count-leaves x) + (cond ((null? x) 0) + ((not (pair? x)) 1) + (else (+ (count-leaves (car x)) + (count-leaves (cdr x)))))) + +;; EXERCISE 2.24 +;: (list 1 (list 2 (list 3 4))) + +;; EXERCISE 2.25 +;: (1 3 (5 7) 9) +;: ((7)) +;: (1 (2 (3 (4 (5 (6 7)))))) + +;; EXERCISE 2.26 +;: (define x (list 1 2 3)) +;: (define y (list 4 5 6)) +;: +;: (append x y) +;: (cons x y) +;: (list x y) + +;; EXERCISE 2.27 + +;: (define x (list (list 1 2) (list 3 4))) +;: x +;: (reverse x) +;: (deep-reverse x) + + +;; EXERCISE 2.28 + +;: (define x (list (list 1 2) (list 3 4))) +;: (fringe x) +;: (fringe (list x x)) + + +;; EXERCISE 2.29 +(define (make-mobile left right) + (list left right)) + +(define (make-branch length structure) + (list length structure)) + + +;; part d +(define (make-mobile left right) + (cons left right)) + +(define (make-branch length structure) + (cons length structure)) + + +;; Mapping over trees + +(define (scale-tree tree factor) + (cond ((null? tree) nil) + ((not (pair? tree)) (* tree factor)) + (else (cons (scale-tree (car tree) factor) + (scale-tree (cdr tree) factor))))) + + +;: (scale-tree (list 1 (list 2 (list 3 4) 5) (list 6 7)) +;: 10) + + +(define (scale-tree tree factor) + (map (lambda (sub-tree) + (if (pair? sub-tree) + (scale-tree sub-tree factor) + (* sub-tree factor))) + tree)) + + +;; EXERCISE 2.30 +;: (square-tree +;: (list 1 +;: (list 2 (list 3 4) 5) +;: (list 6 7))) + + +;; EXERCISE 2.31 +(define (square-tree tree) (tree-map square tree)) + + +;; EXERCISE 2.32 +(define (subsets s) + (if (null? s) + (list nil) + (let ((rest (subsets (cdr s)))) + (append rest (map ??FILL-THIS-IN?? rest))))) + + +;;;SECTION 2.2.3 + +(define (sum-odd-squares tree) + (cond ((null? tree) 0) + ((not (pair? tree)) + (if (odd? tree) (square tree) 0)) + (else (+ (sum-odd-squares (car tree)) + (sum-odd-squares (cdr tree)))))) + +(define (even-fibs n) + (define (next k) + (if (> k n) + nil + (let ((f (fib k))) + (if (even? f) + (cons f (next (+ k 1))) + (next (+ k 1)))))) + (next 0)) + + +;; Sequence operations + +;: (map square (list 1 2 3 4 5)) + +(define (filter predicate sequence) + (cond ((null? sequence) nil) + ((predicate (car sequence)) + (cons (car sequence) + (filter predicate (cdr sequence)))) + (else (filter predicate (cdr sequence))))) + +;: (filter odd? (list 1 2 3 4 5)) + +(define (accumulate op initial sequence) + (if (null? sequence) + initial + (op (car sequence) + (accumulate op initial (cdr sequence))))) + +;: (accumulate + 0 (list 1 2 3 4 5)) +;: (accumulate * 1 (list 1 2 3 4 5)) +;: (accumulate cons nil (list 1 2 3 4 5)) + +(define (enumerate-interval low high) + (if (> low high) + nil + (cons low (enumerate-interval (+ low 1) high)))) + +;: (enumerate-interval 2 7) + +(define (enumerate-tree tree) + (cond ((null? tree) nil) + ((not (pair? tree)) (list tree)) + (else (append (enumerate-tree (car tree)) + (enumerate-tree (cdr tree)))))) + +;: (enumerate-tree (list 1 (list 2 (list 3 4)) 5)) + +(define (sum-odd-squares tree) + (accumulate + + 0 + (map square + (filter odd? + (enumerate-tree tree))))) + +(define (even-fibs n) + (accumulate cons + nil + (filter even? + (map fib + (enumerate-interval 0 n))))) + +(define (list-fib-squares n) + (accumulate cons + nil + (map square + (map fib + (enumerate-interval 0 n))))) + +;: (list-fib-squares 10) + + +(define (product-of-squares-of-odd-elements sequence) + (accumulate * + 1 + (map square + (filter odd? sequence)))) + +;: (product-of-squares-of-odd-elements (list 1 2 3 4 5)) + +(define (salary-of-highest-paid-programmer records) + (accumulate max + 0 + (map salary + (filter programmer? records)))) + + +;; EXERCISE 2.34 +(define (horner-eval x coefficient-sequence) + (accumulate (lambda (this-coeff higher-terms) ??FILL-THIS-IN??) + 0 + coefficient-sequence)) + +;: (horner-eval 2 (list 1 3 0 5 0 1)) + +;; EXERCISE 2.36 +(define (accumulate-n op init seqs) + (if (null? (car seqs)) + nil + (cons (accumulate op init ??FILL-THIS-IN??) + (accumulate-n op init ??FILL-THIS-IN??)))) + +;: (accumulate-n + 0 s) + +;; EXERCISE 2.37 + +(define (dot-product v w) + (accumulate + 0 (map * v w))) + + +;; EXERCISE 2.38 + +(define (fold-left op initial sequence) + (define (iter result rest) + (if (null? rest) + result + (iter (op result (car rest)) + (cdr rest)))) + (iter initial sequence)) + +;: (fold-right / 1 (list 1 2 3)) +;: (fold-left / 1 (list 1 2 3)) +;: (fold-right list nil (list 1 2 3)) +;: (fold-left list nil (list 1 2 3)) + + +;;Nested mappings + +;: (accumulate append +;: nil +;: (map (lambda (i) +;: (map (lambda (j) (list i j)) +;: (enumerate-interval 1 (- i 1)))) +;: (enumerate-interval 1 n))) + +(define (flatmap proc seq) + (accumulate append nil (map proc seq))) + +(define (prime-sum? pair) + (prime? (+ (car pair) (cadr pair)))) + +(define (make-pair-sum pair) + (list (car pair) (cadr pair) (+ (car pair) (cadr pair)))) + +(define (prime-sum-pairs n) + (map make-pair-sum + (filter prime-sum? + (flatmap + (lambda (i) + (map (lambda (j) (list i j)) + (enumerate-interval 1 (- i 1)))) + (enumerate-interval 1 n))))) + + +(define (permutations s) + (if (null? s) ; empty set? + (list nil) ; sequence containing empty set + (flatmap (lambda (x) + (map (lambda (p) (cons x p)) + (permutations (remove x s)))) + s))) + +(define (remove item sequence) + (filter (lambda (x) (not (= x item))) + sequence)) + + +;; EXERCISE 2.42 +(define (queens board-size) + (define (queen-cols k) + (if (= k 0) + (list empty-board) + (filter + (lambda (positions) (safe? k positions)) + (flatmap + (lambda (rest-of-queens) + (map (lambda (new-row) + (adjoin-position new-row k rest-of-queens)) + (enumerate-interval 1 board-size))) + (queen-cols (- k 1)))))) + (queen-cols board-size)) + +;; EXERCISE 2.43 +;; Louis's version of queens +(define (queens board-size) + (define (queen-cols k) + (if (= k 0) + (list empty-board) + (filter + (lambda (positions) (safe? k positions)) + ;; next expression changed + (flatmap + (lambda (new-row) + (map (lambda (rest-of-queens) + (adjoin-position new-row k rest-of-queens)) + (queen-cols (- k 1)))) + (enumerate-interval 1 board-size))))) + (queen-cols board-size)) + +;;;SECTION 2.2.4 + +;: (define wave2 (beside wave (flip-vert wave))) +;: (define wave4 (below wave2 wave2)) + + +(define (flipped-pairs painter) + (let ((painter2 (beside painter (flip-vert painter)))) + (below painter2 painter2))) + + +;: (define wave4 (flipped-pairs wave)) + + +(define (right-split painter n) + (if (= n 0) + painter + (let ((smaller (right-split painter (- n 1)))) + (beside painter (below smaller smaller))))) + + +(define (corner-split painter n) + (if (= n 0) + painter + (let ((up (up-split painter (- n 1))) + (right (right-split painter (- n 1)))) + (let ((top-left (beside up up)) + (bottom-right (below right right)) + (corner (corner-split painter (- n 1)))) + (beside (below painter top-left) + (below bottom-right corner)))))) + + +(define (square-limit painter n) + (let ((quarter (corner-split painter n))) + (let ((half (beside (flip-horiz quarter) quarter))) + (below (flip-vert half) half)))) + + +;; Higher-order operations + +(define (square-of-four tl tr bl br) + (lambda (painter) + (let ((top (beside (tl painter) (tr painter))) + (bottom (beside (bl painter) (br painter)))) + (below bottom top)))) + + +(define (flipped-pairs painter) + (let ((combine4 (square-of-four identity flip-vert + identity flip-vert))) + (combine4 painter))) + +; footnote +;: (define flipped-pairs +;: (square-of-four identity flip-vert identity flip-vert)) + + +(define (square-limit painter n) + (let ((combine4 (square-of-four flip-horiz identity + rotate180 flip-vert))) + (combine4 (corner-split painter n)))) + + +;; EXERCISE 2.45 + +;: (define right-split (split beside below)) +;: (define up-split (split below beside)) + + +;; Frames + +(define (frame-coord-map frame) + (lambda (v) + (add-vect + (origin-frame frame) + (add-vect (scale-vect (xcor-vect v) + (edge1-frame frame)) + (scale-vect (ycor-vect v) + (edge2-frame frame)))))) + + +;: ((frame-coord-map a-frame) (make-vect 0 0)) + +;: (origin-frame a-frame) + + +;; EXERCISE 2.47 + +(define (make-frame origin edge1 edge2) + (list origin edge1 edge2)) + +(define (make-frame origin edge1 edge2) + (cons origin (cons edge1 edge2))) + + +;; Painters + +(define (segments->painter segment-list) + (lambda (frame) + (for-each + (lambda (segment) + (draw-line + ((frame-coord-map frame) (start-segment segment)) + ((frame-coord-map frame) (end-segment segment)))) + segment-list))) + + +(define (transform-painter painter origin corner1 corner2) + (lambda (frame) + (let ((m (frame-coord-map frame))) + (let ((new-origin (m origin))) + (painter + (make-frame new-origin + (sub-vect (m corner1) new-origin) + (sub-vect (m corner2) new-origin))))))) + + +(define (flip-vert painter) + (transform-painter painter + (make-vect 0.0 1.0) ; new origin + (make-vect 1.0 1.0) ; new end of edge1 + (make-vect 0.0 0.0))) ; new end of edge2 + + +(define (shrink-to-upper-right painter) + (transform-painter painter + (make-vect 0.5 0.5) + (make-vect 1.0 0.5) + (make-vect 0.5 1.0))) + + +(define (rotate90 painter) + (transform-painter painter + (make-vect 1.0 0.0) + (make-vect 1.0 1.0) + (make-vect 0.0 0.0))) + + +(define (squash-inwards painter) + (transform-painter painter + (make-vect 0.0 0.0) + (make-vect 0.65 0.35) + (make-vect 0.35 0.65))) + + +(define (beside painter1 painter2) + (let ((split-point (make-vect 0.5 0.0))) + (let ((paint-left + (transform-painter painter1 + (make-vect 0.0 0.0) + split-point + (make-vect 0.0 1.0))) + (paint-right + (transform-painter painter2 + split-point + (make-vect 1.0 0.0) + (make-vect 0.5 1.0)))) + (lambda (frame) + (paint-left frame) + (paint-right frame))))) + +;;;SECTION 2.3.1 + +;: (a b c d) +;: (23 45 17) +;: ((Norah 12) (Molly 9) (Anna 7) (Lauren 6) (Charlotte 3)) + +;: (* (+ 23 45) (+ x 9)) + +(define (fact n) (if (= n 1) 1 (* n (fact (- n 1))))) + + +;: (define a 1) +;: (define b 2) +;: (list a b) +;: (list 'a 'b) +;: (list 'a b) + +;: (car '(a b c)) +;: (cdr '(a b c)) + + +(define (memq item x) + (cond ((null? x) false) + ((eq? item (car x)) x) + (else (memq item (cdr x))))) + +;: (memq 'apple '(pear banana prune)) +;: (memq 'apple '(x (apple sauce) y apple pear)) + + +;; EXERCISE 2.53 +;: (list 'a 'b 'c) +;: +;: (list (list 'george)) +;: +;: (cdr '((x1 x2) (y1 y2))) +;: +;: (cadr '((x1 x2) (y1 y2))) +;: +;: (pair? (car '(a short list))) +;: +;: (memq 'red '((red shoes) (blue socks))) +;: +;: (memq 'red '(red shoes blue socks)) + + +;; EXERCISE 2.54 +;: (equal? '(this is a list) '(this is a list)) +;: (equal? '(this is a list) '(this (is a) list)) + +;; EXERCISE 2.55 +;: (car ''abracadabra) + + +;;;SECTION 2.3.2 + +(define (deriv exp var) + (cond ((number? exp) 0) + ((variable? exp) + (if (same-variable? exp var) 1 0)) + ((sum? exp) + (make-sum (deriv (addend exp) var) + (deriv (augend exp) var))) + ((product? exp) + (make-sum + (make-product (multiplier exp) + (deriv (multiplicand exp) var)) + (make-product (deriv (multiplier exp) var) + (multiplicand exp)))) + (else + (error "unknown expression type -- DERIV" exp)))) + +;; representing algebraic expressions + +(define (variable? x) (symbol? x)) + +(define (same-variable? v1 v2) + (and (variable? v1) (variable? v2) (eq? v1 v2))) + +(define (make-sum a1 a2) (list '+ a1 a2)) + +(define (make-product m1 m2) (list '* m1 m2)) + +(define (sum? x) + (and (pair? x) (eq? (car x) '+))) + +(define (addend s) (cadr s)) + +(define (augend s) (caddr s)) + +(define (product? x) + (and (pair? x) (eq? (car x) '*))) + +(define (multiplier p) (cadr p)) + +(define (multiplicand p) (caddr p)) + + +;: (deriv '(+ x 3) 'x) +;: (deriv '(* x y) 'x) +;: (deriv '(* (* x y) (+ x 3)) 'x) + + +;; With simplification + +(define (make-sum a1 a2) + (cond ((=number? a1 0) a2) + ((=number? a2 0) a1) + ((and (number? a1) (number? a2)) (+ a1 a2)) + (else (list '+ a1 a2)))) + +(define (=number? exp num) + (and (number? exp) (= exp num))) + +(define (make-product m1 m2) + (cond ((or (=number? m1 0) (=number? m2 0)) 0) + ((=number? m1 1) m2) + ((=number? m2 1) m1) + ((and (number? m1) (number? m2)) (* m1 m2)) + (else (list '* m1 m2)))) + + +;: (deriv '(+ x 3) 'x) +;: (deriv '(* x y) 'x) +;: (deriv '(* (* x y) (+ x 3)) 'x) + + +;; EXERCISE 2.57 +;: (deriv '(* x y (+ x 3)) 'x) + + +;;;SECTION 2.3.3 + +;; UNORDERED + +(define (element-of-set? x set) + (cond ((null? set) false) + ((equal? x (car set)) true) + (else (element-of-set? x (cdr set))))) + +(define (adjoin-set x set) + (if (element-of-set? x set) + set + (cons x set))) + +(define (intersection-set set1 set2) + (cond ((or (null? set1) (null? set2)) '()) + ((element-of-set? (car set1) set2) + (cons (car set1) + (intersection-set (cdr set1) set2))) + (else (intersection-set (cdr set1) set2)))) + + +;; ORDERED + +(define (element-of-set? x set) + (cond ((null? set) false) + ((= x (car set)) true) + ((< x (car set)) false) + (else (element-of-set? x (cdr set))))) + +(define (intersection-set set1 set2) + (if (or (null? set1) (null? set2)) + '() + (let ((x1 (car set1)) (x2 (car set2))) + (cond ((= x1 x2) + (cons x1 + (intersection-set (cdr set1) + (cdr set2)))) + ((< x1 x2) + (intersection-set (cdr set1) set2)) + ((< x2 x1) + (intersection-set set1 (cdr set2))))))) + +;; BINARY TREES +(define (entry tree) (car tree)) + +(define (left-branch tree) (cadr tree)) + +(define (right-branch tree) (caddr tree)) + +(define (make-tree entry left right) + (list entry left right)) + +(define (element-of-set? x set) + (cond ((null? set) false) + ((= x (entry set)) true) + ((< x (entry set)) + (element-of-set? x (left-branch set))) + ((> x (entry set)) + (element-of-set? x (right-branch set))))) + +(define (adjoin-set x set) + (cond ((null? set) (make-tree x '() '())) + ((= x (entry set)) set) + ((< x (entry set)) + (make-tree (entry set) + (adjoin-set x (left-branch set)) + (right-branch set))) + ((> x (entry set)) + (make-tree (entry set) + (left-branch set) + (adjoin-set x (right-branch set)))))) + + +;; EXERCISE 2.63 +(define (tree->list-1 tree) + (if (null? tree) + '() + (append (tree->list-1 (left-branch tree)) + (cons (entry tree) + (tree->list-1 (right-branch tree)))))) + +(define (tree->list-2 tree) + (define (copy-to-list tree result-list) + (if (null? tree) + result-list + (copy-to-list (left-branch tree) + (cons (entry tree) + (copy-to-list (right-branch tree) + result-list))))) + (copy-to-list tree '())) + + +;; EXERCISE 2.64 + +(define (list->tree elements) + (car (partial-tree elements (length elements)))) + +(define (partial-tree elts n) + (if (= n 0) + (cons '() elts) + (let ((left-size (quotient (- n 1) 2))) + (let ((left-result (partial-tree elts left-size))) + (let ((left-tree (car left-result)) + (non-left-elts (cdr left-result)) + (right-size (- n (+ left-size 1)))) + (let ((this-entry (car non-left-elts)) + (right-result (partial-tree (cdr non-left-elts) + right-size))) + (let ((right-tree (car right-result)) + (remaining-elts (cdr right-result))) + (cons (make-tree this-entry left-tree right-tree) + remaining-elts)))))))) + +;; INFORMATION RETRIEVAL + +(define (lookup given-key set-of-records) + (cond ((null? set-of-records) false) + ((equal? given-key (key (car set-of-records))) + (car set-of-records)) + (else (lookup given-key (cdr set-of-records))))) + + +;;;SECTION 2.3.3 + +;; representing + +(define (make-leaf symbol weight) + (list 'leaf symbol weight)) + +(define (leaf? object) + (eq? (car object) 'leaf)) + +(define (symbol-leaf x) (cadr x)) + +(define (weight-leaf x) (caddr x)) + +(define (make-code-tree left right) + (list left + right + (append (symbols left) (symbols right)) + (+ (weight left) (weight right)))) + +(define (left-branch tree) (car tree)) + +(define (right-branch tree) (cadr tree)) + +(define (symbols tree) + (if (leaf? tree) + (list (symbol-leaf tree)) + (caddr tree))) + +(define (weight tree) + (if (leaf? tree) + (weight-leaf tree) + (cadddr tree))) + +;; decoding +(define (decode bits tree) + (define (decode-1 bits current-branch) + (if (null? bits) + '() + (let ((next-branch + (choose-branch (car bits) current-branch))) + (if (leaf? next-branch) + (cons (symbol-leaf next-branch) + (decode-1 (cdr bits) tree)) + (decode-1 (cdr bits) next-branch))))) + (decode-1 bits tree)) + +(define (choose-branch bit branch) + (cond ((= bit 0) (left-branch branch)) + ((= bit 1) (right-branch branch)) + (else (error "bad bit -- CHOOSE-BRANCH" bit)))) + +;; sets + +(define (adjoin-set x set) + (cond ((null? set) (list x)) + ((< (weight x) (weight (car set))) (cons x set)) + (else (cons (car set) + (adjoin-set x (cdr set)))))) + +(define (make-leaf-set pairs) + (if (null? pairs) + '() + (let ((pair (car pairs))) + (adjoin-set (make-leaf (car pair) + (cadr pair)) + (make-leaf-set (cdr pairs)))))) + + +;; EXERCISE 2.67 + +;: (define sample-tree +;: (make-code-tree (make-leaf 'A 4) +;: (make-code-tree +;: (make-leaf 'B 2) +;: (make-code-tree (make-leaf 'D 1) +;: (make-leaf 'C 1))))) + +;: (define sample-message '(0 1 1 0 0 1 0 1 0 1 1 1 0)) + + +;; EXERCISE 2.68 + +(define (encode message tree) + (if (null? message) + '() + (append (encode-symbol (car message) tree) + (encode (cdr message) tree)))) + +;; EXERCISE 2.69 + +(define (generate-huffman-tree pairs) + (successive-merge (make-leaf-set pairs))) + +;;;SECTION 2.4.1 + +;: (make-from-real-imag (real-part z) (imag-part z)) + +;: (make-from-mag-ang (magnitude z) (angle z)) + +(define (add-complex z1 z2) + (make-from-real-imag (+ (real-part z1) (real-part z2)) + (+ (imag-part z1) (imag-part z2)))) + +(define (sub-complex z1 z2) + (make-from-real-imag (- (real-part z1) (real-part z2)) + (- (imag-part z1) (imag-part z2)))) + +(define (mul-complex z1 z2) + (make-from-mag-ang (* (magnitude z1) (magnitude z2)) + (+ (angle z1) (angle z2)))) + +(define (div-complex z1 z2) + (make-from-mag-ang (/ (magnitude z1) (magnitude z2)) + (- (angle z1) (angle z2)))) + + +;; Ben (rectangular) + +(define (real-part z) (car z)) + +(define (imag-part z) (cdr z)) + +(define (magnitude z) + (sqrt (+ (square (real-part z)) (square (imag-part z))))) + +(define (angle z) + (atan (imag-part z) (real-part z))) + +(define (make-from-real-imag x y) (cons x y)) + +(define (make-from-mag-ang r a) + (cons (* r (cos a)) (* r (sin a)))) + + +;; Alyssa (polar) + +(define (real-part z) + (* (magnitude z) (cos (angle z)))) + +(define (imag-part z) + (* (magnitude z) (sin (angle z)))) + +(define (magnitude z) (car z)) + +(define (angle z) (cdr z)) + +(define (make-from-real-imag x y) + (cons (sqrt (+ (square x) (square y))) + (atan y x))) + +(define (make-from-mag-ang r a) (cons r a)) + + +;;;SECTION 2.4.2 + +(define (attach-tag type-tag contents) + (cons type-tag contents)) + +(define (type-tag datum) + (if (pair? datum) + (car datum) + (error "Bad tagged datum -- TYPE-TAG" datum))) + +(define (contents datum) + (if (pair? datum) + (cdr datum) + (error "Bad tagged datum -- CONTENTS" datum))) + +(define (rectangular? z) + (eq? (type-tag z) 'rectangular)) + +(define (polar? z) + (eq? (type-tag z) 'polar)) + + +;; Ben (rectangular) + +(define (real-part-rectangular z) (car z)) + +(define (imag-part-rectangular z) (cdr z)) + +(define (magnitude-rectangular z) + (sqrt (+ (square (real-part-rectangular z)) + (square (imag-part-rectangular z))))) + +(define (angle-rectangular z) + (atan (imag-part-rectangular z) + (real-part-rectangular z))) + +(define (make-from-real-imag-rectangular x y) + (attach-tag 'rectangular (cons x y))) + +(define (make-from-mag-ang-rectangular r a) + (attach-tag 'rectangular + (cons (* r (cos a)) (* r (sin a))))) + +;; Alyssa (polar) + +(define (real-part-polar z) + (* (magnitude-polar z) (cos (angle-polar z)))) + +(define (imag-part-polar z) + (* (magnitude-polar z) (sin (angle-polar z)))) + +(define (magnitude-polar z) (car z)) + +(define (angle-polar z) (cdr z)) + +(define (make-from-real-imag-polar x y) + (attach-tag 'polar + (cons (sqrt (+ (square x) (square y))) + (atan y x)))) + +(define (make-from-mag-ang-polar r a) + (attach-tag 'polar (cons r a))) + + +;; Generic selectors + +(define (real-part z) + (cond ((rectangular? z) + (real-part-rectangular (contents z))) + ((polar? z) + (real-part-polar (contents z))) + (else (error "Unknown type -- REAL-PART" z)))) + +(define (imag-part z) + (cond ((rectangular? z) + (imag-part-rectangular (contents z))) + ((polar? z) + (imag-part-polar (contents z))) + (else (error "Unknown type -- IMAG-PART" z)))) + +(define (magnitude z) + (cond ((rectangular? z) + (magnitude-rectangular (contents z))) + ((polar? z) + (magnitude-polar (contents z))) + (else (error "Unknown type -- MAGNITUDE" z)))) + +(define (angle z) + (cond ((rectangular? z) + (angle-rectangular (contents z))) + ((polar? z) + (angle-polar (contents z))) + (else (error "Unknown type -- ANGLE" z)))) + +;; same as before +(define (add-complex z1 z2) + (make-from-real-imag (+ (real-part z1) (real-part z2)) + (+ (imag-part z1) (imag-part z2)))) + +;; Constructors for complex numbers + +(define (make-from-real-imag x y) + (make-from-real-imag-rectangular x y)) + +(define (make-from-mag-ang r a) + (make-from-mag-ang-polar r a)) + +;;;SECTION 2.4.3 + +;; uses get/put (from 3.3.3) -- see ch2support.scm + +(define (install-rectangular-package) + ;; internal procedures + (define (real-part z) (car z)) + (define (imag-part z) (cdr z)) + (define (make-from-real-imag x y) (cons x y)) + (define (magnitude z) + (sqrt (+ (square (real-part z)) + (square (imag-part z))))) + (define (angle z) + (atan (imag-part z) (real-part z))) + (define (make-from-mag-ang r a) + (cons (* r (cos a)) (* r (sin a)))) + + ;; interface to the rest of the system + (define (tag x) (attach-tag 'rectangular x)) + (put 'real-part '(rectangular) real-part) + (put 'imag-part '(rectangular) imag-part) + (put 'magnitude '(rectangular) magnitude) + (put 'angle '(rectangular) angle) + (put 'make-from-real-imag 'rectangular + (lambda (x y) (tag (make-from-real-imag x y)))) + (put 'make-from-mag-ang 'rectangular + (lambda (r a) (tag (make-from-mag-ang r a)))) + 'done) + +(define (install-polar-package) + ;; internal procedures + (define (magnitude z) (car z)) + (define (angle z) (cdr z)) + (define (make-from-mag-ang r a) (cons r a)) + (define (real-part z) + (* (magnitude z) (cos (angle z)))) + (define (imag-part z) + (* (magnitude z) (sin (angle z)))) + (define (make-from-real-imag x y) + (cons (sqrt (+ (square x) (square y))) + (atan y x))) + + ;; interface to the rest of the system + (define (tag x) (attach-tag 'polar x)) + (put 'real-part '(polar) real-part) + (put 'imag-part '(polar) imag-part) + (put 'magnitude '(polar) magnitude) + (put 'angle '(polar) angle) + (put 'make-from-real-imag 'polar + (lambda (x y) (tag (make-from-real-imag x y)))) + (put 'make-from-mag-ang 'polar + (lambda (r a) (tag (make-from-mag-ang r a)))) + 'done) + +;;footnote +;: (apply + (list 1 2 3 4)) + + +(define (apply-generic op . args) + (let ((type-tags (map type-tag args))) + (let ((proc (get op type-tags))) + (if proc + (apply proc (map contents args)) + (error + "No method for these types -- APPLY-GENERIC" + (list op type-tags)))))) + +;; Generic selectors + +(define (real-part z) (apply-generic 'real-part z)) +(define (imag-part z) (apply-generic 'imag-part z)) +(define (magnitude z) (apply-generic 'magnitude z)) +(define (angle z) (apply-generic 'angle z)) + + +;; Constructors for complex numbers + +(define (make-from-real-imag x y) + ((get 'make-from-real-imag 'rectangular) x y)) + +(define (make-from-mag-ang r a) + ((get 'make-from-mag-ang 'polar) r a)) + + + +;; EXERCISE 2.73 +(define (deriv exp var) + (cond ((number? exp) 0) + ((variable? exp) (if (same-variable? exp var) 1 0)) + ((sum? exp) + (make-sum (deriv (addend exp) var) + (deriv (augend exp) var))) + ((product? exp) + (make-sum + (make-product (multiplier exp) + (deriv (multiplicand exp) var)) + (make-product (deriv (multiplier exp) var) + (multiplicand exp)))) + (else (error "unknown expression type -- DERIV" exp)))) + + +(define (deriv exp var) + (cond ((number? exp) 0) + ((variable? exp) (if (same-variable? exp var) 1 0)) + (else ((get 'deriv (operator exp)) (operands exp) + var)))) + +(define (operator exp) (car exp)) + +(define (operands exp) (cdr exp)) + +;: ((get (operator exp) 'deriv) (operands exp) var) + + +;; Message passing +(define (make-from-real-imag x y) + (define (dispatch op) + (cond ((eq? op 'real-part) x) + ((eq? op 'imag-part) y) + ((eq? op 'magnitude) + (sqrt (+ (square x) (square y)))) + ((eq? op 'angle) (atan y x)) + (else + (error "Unknown op -- MAKE-FROM-REAL-IMAG" op)))) + dispatch) + +(define (apply-generic op arg) (arg op)) + +;;;SECTION 2.5.1 + +(define (add x y) (apply-generic 'add x y)) +(define (sub x y) (apply-generic 'sub x y)) +(define (mul x y) (apply-generic 'mul x y)) +(define (div x y) (apply-generic 'div x y)) + +(define (install-scheme-number-package) + (define (tag x) + (attach-tag 'scheme-number x)) + (put 'add '(scheme-number scheme-number) + (lambda (x y) (tag (+ x y)))) + (put 'sub '(scheme-number scheme-number) + (lambda (x y) (tag (- x y)))) + (put 'mul '(scheme-number scheme-number) + (lambda (x y) (tag (* x y)))) + (put 'div '(scheme-number scheme-number) + (lambda (x y) (tag (/ x y)))) + (put 'make 'scheme-number + (lambda (x) (tag x))) + 'done) + +(define (make-scheme-number n) + ((get 'make 'scheme-number) n)) + +(define (install-rational-package) + ;; internal procedures + (define (numer x) (car x)) + (define (denom x) (cdr x)) + (define (make-rat n d) + (let ((g (gcd n d))) + (cons (/ n g) (/ d g)))) + (define (add-rat x y) + (make-rat (+ (* (numer x) (denom y)) + (* (numer y) (denom x))) + (* (denom x) (denom y)))) + (define (sub-rat x y) + (make-rat (- (* (numer x) (denom y)) + (* (numer y) (denom x))) + (* (denom x) (denom y)))) + (define (mul-rat x y) + (make-rat (* (numer x) (numer y)) + (* (denom x) (denom y)))) + (define (div-rat x y) + (make-rat (* (numer x) (denom y)) + (* (denom x) (numer y)))) + ;; interface to rest of the system + (define (tag x) (attach-tag 'rational x)) + (put 'add '(rational rational) + (lambda (x y) (tag (add-rat x y)))) + (put 'sub '(rational rational) + (lambda (x y) (tag (sub-rat x y)))) + (put 'mul '(rational rational) + (lambda (x y) (tag (mul-rat x y)))) + (put 'div '(rational rational) + (lambda (x y) (tag (div-rat x y)))) + + (put 'make 'rational + (lambda (n d) (tag (make-rat n d)))) + 'done) + +(define (make-rational n d) + ((get 'make 'rational) n d)) + +(define (install-complex-package) + ;; imported procedures from rectangular and polar packages + (define (make-from-real-imag x y) + ((get 'make-from-real-imag 'rectangular) x y)) + (define (make-from-mag-ang r a) + ((get 'make-from-mag-ang 'polar) r a)) + ;; internal procedures + (define (add-complex z1 z2) + (make-from-real-imag (+ (real-part z1) (real-part z2)) + (+ (imag-part z1) (imag-part z2)))) + (define (sub-complex z1 z2) + (make-from-real-imag (- (real-part z1) (real-part z2)) + (- (imag-part z1) (imag-part z2)))) + (define (mul-complex z1 z2) + (make-from-mag-ang (* (magnitude z1) (magnitude z2)) + (+ (angle z1) (angle z2)))) + (define (div-complex z1 z2) + (make-from-mag-ang (/ (magnitude z1) (magnitude z2)) + (- (angle z1) (angle z2)))) + + ;; interface to rest of the system + (define (tag z) (attach-tag 'complex z)) + (put 'add '(complex complex) + (lambda (z1 z2) (tag (add-complex z1 z2)))) + (put 'sub '(complex complex) + (lambda (z1 z2) (tag (sub-complex z1 z2)))) + (put 'mul '(complex complex) + (lambda (z1 z2) (tag (mul-complex z1 z2)))) + (put 'div '(complex complex) + (lambda (z1 z2) (tag (div-complex z1 z2)))) + (put 'make-from-real-imag 'complex + (lambda (x y) (tag (make-from-real-imag x y)))) + (put 'make-from-mag-ang 'complex + (lambda (r a) (tag (make-from-mag-ang r a)))) + 'done) + +(define (make-complex-from-real-imag x y) + ((get 'make-from-real-imag 'complex) x y)) + +(define (make-complex-from-mag-ang r a) + ((get 'make-from-mag-ang 'complex) r a)) + + +;; EXERCISE 2.77 +;; to put in complex package + +;: (put 'real-part '(complex) real-part) +;: (put 'imag-part '(complex) imag-part) +;: (put 'magnitude '(complex) magnitude) +;: (put 'angle '(complex) angle) + + +;;;SECTION 2.5.2 + +;; to be included in the complex package +;: (define (add-complex-to-schemenum z x) +;: (make-from-real-imag (+ (real-part z) x) +;: (imag-part z))) +;: +;: (put 'add '(complex scheme-number) +;: (lambda (z x) (tag (add-complex-to-schemenum z x)))) + + +;; Coercion + +(define (scheme-number->complex n) + (make-complex-from-real-imag (contents n) 0)) + +;: (put-coercion 'scheme-number 'complex scheme-number->complex) + + +(define (apply-generic op . args) + (let ((type-tags (map type-tag args))) + (let ((proc (get op type-tags))) + (if proc + (apply proc (map contents args)) + (if (= (length args) 2) + (let ((type1 (car type-tags)) + (type2 (cadr type-tags)) + (a1 (car args)) + (a2 (cadr args))) + (let ((t1->t2 (get-coercion type1 type2)) + (t2->t1 (get-coercion type2 type1))) + (cond (t1->t2 + (apply-generic op (t1->t2 a1) a2)) + (t2->t1 + (apply-generic op a1 (t2->t1 a2))) + (else + (error "No method for these types" + (list op type-tags)))))) + (error "No method for these types" + (list op type-tags))))))) + +;; EXERCISE 2.81 + +(define (scheme-number->scheme-number n) n) +(define (complex->complex z) z) +;: (put-coercion 'scheme-number 'scheme-number +;: scheme-number->scheme-number) +;: (put-coercion 'complex 'complex complex->complex) + +(define (exp x y) (apply-generic 'exp x y)) +;: (put 'exp '(scheme-number scheme-number) +;: (lambda (x y) (tag (expt x y)))) + +;;;SECTION 2.5.3 + +;;; ALL procedures in 2.5.3 except make-polynomial +;;; should be inserted in install-polynomial-package, as indicated + +(define (add-poly p1 p2) + (if (same-variable? (variable p1) (variable p2)) + (make-poly (variable p1) + (add-terms (term-list p1) + (term-list p2))) + (error "Polys not in same var -- ADD-POLY" + (list p1 p2)))) + +(define (mul-poly p1 p2) + (if (same-variable? (variable p1) (variable p2)) + (make-poly (variable p1) + (mul-terms (term-list p1) + (term-list p2))) + (error "Polys not in same var -- MUL-POLY" + (list p1 p2)))) + +;; *incomplete* skeleton of package +(define (install-polynomial-package) + ;; internal procedures + ;; representation of poly + (define (make-poly variable term-list) + (cons variable term-list)) + (define (variable p) (car p)) + (define (term-list p) (cdr p)) + ;;[procedures same-variable? and variable? from section 2.3.2] + + ;; representation of terms and term lists + ;;[procedures adjoin-term ... coeff from text below] + + ;;(define (add-poly p1 p2) ... ) + ;;[procedures used by add-poly] + + ;;(define (mul-poly p1 p2) ... ) + ;;[procedures used by mul-poly] + + ;; interface to rest of the system + (define (tag p) (attach-tag 'polynomial p)) + (put 'add '(polynomial polynomial) + (lambda (p1 p2) (tag (add-poly p1 p2)))) + (put 'mul '(polynomial polynomial) + (lambda (p1 p2) (tag (mul-poly p1 p2)))) + + (put 'make 'polynomial + (lambda (var terms) (tag (make-poly var terms)))) + 'done) + +(define (add-terms L1 L2) + (cond ((empty-termlist? L1) L2) + ((empty-termlist? L2) L1) + (else + (let ((t1 (first-term L1)) (t2 (first-term L2))) + (cond ((> (order t1) (order t2)) + (adjoin-term + t1 (add-terms (rest-terms L1) L2))) + ((< (order t1) (order t2)) + (adjoin-term + t2 (add-terms L1 (rest-terms L2)))) + (else + (adjoin-term + (make-term (order t1) + (add (coeff t1) (coeff t2))) + (add-terms (rest-terms L1) + (rest-terms L2))))))))) + +(define (mul-terms L1 L2) + (if (empty-termlist? L1) + (the-empty-termlist) + (add-terms (mul-term-by-all-terms (first-term L1) L2) + (mul-terms (rest-terms L1) L2)))) + +(define (mul-term-by-all-terms t1 L) + (if (empty-termlist? L) + (the-empty-termlist) + (let ((t2 (first-term L))) + (adjoin-term + (make-term (+ (order t1) (order t2)) + (mul (coeff t1) (coeff t2))) + (mul-term-by-all-terms t1 (rest-terms L)))))) + + +;; Representing term lists + +(define (adjoin-term term term-list) + (if (=zero? (coeff term)) + term-list + (cons term term-list))) + +(define (the-empty-termlist) '()) +(define (first-term term-list) (car term-list)) +(define (rest-terms term-list) (cdr term-list)) +(define (empty-termlist? term-list) (null? term-list)) + +(define (make-term order coeff) (list order coeff)) +(define (order term) (car term)) +(define (coeff term) (cadr term)) + + +;; Constructor +(define (make-polynomial var terms) + ((get 'make 'polynomial) var terms)) + + +;; EXERCISE 2.91 + +(define (div-terms L1 L2) + (if (empty-termlist? L1) + (list (the-empty-termlist) (the-empty-termlist)) + (let ((t1 (first-term L1)) + (t2 (first-term L2))) + (if (> (order t2) (order t1)) + (list (the-empty-termlist) L1) + (let ((new-c (div (coeff t1) (coeff t2))) + (new-o (- (order t1) (order t2)))) + (let ((rest-of-result + ??FILL-THIS-IN?? ;compute rest of result recursively + )) + ??FILL-THIS-IN?? ;form complete result + )))))) + + +;; EXERCISE 2.93 +;: (define p1 (make-polynomial 'x '((2 1)(0 1)))) +;: (define p2 (make-polynomial 'x '((3 1)(0 1)))) +;: (define rf (make-rational p2 p1)) + + +;; Rational functions + +(define (gcd a b) + (if (= b 0) + a + (gcd b (remainder a b)))) + +(define (gcd-terms a b) + (if (empty-termlist? b) + a + (gcd-terms b (remainder-terms a b)))) + + +;; EXERCISE 2.94 +;: (define p1 (make-polynomial 'x '((4 1) (3 -1) (2 -2) (1 2)))) +;: (define p2 (make-polynomial 'x '((3 1) (1 -1)))) +;: (greatest-common-divisor p1 p2) + + +;; EXERCISE 2.97 + +(define (reduce-integers n d) + (let ((g (gcd n d))) + (list (/ n g) (/ d g)))) + +;: (define p1 (make-polynomial 'x '((1 1)(0 1)))) +;: (define p2 (make-polynomial 'x '((3 1)(0 -1)))) +;: (define p3 (make-polynomial 'x '((1 1)))) +;: (define p4 (make-polynomial 'x '((2 1)(0 -1)))) + +;: (define rf1 (make-rational p1 p2)) +;: (define rf2 (make-rational p3 p4)) + +;: (add rf1 rf2) + +; -----***CH2TESTS.SCM*** +;;; EXAMPLES OF TESTING CODE (IN MIT SCHEME) +;;; FROM CHAPTER 2 OF STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS + + +;;;SECTION 2.4.1 + +;; Ben's rectangular + +(define z1 (make-from-real-imag 1 1)) +;Value: z1 + +(real-part z1) +;Value: 1 +(imag-part z1) +;Value: 1 +(magnitude z1) +;Value: 1.4142135623730951 +(angle z1) +;Value: .7853981633974483 +(* 4 (angle z1)) +;Value: 3.141592653589793 +(define z2 (make-from-mag-ang 1.4142135623730951 .7853981633974483)) +;Value: z2 + +(real-part z2) +;Value: 1. +(imag-part z2) +;Value: 1. + +z1 +;Value 10: (1 . 1) + +z2 +;Value 14: (1. . 1.) + +(add-complex z1 z2) +;Value 16: (2. . 2.) + +(sub-complex z1 z2) +;Value 17: (0. . 0.) + + +;; Alyssa's polar + +(define z1 (make-from-real-imag 1 1)) +;Value: z1 + +(real-part z1) +;Value: 1. + +(imag-part z1) +;Value: 1. + +(magnitude z1) +;Value: 1.4142135623730951 + +(angle z1) +;Value: .7853981633974483 + +(* 4 (angle z1)) +;Value: 3.141592653589793 + +(define z2 (make-from-mag-ang 1.4142135623730951 .7853981633974483)) +;Value: z2 + +(real-part z2) +;Value: 1. + +(imag-part z2) +;Value: 1. + +z1 +;Value 12: (1.4142135623730951 . .7853981633974483) + +z2 +;Value 13: (1.4142135623730951 . .7853981633974483) + +(mul-complex z1 z2) +;Value 18: (2.0000000000000004 . 1.5707963267948966) + +(div-complex z1 z2) +;Value 19: (1. . 0.) + +;;;SECTION 2.4.2 + +(define z1 (make-from-real-imag 1 1)) +;Value: z1 + +z1 +;Value 20: (rectangular 1 . 1) +(real-part z1) +;Value: 1 +(imag-part z1) +;Value: 1 +(magnitude z1) +;Value: 1.4142135623730951 +(angle z1) +;Value: .7853981633974483 + +(define z2 (make-from-mag-ang 1.4142135623730951 .7853981633974483)) +;Value: z2 + +z2 +;Value 22: (polar 1.4142135623730951 . .7853981633974483) + +(magnitude z2) +;Value: 1.4142135623730951 +(angle z2) +;Value: .7853981633974483 +(real-part z2) +;Value: 1. +(imag-part z2) +;Value: 1. + +z1 +;Value 20: (rectangular 1 . 1) +z2 +;Value 22: (polar 1.4142135623730951 . .7853981633974483) + +(add-complex z1 z2) +;Value 23: (rectangular 2. . 2.) +(sub-complex z1 z2) +;Value 24: (rectangular 0. . 0.) +(mul-complex z1 z2) +;Value 25: (polar 2.0000000000000004 . 1.5707963267948966) +(div-complex z1 z2) +;Value 26: (polar 1. . 0.) + +;;;SECTION 2.5.2 + +(define z1 (make-complex-from-real-imag 1 1)) + +;; Before coercion mechanism + +(add z1 (make-scheme-number 3)) +;Value 1: (complex rectangular 4 . 1) + +(add (make-scheme-number 3) z1) +;No method for the given types (add (scheme-number complex)) + + +;; With coercion mechanism + +(add z1 (make-scheme-number 3)) +;Value 6: (complex rectangular 4 . 1) + +(add (make-scheme-number 3) z1) +;Value 7: (complex rectangular 4 . 1) + +;;;SECTION 2.5.3 + +(define a (make-polynomial 'x '((5 1) (4 2) (2 3) (1 -2) (0 -5)))) + +a +;Value 3: (polynomial x (5 1) (4 2) (2 3) (1 -2) (0 -5)) + +(add a a) +;Value 4: (polynomial x (5 2) (4 4) (2 6) (1 -4) (0 -10)) + +(define b (make-polynomial 'x '((100 1) (2 2) (0 1)))) + +b +;Value 5: (polynomial x (100 1) (2 2) (0 1)) + +(mul b b) +;Value 6: (polynomial x (200 1) (102 4) (100 2) (4 4) (2 4) (0 1)) + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/chapter3.code b/js/games/nluqo.github.io/~bh/61a-pages/Lib/chapter3.code new file mode 100644 index 0000000..656fff4 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/chapter3.code @@ -0,0 +1,1707 @@ +;;;;CODE FROM CHAPTER 3 OF STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS + +;;; Examples from the book are commented out with ;: so that they +;;; are easy to find and so that they will be omitted if you evaluate a +;;; chunk of the file (programs with intervening examples) in Scheme. + +;;; BEWARE: Although the whole file can be loaded into Scheme, +;;; you won't want to do so. For example, you generally do +;;; not want to use the procedural representation of pairs +;;; (cons, car, cdr as defined in section 3.3.1) instead of +;;; Scheme's primitive pairs. + +;;; Some things require code that is not in the book -- see ch3support.scm + + +;;;;SECTION 3.1 + +;;;SECTION 3.1.1 + +;: (withdraw 25) +;: (withdraw 25) +;: (withdraw 60) +;: (withdraw 15) + +(define balance 100) + +(define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + + +(define new-withdraw + (let ((balance 100)) + (lambda (amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")))) + + +(define (make-withdraw balance) + (lambda (amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds"))) + + +;: (define W1 (make-withdraw 100)) +;: (define W2 (make-withdraw 100)) +;: (W1 50) +;: (W2 70) +;: (W2 40) +;: (W1 40) + + +(define (make-account balance) + (define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (define (dispatch m) + (cond ((eq? m 'withdraw) withdraw) + ((eq? m 'deposit) deposit) + (else (error "Unknown request -- MAKE-ACCOUNT" + m)))) + dispatch) + +;: (define acc (make-account 100)) + +;: ((acc 'withdraw) 50) +;: ((acc 'withdraw) 60) +;: ((acc 'deposit) 40) +;: ((acc 'withdraw) 60) + +;: (define acc2 (make-account 100)) + + +;; EXERCISE 3.1 +;: (define A (make-accumulator 5)) +;: (A 10) +;: (A 10) + + +;; EXERCISE 3.2 +;: (define s (make-monitored sqrt)) +;: (s 100) +;: (s 'how-many-calls?) + + +;; EXERCISE 3.3 +;: (define acc (make-account 100 'secret-password)) +;: ((acc 'secret-password 'withdraw) 40) +;: ((acc 'some-other-password 'deposit) 50) + + +;;;SECTION 3.1.2 + +;; *following uses rand-update -- see ch3support.scm +;; *also must set random-init to some value +(define random-init 7) ;**not in book** +(define rand + (let ((x random-init)) + (lambda () + (set! x (rand-update x)) + x))) + + +(define (estimate-pi trials) + (sqrt (/ 6 (monte-carlo trials cesaro-test)))) + +(define (cesaro-test) + (= (gcd (rand) (rand)) 1)) + +(define (monte-carlo trials experiment) + (define (iter trials-remaining trials-passed) + (cond ((= trials-remaining 0) + (/ trials-passed trials)) + ((experiment) + (iter (- trials-remaining 1) (+ trials-passed 1))) + (else + (iter (- trials-remaining 1) trials-passed)))) + (iter trials 0)) + +;; second version (no assignment) +(define (estimate-pi trials) + (sqrt (/ 6 (random-gcd-test trials random-init)))) + +(define (random-gcd-test trials initial-x) + (define (iter trials-remaining trials-passed x) + (let ((x1 (rand-update x))) + (let ((x2 (rand-update x1))) + (cond ((= trials-remaining 0) + (/ trials-passed trials)) + ((= (gcd x1 x2) 1) + (iter (- trials-remaining 1) + (+ trials-passed 1) + x2)) + (else + (iter (- trials-remaining 1) + trials-passed + x2)))))) + (iter trials 0 initial-x)) + + +;; EXERCISE 3.5 +(define (random-in-range low high) + (let ((range (- high low))) + (+ low (random range)))) + + +;;;SECTION 3.1.3 + +(define (make-simplified-withdraw balance) + (lambda (amount) + (set! balance (- balance amount)) + balance)) + + +;: (define W (make-simplified-withdraw 25)) +;: (W 20) +;: (W 10) + + +(define (make-decrementer balance) + (lambda (amount) + (- balance amount))) + +;: (define D (make-decrementer 25)) +;: (D 20) +;: (D 10) + +;: ((make-decrementer 25) 20) +;: ((lambda (amount) (- 25 amount)) 20) +;: (- 25 20) + +;: ((make-simplified-withdraw 25) 20) + +;: ((lambda (amount) (set! balance (- 25 amount)) 25) 20) +;: (set! balance (- 25 20)) 25 + +;;;Sameness and change + +;: (define D1 (make-decrementer 25)) +;: (define D2 (make-decrementer 25)) +;: +;: (define W1 (make-simplified-withdraw 25)) +;: (define W2 (make-simplified-withdraw 25)) +;: +;: (W1 20) +;: (W1 20) +;: (W2 20) + +;: (define peter-acc (make-account 100)) +;: (define paul-acc (make-account 100)) +;: +;: (define peter-acc (make-account 100)) +;: (define paul-acc peter-acc) + +;;;Pitfalls of imperative programming + +(define (factorial n) + (define (iter product counter) + (if (> counter n) + product + (iter (* counter product) + (+ counter 1)))) + (iter 1 1)) + +(define (factorial n) + (let ((product 1) + (counter 1)) + (define (iter) + (if (> counter n) + product + (begin (set! product (* counter product)) + (set! counter (+ counter 1)) + (iter)))) + (iter))) + + +;; EXERCISE 3.7 +;: (define paul-acc +;: (make-joint peter-acc 'open-sesame 'rosebud)) + + +;;;;SECTION 3.2 + +;;;SECTION 3.2.1 + +(define (square x) + (* x x)) + +(define square + (lambda (x) (* x x))) + + +;;;SECTION 3.2.2 + +(define (square x) + (* x x)) + +(define (sum-of-squares x y) + (+ (square x) (square y))) + +(define (f a) + (sum-of-squares (+ a 1) (* a 2))) + +;: (sum-of-squares (+ a 1) (* a 2)) + + +;; EXERCISE 3.9 + +(define (factorial n) + (if (= n 1) + 1 + (* n (factorial (- n 1))))) + +(define (factorial n) + (fact-iter 1 1 n)) + +(define (fact-iter product counter max-count) + (if (> counter max-count) + product + (fact-iter (* counter product) + (+ counter 1) + max-count))) + + +;;;SECTION 3.2.3 + +(define (make-withdraw balance) + (lambda (amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds"))) + +;: (define W1 (make-withdraw 100)) +;: (W1 50) + +;: (define W2 (make-withdraw 100)) + + +;; EXERCISE 3.10 + +(define (make-withdraw initial-amount) + (let ((balance initial-amount)) + (lambda (amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")))) + + +;: (define W1 (make-withdraw 100)) +;: (W1 50) +;: (define W2 (make-withdraw 100)) + + +;;;SECTION 3.2.4 + +;; same as in section 1.1.8 +(define (sqrt x) + (define (good-enough? guess) + (< (abs (- (square guess) x)) 0.001)) + (define (improve guess) + (average guess (/ x guess))) + (define (sqrt-iter guess) + (if (good-enough? guess) + guess + (sqrt-iter (improve guess)))) + (sqrt-iter 1.0)) + + +;; EXERCISE 3.11 + +(define (make-account balance) + (define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (define (dispatch m) + (cond ((eq? m 'withdraw) withdraw) + ((eq? m 'deposit) deposit) + (else (error "Unknown request -- MAKE-ACCOUNT" + m)))) + dispatch) + +;: (define acc (make-account 50)) +;: +;: ((acc 'deposit) 40) +;: ((acc 'withdraw) 60) +;: +;: (define acc2 (make-account 100)) + + +;;;;SECTION 3.3 + +;;;SECTION 3.3.1 + +(define (cons x y) + (let ((new (get-new-pair))) + (set-car! new x) + (set-cdr! new y) + new)) + + +;; EXERCISE 3.12 +(define (append x y) + (if (null? x) + y + (cons (car x) (append (cdr x) y)))) + +(define (append! x y) + (set-cdr! (last-pair x) y) + x) + +(define (last-pair x) + (if (null? (cdr x)) + x + (last-pair (cdr x)))) + +;: (define x (list 'a 'b)) +;: (define y (list 'c 'd)) +;: (define z (append x y)) +;: z +;: (cdr x) +;: +;: (define w (append! x y)) +;: w +;: (cdr x) + + +;; EXERCISE 3.13 +(define (make-cycle x) + (set-cdr! (last-pair x) x) + x) + +;: (define z (make-cycle (list 'a 'b 'c))) + + +;; EXERCISE 3.14 +(define (mystery x) + (define (loop x y) + (if (null? x) + y + (let ((temp (cdr x))) + (set-cdr! x y) + (loop temp x)))) + (loop x '())) + + +;;; Sharing and identity + +;: (define x (list 'a 'b)) +;: (define z1 (cons x x)) +;: (define z2 (cons (list 'a 'b) (list 'a 'b))) + +(define (set-to-wow! x) + (set-car! (car x) 'wow) + x) + +;: z1 +;: (set-to-wow! z1) +;: z2 +;: (set-to-wow! z2) + + +;; EXERCISE 3.16 +(define (count-pairs x) + (if (not (pair? x)) + 0 + (+ (count-pairs (car x)) + (count-pairs (cdr x)) + 1))) + + +;;;Mutation as assignment + +(define (cons x y) + (define (dispatch m) + (cond ((eq? m 'car) x) + ((eq? m 'cdr) y) + (else (error "Undefined operation -- CONS" m)))) + dispatch) + +(define (car z) (z 'car)) +(define (cdr z) (z 'cdr)) + + +(define (cons x y) + (define (set-x! v) (set! x v)) + (define (set-y! v) (set! y v)) + (define (dispatch m) + (cond ((eq? m 'car) x) + ((eq? m 'cdr) y) + ((eq? m 'set-car!) set-x!) + ((eq? m 'set-cdr!) set-y!) + (else (error "Undefined operation -- CONS" m)))) + dispatch) + +(define (car z) (z 'car)) +(define (cdr z) (z 'cdr)) + +(define (set-car! z new-value) + ((z 'set-car!) new-value) + z) + +(define (set-cdr! z new-value) + ((z 'set-cdr!) new-value) + z) + + +;; EXERCISE 3.20 +;: (define x (cons 1 2)) +;: (define z (cons x x)) +;: (set-car! (cdr z) 17) +;: (car x) + + +;;;SECTION 3.3.2 + +(define (front-ptr queue) (car queue)) +(define (rear-ptr queue) (cdr queue)) +(define (set-front-ptr! queue item) (set-car! queue item)) +(define (set-rear-ptr! queue item) (set-cdr! queue item)) + +(define (empty-queue? queue) (null? (front-ptr queue))) +(define (make-queue) (cons '() '())) + +(define (front-queue queue) + (if (empty-queue? queue) + (error "FRONT called with an empty queue" queue) + (car (front-ptr queue)))) + +(define (insert-queue! queue item) + (let ((new-pair (cons item '()))) + (cond ((empty-queue? queue) + (set-front-ptr! queue new-pair) + (set-rear-ptr! queue new-pair) + queue) + (else + (set-cdr! (rear-ptr queue) new-pair) + (set-rear-ptr! queue new-pair) + queue)))) + +(define (delete-queue! queue) + (cond ((empty-queue? queue) + (error "DELETE! called with an empty queue" queue)) + (else + (set-front-ptr! queue (cdr (front-ptr queue))) + queue))) + + +;; EXERCISE 3.21 +;: (define q1 (make-queue)) +;: (insert-queue! q1 'a) +;: (insert-queue! q1 'b) +;: (delete-queue! q1) +;: (delete-queue! q1) + + +;;;SECTION 3.3.3 + +(define (lookup key table) + (let ((record (assoc key (cdr table)))) + (if record + (cdr record) + false))) + +(define (assoc key records) + (cond ((null? records) false) + ((equal? key (caar records)) (car records)) + (else (assoc key (cdr records))))) + +(define (insert! key value table) + (let ((record (assoc key (cdr table)))) + (if record + (set-cdr! record value) + (set-cdr! table + (cons (cons key value) (cdr table))))) + 'ok) + +(define (make-table) + (list '*table*)) + +;; two-dimensional +(define (lookup key-1 key-2 table) + (let ((subtable (assoc key-1 (cdr table)))) + (if subtable + (let ((record (assoc key-2 (cdr subtable)))) + (if record + (cdr record) + false)) + false))) + +(define (insert! key-1 key-2 value table) + (let ((subtable (assoc key-1 (cdr table)))) + (if subtable + (let ((record (assoc key-2 (cdr subtable)))) + (if record + (set-cdr! record value) + (set-cdr! subtable + (cons (cons key-2 value) + (cdr subtable))))) + (set-cdr! table + (cons (list key-1 + (cons key-2 value)) + (cdr table))))) + 'ok) + +;; local tables +(define (make-table) + (let ((local-table (list '*table*))) + (define (lookup key-1 key-2) + (let ((subtable (assoc key-1 (cdr local-table)))) + (if subtable + (let ((record (assoc key-2 (cdr subtable)))) + (if record + (cdr record) + false)) + false))) + (define (insert! key-1 key-2 value) + (let ((subtable (assoc key-1 (cdr local-table)))) + (if subtable + (let ((record (assoc key-2 (cdr subtable)))) + (if record + (set-cdr! record value) + (set-cdr! subtable + (cons (cons key-2 value) + (cdr subtable))))) + (set-cdr! local-table + (cons (list key-1 + (cons key-2 value)) + (cdr local-table))))) + 'ok) + (define (dispatch m) + (cond ((eq? m 'lookup-proc) lookup) + ((eq? m 'insert-proc!) insert!) + (else (error "Unknown operation -- TABLE" m)))) + dispatch)) + +(define operation-table (make-table)) +(define get (operation-table 'lookup-proc)) +(define put (operation-table 'insert-proc!)) + + +;; EXERCISE 3.27 +(define (fib n) + (cond ((= n 0) 0) + ((= n 1) 1) + (else (+ (fib (- n 1)) + (fib (- n 2)))))) + +(define (memoize f) + (let ((table (make-table))) + (lambda (x) + (let ((previously-computed-result (lookup x table))) + (or previously-computed-result + (let ((result (f x))) + (insert! x result table) + result)))))) + +(define memo-fib + (memoize (lambda (n) + (cond ((= n 0) 0) + ((= n 1) 1) + (else (+ (memo-fib (- n 1)) + (memo-fib (- n 2)))))))) + +;;;SECTION 3.3.4 + +;: (define a (make-wire)) +;: (define b (make-wire)) +;: (define c (make-wire)) +;: (define d (make-wire)) +;: (define e (make-wire)) +;: (define s (make-wire)) +;: +;: (or-gate a b d) +;: (and-gate a b c) +;: (inverter c e) +;: (and-gate d e s) + + +;;NB. To use half-adder, need or-gate from exercise 3.28 +(define (half-adder a b s c) + (let ((d (make-wire)) (e (make-wire))) + (or-gate a b d) + (and-gate a b c) + (inverter c e) + (and-gate d e s) + 'ok)) + +(define (full-adder a b c-in sum c-out) + (let ((s (make-wire)) + (c1 (make-wire)) + (c2 (make-wire))) + (half-adder b c-in s c1) + (half-adder a s sum c2) + (or-gate c1 c2 c-out) + 'ok)) + +(define (inverter input output) + (define (invert-input) + (let ((new-value (logical-not (get-signal input)))) + (after-delay inverter-delay + (lambda () + (set-signal! output new-value))))) + (add-action! input invert-input) + 'ok) + +(define (logical-not s) + (cond ((= s 0) 1) + ((= s 1) 0) + (else (error "Invalid signal" s)))) + +;; *following uses logical-and -- see ch3support.scm + +(define (and-gate a1 a2 output) + (define (and-action-procedure) + (let ((new-value + (logical-and (get-signal a1) (get-signal a2)))) + (after-delay and-gate-delay + (lambda () + (set-signal! output new-value))))) + (add-action! a1 and-action-procedure) + (add-action! a2 and-action-procedure) + 'ok) + + +(define (make-wire) + (let ((signal-value 0) (action-procedures '())) + (define (set-my-signal! new-value) + (if (not (= signal-value new-value)) + (begin (set! signal-value new-value) + (call-each action-procedures)) + 'done)) + (define (accept-action-procedure! proc) + (set! action-procedures (cons proc action-procedures)) + (proc)) + (define (dispatch m) + (cond ((eq? m 'get-signal) signal-value) + ((eq? m 'set-signal!) set-my-signal!) + ((eq? m 'add-action!) accept-action-procedure!) + (else (error "Unknown operation -- WIRE" m)))) + dispatch)) + +(define (call-each procedures) + (if (null? procedures) + 'done + (begin + ((car procedures)) + (call-each (cdr procedures))))) + +(define (get-signal wire) + (wire 'get-signal)) + +(define (set-signal! wire new-value) + ((wire 'set-signal!) new-value)) + +(define (add-action! wire action-procedure) + ((wire 'add-action!) action-procedure)) + +(define (after-delay delay action) + (add-to-agenda! (+ delay (current-time the-agenda)) + action + the-agenda)) + +(define (propagate) + (if (empty-agenda? the-agenda) + 'done + (let ((first-item (first-agenda-item the-agenda))) + (first-item) + (remove-first-agenda-item! the-agenda) + (propagate)))) + +(define (probe name wire) + (add-action! wire + (lambda () + (newline) + (display name) + (display " ") + (display (current-time the-agenda)) + (display " New-value = ") + (display (get-signal wire))))) + +;;; Sample simulation + +;: (define the-agenda (make-agenda)) +;: (define inverter-delay 2) +;: (define and-gate-delay 3) +;: (define or-gate-delay 5) +;: +;: (define input-1 (make-wire)) +;: (define input-2 (make-wire)) +;: (define sum (make-wire)) +;: (define carry (make-wire)) +;: +;: (probe 'sum sum) +;: (probe 'carry carry) +;: +;: (half-adder input-1 input-2 sum carry) +;: (set-signal! input-1 1) +;: (propagate) +;: +;: (set-signal! input-2 1) +;: (propagate) + + +;; EXERCISE 3.31 +;: (define (accept-action-procedure! proc) +;: (set! action-procedures (cons proc action-procedures))) + + +;;;Implementing agenda + +(define (make-time-segment time queue) + (cons time queue)) +(define (segment-time s) (car s)) +(define (segment-queue s) (cdr s)) + +(define (make-agenda) (list 0)) + +(define (current-time agenda) (car agenda)) +(define (set-current-time! agenda time) + (set-car! agenda time)) + +(define (segments agenda) (cdr agenda)) +(define (set-segments! agenda segments) + (set-cdr! agenda segments)) +(define (first-segment agenda) (car (segments agenda))) +(define (rest-segments agenda) (cdr (segments agenda))) + +(define (empty-agenda? agenda) + (null? (segments agenda))) + +(define (add-to-agenda! time action agenda) + (define (belongs-before? segments) + (or (null? segments) + (< time (segment-time (car segments))))) + (define (make-new-time-segment time action) + (let ((q (make-queue))) + (insert-queue! q action) + (make-time-segment time q))) + (define (add-to-segments! segments) + (if (= (segment-time (car segments)) time) + (insert-queue! (segment-queue (car segments)) + action) + (let ((rest (cdr segments))) + (if (belongs-before? rest) + (set-cdr! + segments + (cons (make-new-time-segment time action) + (cdr segments))) + (add-to-segments! rest))))) + (let ((segments (segments agenda))) + (if (belongs-before? segments) + (set-segments! + agenda + (cons (make-new-time-segment time action) + segments)) + (add-to-segments! segments)))) + +(define (remove-first-agenda-item! agenda) + (let ((q (segment-queue (first-segment agenda)))) + (delete-queue! q) + (if (empty-queue? q) + (set-segments! agenda (rest-segments agenda))))) + +(define (first-agenda-item agenda) + (if (empty-agenda? agenda) + (error "Agenda is empty -- FIRST-AGENDA-ITEM") + (let ((first-seg (first-segment agenda))) + (set-current-time! agenda (segment-time first-seg)) + (front-queue (segment-queue first-seg))))) + + +;;;SECTION 3.3.5 + +;: (define C (make-connector)) +;: (define F (make-connector)) +;: (celsius-fahrenheit-converter C F) + +(define (celsius-fahrenheit-converter c f) + (let ((u (make-connector)) + (v (make-connector)) + (w (make-connector)) + (x (make-connector)) + (y (make-connector))) + (multiplier c w u) + (multiplier v x u) + (adder v y f) + (constant 9 w) + (constant 5 x) + (constant 32 y) + 'ok)) + +;: (probe "Celsius temp" C) +;: (probe "Fahrenheit temp" F) +;: (set-value! C 25 'user) +;: (set-value! F 212 'user) +;: (forget-value! C 'user) +;: (set-value! F 212 'user) + + +(define (adder a1 a2 sum) + (define (process-new-value) + (cond ((and (has-value? a1) (has-value? a2)) + (set-value! sum + (+ (get-value a1) (get-value a2)) + me)) + ((and (has-value? a1) (has-value? sum)) + (set-value! a2 + (- (get-value sum) (get-value a1)) + me)) + ((and (has-value? a2) (has-value? sum)) + (set-value! a1 + (- (get-value sum) (get-value a2)) + me)))) + (define (process-forget-value) + (forget-value! sum me) + (forget-value! a1 me) + (forget-value! a2 me) + (process-new-value)) + (define (me request) + (cond ((eq? request 'I-have-a-value) + (process-new-value)) + ((eq? request 'I-lost-my-value) + (process-forget-value)) + (else + (error "Unknown request -- ADDER" request)))) + (connect a1 me) + (connect a2 me) + (connect sum me) + me) + +(define (inform-about-value constraint) + (constraint 'I-have-a-value)) + +(define (inform-about-no-value constraint) + (constraint 'I-lost-my-value)) + +(define (multiplier m1 m2 product) + (define (process-new-value) + (cond ((or (and (has-value? m1) (= (get-value m1) 0)) + (and (has-value? m2) (= (get-value m2) 0))) + (set-value! product 0 me)) + ((and (has-value? m1) (has-value? m2)) + (set-value! product + (* (get-value m1) (get-value m2)) + me)) + ((and (has-value? product) (has-value? m1)) + (set-value! m2 + (/ (get-value product) (get-value m1)) + me)) + ((and (has-value? product) (has-value? m2)) + (set-value! m1 + (/ (get-value product) (get-value m2)) + me)))) + (define (process-forget-value) + (forget-value! product me) + (forget-value! m1 me) + (forget-value! m2 me) + (process-new-value)) + (define (me request) + (cond ((eq? request 'I-have-a-value) + (process-new-value)) + ((eq? request 'I-lost-my-value) + (process-forget-value)) + (else + (error "Unknown request -- MULTIPLIER" request)))) + (connect m1 me) + (connect m2 me) + (connect product me) + me) + +(define (constant value connector) + (define (me request) + (error "Unknown request -- CONSTANT" request)) + (connect connector me) + (set-value! connector value me) + me) + +(define (probe name connector) + (define (print-probe value) + (newline) + (display "Probe: ") + (display name) + (display " = ") + (display value)) + (define (process-new-value) + (print-probe (get-value connector))) + (define (process-forget-value) + (print-probe "?")) + (define (me request) + (cond ((eq? request 'I-have-a-value) + (process-new-value)) + ((eq? request 'I-lost-my-value) + (process-forget-value)) + (else + (error "Unknown request -- PROBE" request)))) + (connect connector me) + me) + +(define (make-connector) + (let ((value false) (informant false) (constraints '())) + (define (set-my-value newval setter) + (cond ((not (has-value? me)) + (set! value newval) + (set! informant setter) + (for-each-except setter + inform-about-value + constraints)) + ((not (= value newval)) + (error "Contradiction" (list value newval))) + (else 'ignored))) + (define (forget-my-value retractor) + (if (eq? retractor informant) + (begin (set! informant false) + (for-each-except retractor + inform-about-no-value + constraints)) + 'ignored)) + (define (connect new-constraint) + (if (not (memq new-constraint constraints)) + (set! constraints + (cons new-constraint constraints))) + (if (has-value? me) + (inform-about-value new-constraint)) + 'done) + (define (me request) + (cond ((eq? request 'has-value?) + (if informant true false)) + ((eq? request 'value) value) + ((eq? request 'set-value!) set-my-value) + ((eq? request 'forget) forget-my-value) + ((eq? request 'connect) connect) + (else (error "Unknown operation -- CONNECTOR" + request)))) + me)) + +(define (for-each-except exception procedure list) + (define (loop items) + (cond ((null? items) 'done) + ((eq? (car items) exception) (loop (cdr items))) + (else (procedure (car items)) + (loop (cdr items))))) + (loop list)) + +(define (has-value? connector) + (connector 'has-value?)) + +(define (get-value connector) + (connector 'value)) + +(define (set-value! connector new-value informant) + ((connector 'set-value!) new-value informant)) + +(define (forget-value! connector retractor) + ((connector 'forget) retractor)) + +(define (connect connector new-constraint) + ((connector 'connect) new-constraint)) + + +;; EXERCISE 3.34 + +(define (squarer a b) + (multiplier a a b)) + + + +;; EXERCISE 3.36 +;: (define a (make-connector)) +;: (define b (make-connector)) +;: (set-value! a 10 'user) + + +;; EXERCISE 3.37 + +(define (celsius-fahrenheit-converter x) + (c+ (c* (c/ (cv 9) (cv 5)) + x) + (cv 32))) + +;: (define C (make-connector)) +;: (define F (celsius-fahrenheit-converter C)) + +(define (c+ x y) + (let ((z (make-connector))) + (adder x y z) + z)) + + +;;;SECTION 3.4 +;;;**Need parallel-execute, available for MIT Scheme + +;;;SECTION 3.4.1 + +(define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + + +;; EXERCISE 3.38 +;: (set! balance (+ balance 10)) +;: (set! balance (- balance 20)) +;: (set! balance (- balance (/ balance 2))) + + +;;;SECTION 3.4.2 + +;: (define x 10) +;: (parallel-execute (lambda () (set! x (* x x))) +;: (lambda () (set! x (+ x 1)))) + +;: (define x 10) +;: (define s (make-serializer)) +;: (parallel-execute (s (lambda () (set! x (* x x)))) +;: (s (lambda () (set! x (+ x 1))))) + + +(define (make-account balance) + (define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (let ((protected (make-serializer))) + (define (dispatch m) + (cond ((eq? m 'withdraw) (protected withdraw)) + ((eq? m 'deposit) (protected deposit)) + ((eq? m 'balance) balance) + (else (error "Unknown request -- MAKE-ACCOUNT" + m)))) + dispatch)) + + +;; EXERCISE 3.39 + +;: (define x 10) +;: (define s (make-serializer)) +;: (parallel-execute (lambda () (set! x ((s (lambda () (* x x)))))) +;: (s (lambda () (set! x (+ x 1))))) + + +;; EXERCISE 3.40 + +;: (define x 10) +;: (parallel-execute (lambda () (set! x (* x x))) +;: (lambda () (set! x (* x x x)))) +;: +;: +;: (define x 10) +;: (define s (make-serializer)) +;: (parallel-execute (s (lambda () (set! x (* x x)))) +;: (s (lambda () (set! x (* x x x))))) + + +;; EXERCISE 3.41 + +(define (make-account balance) + (define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (let ((protected (make-serializer))) + (define (dispatch m) + (cond ((eq? m 'withdraw) (protected withdraw)) + ((eq? m 'deposit) (protected deposit)) + ((eq? m 'balance) + ((protected (lambda () balance)))) + (else (error "Unknown request -- MAKE-ACCOUNT" + m)))) + dispatch)) + +;; EXERCISE 3.42 + +(define (make-account balance) + (define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (let ((protected (make-serializer))) + (let ((protected-withdraw (protected withdraw)) + (protected-deposit (protected deposit))) + (define (dispatch m) + (cond ((eq? m 'withdraw) protected-withdraw) + ((eq? m 'deposit) protected-deposit) + ((eq? m 'balance) balance) + (else (error "Unknown request -- MAKE-ACCOUNT" + m)))) + dispatch))) + +;;;Multiple shared resources + +(define (exchange account1 account2) + (let ((difference (- (account1 'balance) + (account2 'balance)))) + ((account1 'withdraw) difference) + ((account2 'deposit) difference))) + +(define (make-account-and-serializer balance) + (define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (let ((balance-serializer (make-serializer))) + (define (dispatch m) + (cond ((eq? m 'withdraw) withdraw) + ((eq? m 'deposit) deposit) + ((eq? m 'balance) balance) + ((eq? m 'serializer) balance-serializer) + (else (error "Unknown request -- MAKE-ACCOUNT" + m)))) + dispatch)) + + +(define (deposit account amount) + (let ((s (account 'serializer)) + (d (account 'deposit))) + ((s d) amount))) + +(define (serialized-exchange account1 account2) + (let ((serializer1 (account1 'serializer)) + (serializer2 (account2 'serializer))) + ((serializer1 (serializer2 exchange)) + account1 + account2))) + + +;; EXERCISE 3.44 + +(define (transfer from-account to-account amount) + ((from-account 'withdraw) amount) + ((to-account 'deposit) amount)) + + +;; EXERCISE 3.45 + +(define (make-account-and-serializer balance) + (define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (let ((balance-serializer (make-serializer))) + (define (dispatch m) + (cond ((eq? m 'withdraw) (balance-serializer withdraw)) + ((eq? m 'deposit) (balance-serializer deposit)) + ((eq? m 'balance) balance) + ((eq? m 'serializer) balance-serializer) + (else (error "Unknown request -- MAKE-ACCOUNT" + m)))) + dispatch)) + +(define (deposit account amount) + ((account 'deposit) amount)) + + +;;;Implementing serializers + +(define (make-serializer) + (let ((mutex (make-mutex))) + (lambda (p) + (define (serialized-p . args) + (mutex 'acquire) + (let ((val (apply p args))) + (mutex 'release) + val)) + serialized-p))) + +(define (make-mutex) + (let ((cell (list false))) + (define (the-mutex m) + (cond ((eq? m 'acquire) + (if (test-and-set! cell) + (the-mutex 'acquire))) + ((eq? m 'release) (clear! cell)))) + the-mutex)) + +(define (clear! cell) + (set-car! cell false)) + +(define (test-and-set! cell) + (if (car cell) + true + (begin (set-car! cell true) + false))) + +;;from footnote -- MIT Scheme +(define (test-and-set! cell) + (without-interrupts + (lambda () + (if (car cell) + true + (begin (set-car! cell true) + false))))) + +;;;SECTION 3.5 + +;;;SECTION 3.5.1 + +(define (sum-primes a b) + (define (iter count accum) + (cond ((> count b) accum) + ((prime? count) (iter (+ count 1) (+ count accum))) + (else (iter (+ count 1) accum)))) + (iter a 0)) + + +(define (sum-primes a b) + (accumulate + + 0 + (filter prime? (enumerate-interval a b)))) + +;: (car (cdr (filter prime? +;: (enumerate-interval 10000 1000000)))) + +(define (stream-ref s n) + (if (= n 0) + (stream-car s) + (stream-ref (stream-cdr s) (- n 1)))) + +(define (stream-map proc s) + (if (stream-null? s) + the-empty-stream + (cons-stream (proc (stream-car s)) + (stream-map proc (stream-cdr s))))) + +(define (stream-for-each proc s) + (if (stream-null? s) + 'done + (begin (proc (stream-car s)) + (stream-for-each proc (stream-cdr s))))) + +(define (display-stream s) + (stream-for-each display-line s)) + +(define (display-line x) + (newline) + (display x)) + + + +;; stream-car and stream-cdr would normally be built into +;; the stream implementation +;: (define (stream-car stream) (car stream)) +;: (define (stream-cdr stream) (force (cdr stream))) + +;: (stream-car +;: (stream-cdr +;: (stream-filter prime? +;: (stream-enumerate-interval 10000 1000000)))) + +(define (stream-enumerate-interval low high) + (if (> low high) + the-empty-stream + (cons-stream + low + (stream-enumerate-interval (+ low 1) high)))) + +(define (stream-filter pred stream) + (cond ((stream-null? stream) the-empty-stream) + ((pred (stream-car stream)) + (cons-stream (stream-car stream) + (stream-filter pred + (stream-cdr stream)))) + (else (stream-filter pred (stream-cdr stream))))) + + +;; force would normally be built into +;; the stream implementation +;: (define (force delayed-object) +;: (delayed-object)) + +(define (memo-proc proc) + (let ((already-run? false) (result false)) + (lambda () + (if (not already-run?) + (begin (set! result (proc)) + (set! already-run? true) + result) + result)))) + + +;; EXERCISE 3.51 + +(define (show x) + (display-line x) + x) + +;: (define x (stream-map show (stream-enumerate-interval 0 10))) +;: (stream-ref x 5) +;: (stream-ref x 7) + + +;; EXERCISE 3.52 + +(define sum 0) + +(define (accum x) + (set! sum (+ x sum)) + sum) + +;: (define seq (stream-map accum (stream-enumerate-interval 1 20))) +;: (define y (stream-filter even? seq)) +;: (define z (stream-filter (lambda (x) (= (remainder x 5) 0)) +;: seq)) + +;: (stream-ref y 7) +;: (display-stream z) + + +;;;SECTION 3.5.2 + +(define (integers-starting-from n) + (cons-stream n (integers-starting-from (+ n 1)))) + +(define integers (integers-starting-from 1)) + +(define (divisible? x y) (= (remainder x y) 0)) + +(define no-sevens + (stream-filter (lambda (x) (not (divisible? x 7))) + integers)) + +;: (stream-ref no-sevens 100) + +(define (fibgen a b) + (cons-stream a (fibgen b (+ a b)))) + +(define fibs (fibgen 0 1)) + +(define (sieve stream) + (cons-stream + (stream-car stream) + (sieve (stream-filter + (lambda (x) + (not (divisible? x (stream-car stream)))) + (stream-cdr stream))))) + +(define primes (sieve (integers-starting-from 2))) + +;: (stream-ref primes 50) + + +;;;Defining streams implicitly;;;Defining streams implicitly + +(define ones (cons-stream 1 ones)) + +(define (add-streams s1 s2) + (stream-map + s1 s2)) + +(define integers (cons-stream 1 (add-streams ones integers))) + +(define fibs + (cons-stream 0 + (cons-stream 1 + (add-streams (stream-cdr fibs) + fibs)))) + +(define (scale-stream stream factor) + (stream-map (lambda (x) (* x factor)) stream)) + +(define double (cons-stream 1 (scale-stream double 2))) + +(define primes + (cons-stream + 2 + (stream-filter prime? (integers-starting-from 3)))) + +(define (prime? n) + (define (iter ps) + (cond ((> (square (stream-car ps)) n) true) + ((divisible? n (stream-car ps)) false) + (else (iter (stream-cdr ps))))) + (iter primes)) + + +;; EXERCISE 3.53 +;: (define s (cons-stream 1 (add-streams s s))) + + +;; EXERCISE 3.56 +(define (merge s1 s2) + (cond ((stream-null? s1) s2) + ((stream-null? s2) s1) + (else + (let ((s1car (stream-car s1)) + (s2car (stream-car s2))) + (cond ((< s1car s2car) + (cons-stream s1car (merge (stream-cdr s1) s2))) + ((> s1car s2car) + (cons-stream s2car (merge s1 (stream-cdr s2)))) + (else + (cons-stream s1car + (merge (stream-cdr s1) + (stream-cdr s2))))))))) + + +;; EXERCISE 3.58 +(define (expand num den radix) + (cons-stream + (quotient (* num radix) den) + (expand (remainder (* num radix) den) den radix))) + + +;; EXERCISE 3.59 +;: (define exp-series +;: (cons-stream 1 (integrate-series exp-series))) + + +;;;SECTION 3.5.3 + +(define (sqrt-improve guess x) + (average guess (/ x guess))) + + +(define (sqrt-stream x) + (define guesses + (cons-stream 1.0 + (stream-map (lambda (guess) + (sqrt-improve guess x)) + guesses))) + guesses) + +;: (display-stream (sqrt-stream 2)) + + +(define (pi-summands n) + (cons-stream (/ 1.0 n) + (stream-map - (pi-summands (+ n 2))))) + +;: (define pi-stream +;: (scale-stream (partial-sums (pi-summands 1)) 4)) + +;: (display-stream pi-stream) + + +(define (euler-transform s) + (let ((s0 (stream-ref s 0)) + (s1 (stream-ref s 1)) + (s2 (stream-ref s 2))) + (cons-stream (- s2 (/ (square (- s2 s1)) + (+ s0 (* -2 s1) s2))) + (euler-transform (stream-cdr s))))) + +;: (display-stream (euler-transform pi-stream)) + + +(define (make-tableau transform s) + (cons-stream s + (make-tableau transform + (transform s)))) + +(define (accelerated-sequence transform s) + (stream-map stream-car + (make-tableau transform s))) + +;: (display-stream (accelerated-sequence euler-transform +;: pi-stream)) + + +;; EXERCISE 3.63 +(define (sqrt-stream x) + (cons-stream 1.0 + (stream-map (lambda (guess) + (sqrt-improve guess x)) + (sqrt-stream x)))) + +;; EXERCISE 3.64 +(define (sqrt x tolerance) + (stream-limit (sqrt-stream x) tolerance)) + + +;;; Infinite streams of pairs + +;: (stream-filter (lambda (pair) +;: (prime? (+ (car pair) (cadr pair)))) +;: int-pairs) + +(define (stream-append s1 s2) + (if (stream-null? s1) + s2 + (cons-stream (stream-car s1) + (stream-append (stream-cdr s1) s2)))) + + +;: (pairs integers integers) + + +(define (interleave s1 s2) + (if (stream-null? s1) + s2 + (cons-stream (stream-car s1) + (interleave s2 (stream-cdr s1))))) + +(define (pairs s t) + (cons-stream + (list (stream-car s) (stream-car t)) + (interleave + (stream-map (lambda (x) (list (stream-car s) x)) + (stream-cdr t)) + (pairs (stream-cdr s) (stream-cdr t))))) + + +;; EXERCISE 3.68 + +(define (pairs s t) + (interleave + (stream-map (lambda (x) (list (stream-car s) x)) + t) + (pairs (stream-cdr s) (stream-cdr t)))) + + +;;; Streams as signals + +(define (integral integrand initial-value dt) + (define int + (cons-stream initial-value + (add-streams (scale-stream integrand dt) + int))) + int) + + +;; EXERCISE 3.74 + +(define (make-zero-crossings input-stream last-value) + (cons-stream + (sign-change-detector (stream-car input-stream) last-value) + (make-zero-crossings (stream-cdr input-stream) + (stream-car input-stream)))) + +;: (define zero-crossings (make-zero-crossings sense-data 0)) + + + +;; EXERCISE 3.75 + +(define (make-zero-crossings input-stream last-value) + (let ((avpt (/ (+ (stream-car input-stream) last-value) 2))) + (cons-stream (sign-change-detector avpt last-value) + (make-zero-crossings (stream-cdr input-stream) + avpt)))) + + +;;;SECTION 3.5.4 + +(define (solve f y0 dt) + (define y (integral dy y0 dt)) + (define dy (stream-map f y)) + y) + +(define (integral delayed-integrand initial-value dt) + (define int + (cons-stream initial-value + (let ((integrand (force delayed-integrand))) + (add-streams (scale-stream integrand dt) + int)))) + int) + +(define (solve f y0 dt) + (define y (integral (delay dy) y0 dt)) + (define dy (stream-map f y)) + y) + + +;: (stream-ref (solve (lambda (y) y) 1 0.001) 1000) + + +;; EXERCISE 3.77 + +(define (integral integrand initial-value dt) + (cons-stream initial-value + (if (stream-null? integrand) + the-empty-stream + (integral (stream-cdr integrand) + (+ (* dt (stream-car integrand)) + initial-value) + dt)))) + +;;;SECTION 3.5.5 + +;; same as in section 3.1.2 +(define rand + (let ((x random-init)) + (lambda () + (set! x (rand-update x)) + x))) + + +(define random-numbers + (cons-stream random-init + (stream-map rand-update random-numbers))) + + +;: (define cesaro-stream +;: (map-successive-pairs (lambda (r1 r2) (= (gcd r1 r2) 1)) +;: random-numbers)) + +(define (map-successive-pairs f s) + (cons-stream + (f (stream-car s) (stream-car (stream-cdr s))) + (map-successive-pairs f (stream-cdr (stream-cdr s))))) + + +(define (monte-carlo experiment-stream passed failed) + (define (next passed failed) + (cons-stream + (/ passed (+ passed failed)) + (monte-carlo + (stream-cdr experiment-stream) passed failed))) + (if (stream-car experiment-stream) + (next (+ passed 1) failed) + (next passed (+ failed 1)))) + +;: (define pi +;: (stream-map (lambda (p) (sqrt (/ 6 p))) +;: (monte-carlo cesaro-stream 0 0))) + + +;; same as in section 3.1.3 +(define (make-simplified-withdraw balance) + (lambda (amount) + (set! balance (- balance amount)) + balance)) + +(define (stream-withdraw balance amount-stream) + (cons-stream + balance + (stream-withdraw (- balance (stream-car amount-stream)) + (stream-cdr amount-stream)))) + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/concurrent.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/concurrent.scm new file mode 100644 index 0000000..b0014fc --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/concurrent.scm @@ -0,0 +1,245 @@ +;; Implementation of parallel-execute using call/cc. +;; +;; By Ben Rudiak-Gould, 10/2002. +;; +;; Requires STk (for "procedure-body" and first-class environments). + + +(define call/cc call-with-current-continuation) + + +(define (parallel-execute . thunks) + (apply run-concurrently-with-env + random + (map (lambda (thunk) + (cons (list (uncode (procedure-body thunk))) + (make-virtual-env (procedure-environment thunk)) )) + thunks )) + 'okay ) + + +(define (run-concurrently select . exprs) + (apply run-concurrently-with-env + select + (map (lambda (x) + (cons x (make-virtual-env (global-environment))) ) + exprs ))) + + +(define (run-concurrently-with-env select . exprs-with-envs) + (let ((threads + (map (lambda (exp-env) + (list (call/cc + (lambda (cont) + (let ((scheduler (call/cc cont))) + (scheduler (myeval (car exp-env) + (cdr exp-env) + scheduler ))))))) + exprs-with-envs ))) + (let loop () + (let ((active-threads + (filter (lambda (x) (continuation? (car x))) threads) )) + (if (null? active-threads) + (map car threads) + (let ((active (list-ref active-threads + (select (length active-threads)) ))) + (set-car! active (call/cc (car active))) + (loop) )))))) + + +(define (make-virtual-env real-env) + (cons + `((quote **macro** ,macro-quote) + (lambda **macro** ,macro-lambda) + (let **macro** ,macro-let) + (set! **macro** ,macro-set!) + (define **macro** ,macro-define) + (if **macro** ,macro-if) + (cond **macro** ,macro-cond) + (and **macro** ,macro-and) + (or **macro** ,macro-or) + (set-car! **prim** ,prim-set-car!) + (set-cdr! **prim** ,prim-set-cdr!) + (begin **prim** ,prim-begin) + (test-and-set! **prim** ,prim-test-and-set!) ) + real-env )) + + +(define (env-lookup-raw sym env scheduler) + (call/cc scheduler) + (let ((virtual (assq sym (car env)))) + (if virtual + (cdr virtual) + (eval sym (cdr env)) ))) + + +(define (env-lookup sym env scheduler) + (let* ((val (env-lookup-raw sym env scheduler)) + (proc-body (procedure-body val)) ) + (if (and proc-body (not (eq? (cadr proc-body) '**args**))) + (myeval (uncode proc-body) + (make-virtual-env (procedure-environment val)) + scheduler ) + val ))) + + +(define (env-set! sym val env scheduler) + (call/cc scheduler) + (let ((virtual (assq sym (car env)))) + (if virtual + (set-cdr! virtual val) + (eval `(set! ,sym ',val) (cdr env)) ))) + + +(define (env-define! sym val env scheduler) + (call/cc scheduler) + (set-car! env (cons (cons sym val) (car env))) ) + + +(define (get-special-form name env scheduler) + (if (symbol? name) + (let ((val (env-lookup-raw name env scheduler))) + (if (and (pair? val) (eq? (car val) '**macro**)) + val + #f )) + #f )) + + +(define (myeval expr env scheduler) + (cond ((pair? expr) + (let ((special (get-special-form (car expr) env scheduler))) + (if special + ((cadr special) (cdr expr) env scheduler) + (let ((evaluated (eval-seq expr env scheduler))) + (myapply (car evaluated) (cdr evaluated) scheduler) )))) + ((symbol? expr) + (env-lookup expr env scheduler) ) + (else (eval expr)) )) + + +(define (eval-seq exprs env scheduler) + (if (null? exprs) + '() + (let ((val (myeval (car exprs) env scheduler))) + (cons val (eval-seq (cdr exprs) env scheduler)) ))) + + +(define (myapply func args scheduler) + (cond ((procedure? func) + (apply func args) ) + ((and (pair? func) (eq? (car func) '**prim**)) + ((cadr func) args scheduler) ) + ((and (pair? func) (eq? (car func) '**macro**)) + ((cadr func) (map (lambda (x) (list 'quote x)) args) scheduler) ) + (else (error "apply of non-procedure" func args)) )) + + +(define (make-call-environment params args env) + (cons (let loop ((params params) (args args)) + (cond ((pair? params) + (cons (cons (car params) (car args)) + (loop (cdr params) (cdr args)) )) + ((null? params) + (car env) ) + (else (cons (cons params args) (car env))) )) + (cdr env) )) + + +(define (macro-lambda args env scheduler) + (let ((params (car args)) + (body (cdr args)) ) + (lambda **args** + (let ((new-env (make-call-environment params **args** env))) + (last (map (lambda (x) (myeval x new-env scheduler)) body)) )))) + + +(define (macro-let args env scheduler) + (let ((vars (map car (car args))) + (vals (map cadr (car args))) + (body (cdr args)) ) + (myeval `((lambda ,vars ,@body) ,@vals) env scheduler) )) + + +(define (macro-define args env scheduler) + (if (pair? (car args)) + (macro-define `(,(caar args) (lambda ,(cdar args) ,@(cdr args))) + env scheduler ) + (let ((val (myeval (cadr args) env scheduler))) + (env-define! (car args) val env scheduler) ))) + + +(define (macro-set! args env scheduler) + (let ((val (myeval (cadr args) env scheduler))) + (env-set! (car args) val env scheduler) )) + + +(define (macro-quote args env scheduler) + (car args) ) + + +(define (macro-if args env scheduler) + (if (myeval (car args) env scheduler) + (myeval (cadr args) env scheduler) + (if (pair? (cddr args)) + (myeval (caddr args) env scheduler) + 'okay ))) + + +(define (macro-cond args env scheduler) + (cond ((null? args) 'okay) + ((or (eq? (caar args) 'else) + (myeval (caar args) env scheduler) ) + (car (last-pair (eval-seq (cdar args) env scheduler))) ) + (else (macro-cond (cdr args) env scheduler)) )) + + +(define (macro-and args env scheduler) + (if (null? args) + #t + (let ((val (myeval (car args) env scheduler))) + (if (null? (cdr args)) + val + (and val (macro-and (cdr args) env scheduler)) )))) + + +(define (macro-or args env scheduler) + (if (null? args) + #f + (let ((val (myeval (car args) env scheduler))) + (if (null? (cdr args)) + val + (or val (macro-or (cdr args) env scheduler)) )))) + + +(define (prim-set-car! args scheduler) + (call/cc scheduler) + (apply set-car! args) ) + + +(define (prim-set-cdr! args scheduler) + (call/cc scheduler) + (apply set-cdr! args) ) + + +(define (prim-begin args scheduler) + (car (last-pair args)) ) + + +(define (prim-test-and-set! args scheduler) + (call/cc scheduler) + (test-and-set! (car args)) ) + + +(define (test-and-set! x) + (let ((oldval (car x))) + (set-car! x #t) + oldval )) + + +(define (last-pair lst) + (if (null? (cdr lst)) + lst + (last-pair (cdr lst)) )) + + +(load "~cs61a/lib/serial.scm") diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/constraint.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/constraint.scm new file mode 100644 index 0000000..831827d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/constraint.scm @@ -0,0 +1,219 @@ +;; Programming with constraints, from section 3.3.5 of Abelson and Sussman. + +;; Syntactic interface to contraint and probe objects. +;; These operations inform them that a value has become defined or undefined; +;; they have to figure out which value is involved. + +(define (inform-about-value constraint) + ((constraint 'I-have-a-value))) + +(define (inform-about-no-value constraint) + ((constraint 'I-lost-my-value))) + +;; Types of constraints defined here: adder, multiplier and constant; +;; also define probe, which is a pseudo-constraint. + +(define (adder a1 a2 sum) + (define (process-new-value) + (cond ((and (has-value? a1) (has-value? a2)) + (set-value! sum + (+ (get-value a1) (get-value a2)) + me)) + ((and (has-value? a1) (has-value? sum)) + (set-value! a2 + (- (get-value sum) (get-value a1)) + me)) + ((and (has-value? a2) (has-value? sum)) + (set-value! a1 + (- (get-value sum) (get-value a2)) + me)))) + (define (process-forget-value) + (forget-value! sum me) + (forget-value! a1 me) + (forget-value! a2 me) + (process-new-value)) + + (define (me request) + (cond ((eq? request 'I-have-a-value) + process-new-value) + ((eq? request 'I-lost-my-value) + process-forget-value) + (else + (error "Unknown request -- ADDER" request)))) + + (connect a1 me) + (connect a2 me) + (connect sum me) + me) + +(define (multiplier m1 m2 product) + (define (process-new-value) + (cond ((or (if (has-value? m1) (= (get-value m1) 0) #f) + (if (has-value? m2) (= (get-value m2) 0) #f)) + (set-value! product 0 me)) + ((and (has-value? m1) (has-value? m2)) + (set-value! product + (* (get-value m1) (get-value m2)) + me)) + ((and (has-value? m1) (has-value? product)) + (set-value! m2 + (/ (get-value product) (get-value m1)) + me)) + ((and (has-value? m2) (has-value? product)) + (set-value! m1 + (/ (get-value product) (get-value m2)) + me)))) + (define (process-forget-value) + (forget-value! product me) + (forget-value! m1 me) + (forget-value! m2 me) + (process-new-value)) + + (define (me request) + (cond ((eq? request 'I-have-a-value) + process-new-value) + ((eq? request 'I-lost-my-value) + process-forget-value) + (else + (error "Unknown request -- MULTIPLIER" request)))) + + (connect m1 me) + (connect m2 me) + (connect product me) + me) + +(define (constant value connector) + (define (me request) + (error "Unknown request -- CONSTANT" request)) + (connect connector me) + (set-value! connector value me) + me) + +(define (probe name connector) + (define (process-new-value) + (display "Probe: ") + (display name) + (display " = ") + (display (get-value connector)) + (newline)) + + (define (process-forget-value) + (display "Probe: ") + (display name) + (display " = ") + (display "?") + (newline)) + + (define (me request) + (cond ((eq? request 'I-have-a-value) + process-new-value) + ((eq? request 'I-lost-my-value) + process-forget-value) + (else + (error "Unknown request -- PROBE" request)))) + (connect connector me) + me) + +;; syntactic interface to connector objects + +(define (has-value? connector) + (connector 'has-value?)) + +(define (get-value connector) + (connector 'value)) + +(define (forget-value! connector retractor) + ((connector 'forget) retractor)) + +(define (set-value! connector new-value informant) + ((connector 'set-value!) new-value informant)) + +(define (connect connector new-constraint) + ((connector 'connect) new-constraint)) + + +;; connector object generator. + +(define (make-connector) + (let ((value #f) (informant #f) (constraints '())) + + (define (set-my-value newval setter) + (cond ((not (has-value? me)) + (set! value newval) + (set! informant setter) + (for-each-except setter + inform-about-value + constraints)) + ((not (= value newval)) + (error "Contradiction" (list value newval))))) + + (define (forget-my-value retractor) + (if (eq? retractor informant) + (begin (set! informant #f) + (for-each-except retractor + inform-about-no-value + constraints)))) + + (define (connect new-constraint) + (if (not (memq new-constraint constraints)) + (set! constraints + (cons new-constraint constraints))) + (if (has-value? me) + (inform-about-value new-constraint))) + + (define (me request) + (cond ((eq? request 'has-value?) + (not (null? informant))) + ((eq? request 'value) value) + ((eq? request 'set-value!) set-my-value) + ((eq? request 'forget) forget-my-value) + ((eq? request 'connect) connect) + (else (error "Unknown operation -- CONNECTOR" request)))) + me)) + +;; Helper procedure for connector: +;; do the procedure for each element of list EXCEPT the exception. +;; used to inform connected constraints of value changes +;; (don't want to inform the source of the change) + +(define (for-each-except exception procedure list) + (define (loop items) + (cond ((null? items) 'done) + ((eq? (car items) exception) (loop (cdr items))) + (else (procedure (car items)) + (loop (cdr items))))) + (loop list)) + +;; Example application: Centigrade/Fahrenheit converter. +;; Internal connectors and constraints are stashed in a private environment. +;; see Ex. 3.37 for a cleaner way to do this. + +(define (centigrade-fahrenheit-converter c f) + (let ((u (make-connector)) + (v (make-connector)) + (w (make-connector)) + (x (make-connector)) + (y (make-connector))) + + (multiplier c w u) + (multiplier v x u) + (adder v y f) + (constant 9 w) + (constant 5 x) + (constant 32 y))) + +(define C (make-connector)) +(define F (make-connector)) +(centigrade-fahrenheit-converter C F) +(probe "centigrade temp" C) +(probe "Fahrenheit temp" F) + +(define (fma-constraint f m a) + (multiplier m a f)) +(define force (make-connector)) +(define mass (make-connector)) +(define acceleration (make-connector)) +(fma-constraint force mass acceleration) +(probe "force" force) +(probe "mass" mass) +(probe "acceleration" acceleration) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/huffman.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/huffman.scm new file mode 100644 index 0000000..728b100 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/huffman.scm @@ -0,0 +1,61 @@ +(define (make-leaf symbol weight) + (list 'leaf symbol weight)) + +(define (leaf? object) + (eq? (car object) 'leaf)) + +(define (symbol-leaf x) (cadr x)) + +(define (weight-leaf x) (caddr x)) + +(define (make-code-tree left right) + (list left + right + (append (symbols left) (symbols right)) + (+ (weight left) (weight right)))) + +(define (left-branch tree) (car tree)) + +(define (right-branch tree) (cadr tree)) + +(define (symbols tree) + (if (leaf? tree) + (list (symbol-leaf tree)) + (caddr tree))) + +(define (weight tree) + (if (leaf? tree) + (weight-leaf tree) + (cadddr tree))) + +(define (adjoin-set x set) + (cond ((null? set) (list x)) + ((< (weight x) (weight (car set))) (cons x set)) + (else (cons (car set) + (adjoin-set x (cdr set)))))) + +(define (make-leaf-set pairs) + (if (null? pairs) + '() + (let ((pair (car pairs))) + (adjoin-set (make-leaf (car pair) ;symbol + (cadr pair)) ;frequency + (make-leaf-set (cdr pairs)))))) + +(define (decode bits tree) + (decode-1 bits tree tree)) + +(define (decode-1 bits tree current-branch) + (if (null? bits) + '() + (let ((next-branch + (choose-branch (car bits) current-branch))) + (if (leaf? next-branch) + (cons (symbol-leaf next-branch) + (decode-1 (cdr bits) tree tree)) + (decode-1 (cdr bits) tree next-branch))))) + +(define (choose-branch bit branch) + (cond ((= bit 0) (left-branch branch)) + ((= bit 1) (right-branch branch)) + (else (error "bad bit -- CHOOSE-BRANCH" bit)))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=D;O=A new file mode 100644 index 0000000..354ca85 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=D;O=A @@ -0,0 +1,58 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lib</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lib</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv-world.scm">adv-world.scm</a> </td><td align="right">2005-10-22 09:17 </td><td align="right">2.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv.scm">adv.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ambdiff">ambdiff</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="ambeval.scm">ambeval.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">9.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="analyze.scm">analyze.scm</a> </td><td align="right">2004-04-30 13:16 </td><td align="right">3.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="animal.scm">animal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl-meta.scm">apl-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl.scm">apl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="berkeley.scmm">berkeley.scmm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 54K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">710 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2008-02-13 19:37 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter1.code">chapter1.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="chapter2.code">chapter2.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 47K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter3.code">chapter3.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 41K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="concurrent.scm">concurrent.scm</a> </td><td align="right">2003-04-23 11:28 </td><td align="right">6.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="constraint.scm">constraint.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="huffman.scm">huffman.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="labyrinth.scm">labyrinth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="lazy.scm">lazy.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo-meta.scm">logo-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo.scm">logo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="maze.scm">maze.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mceval.scm">mceval.scm</a> </td><td align="right">2001-04-14 20:22 </td><td align="right"> 10K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="old-obj.scm">old-obj.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="picture.scm">picture.scm</a> </td><td align="right">2000-10-02 11:44 </td><td align="right">3.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">207 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prisoner.scm">prisoner.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="pronounce.scm">pronounce.scm</a> </td><td align="right">2012-12-14 09:39 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="query.scm">query.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ref-man.txt">ref-man.txt</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="resist.scm">resist.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="review">review</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="rps.scm">rps.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scheme1.scm">scheme1.scm</a> </td><td align="right">2007-10-10 09:09 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scmset">scmset</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 81 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="serial.scm">serial.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">542 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="small-world.scm">small-world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tables.scm">tables.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">441 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="test.logo">test.logo</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">576 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tri.l">tri.l</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="turkey">turkey</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="twenty-one.scm">twenty-one.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="vambeval.scm">vambeval.scm</a> </td><td align="right">2000-12-03 14:33 </td><td align="right"> 14K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=D;O=D new file mode 100644 index 0000000..5b79407 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=D;O=D @@ -0,0 +1,58 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lib</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lib</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="vambeval.scm">vambeval.scm</a> </td><td align="right">2000-12-03 14:33 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="twenty-one.scm">twenty-one.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="turkey">turkey</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tri.l">tri.l</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="test.logo">test.logo</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">576 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tables.scm">tables.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">441 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="small-world.scm">small-world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="serial.scm">serial.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">542 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scmset">scmset</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 81 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scheme1.scm">scheme1.scm</a> </td><td align="right">2007-10-10 09:09 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="rps.scm">rps.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="review">review</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="resist.scm">resist.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ref-man.txt">ref-man.txt</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="query.scm">query.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="pronounce.scm">pronounce.scm</a> </td><td align="right">2012-12-14 09:39 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prisoner.scm">prisoner.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">207 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="picture.scm">picture.scm</a> </td><td align="right">2000-10-02 11:44 </td><td align="right">3.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="old-obj.scm">old-obj.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mceval.scm">mceval.scm</a> </td><td align="right">2001-04-14 20:22 </td><td align="right"> 10K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="maze.scm">maze.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo.scm">logo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo-meta.scm">logo-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="lazy.scm">lazy.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="labyrinth.scm">labyrinth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="huffman.scm">huffman.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="constraint.scm">constraint.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="concurrent.scm">concurrent.scm</a> </td><td align="right">2003-04-23 11:28 </td><td align="right">6.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter3.code">chapter3.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 41K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="chapter2.code">chapter2.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 47K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter1.code">chapter1.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2008-02-13 19:37 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">710 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="berkeley.scmm">berkeley.scmm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 54K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl.scm">apl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl-meta.scm">apl-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="animal.scm">animal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="analyze.scm">analyze.scm</a> </td><td align="right">2004-04-30 13:16 </td><td align="right">3.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="ambeval.scm">ambeval.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">9.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ambdiff">ambdiff</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv.scm">adv.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv-world.scm">adv-world.scm</a> </td><td align="right">2005-10-22 09:17 </td><td align="right">2.9K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=M;O=A new file mode 100644 index 0000000..31d89eb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=M;O=A @@ -0,0 +1,58 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lib</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lib</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Lib/?C=M;O=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv.scm">adv.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ambdiff">ambdiff</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="animal.scm">animal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl-meta.scm">apl-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl.scm">apl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter1.code">chapter1.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="chapter2.code">chapter2.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 47K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter3.code">chapter3.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 41K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="constraint.scm">constraint.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="huffman.scm">huffman.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="labyrinth.scm">labyrinth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo-meta.scm">logo-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo.scm">logo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="maze.scm">maze.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="old-obj.scm">old-obj.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prisoner.scm">prisoner.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="query.scm">query.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ref-man.txt">ref-man.txt</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="resist.scm">resist.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="review">review</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="rps.scm">rps.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="serial.scm">serial.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">542 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="small-world.scm">small-world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="turkey">turkey</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="twenty-one.scm">twenty-one.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="berkeley.scmm">berkeley.scmm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 54K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">710 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">207 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scmset">scmset</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 81 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tables.scm">tables.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">441 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="test.logo">test.logo</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">576 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tri.l">tri.l</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="picture.scm">picture.scm</a> </td><td align="right">2000-10-02 11:44 </td><td align="right">3.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="vambeval.scm">vambeval.scm</a> </td><td align="right">2000-12-03 14:33 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mceval.scm">mceval.scm</a> </td><td align="right">2001-04-14 20:22 </td><td align="right"> 10K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="concurrent.scm">concurrent.scm</a> </td><td align="right">2003-04-23 11:28 </td><td align="right">6.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="lazy.scm">lazy.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="ambeval.scm">ambeval.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">9.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="analyze.scm">analyze.scm</a> </td><td align="right">2004-04-30 13:16 </td><td align="right">3.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv-world.scm">adv-world.scm</a> </td><td align="right">2005-10-22 09:17 </td><td align="right">2.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scheme1.scm">scheme1.scm</a> </td><td align="right">2007-10-10 09:09 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2008-02-13 19:37 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="pronounce.scm">pronounce.scm</a> </td><td align="right">2012-12-14 09:39 </td><td align="right">4.7K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=N;O=A new file mode 100644 index 0000000..a16ee53 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=N;O=A @@ -0,0 +1,58 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lib</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lib</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv-world.scm">adv-world.scm</a> </td><td align="right">2005-10-22 09:17 </td><td align="right">2.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv.scm">adv.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ambdiff">ambdiff</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="ambeval.scm">ambeval.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">9.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="analyze.scm">analyze.scm</a> </td><td align="right">2004-04-30 13:16 </td><td align="right">3.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="animal.scm">animal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl-meta.scm">apl-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl.scm">apl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="berkeley.scmm">berkeley.scmm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 54K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">710 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2008-02-13 19:37 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter1.code">chapter1.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="chapter2.code">chapter2.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 47K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter3.code">chapter3.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 41K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="concurrent.scm">concurrent.scm</a> </td><td align="right">2003-04-23 11:28 </td><td align="right">6.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="constraint.scm">constraint.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="huffman.scm">huffman.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="labyrinth.scm">labyrinth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="lazy.scm">lazy.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo-meta.scm">logo-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo.scm">logo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="maze.scm">maze.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mceval.scm">mceval.scm</a> </td><td align="right">2001-04-14 20:22 </td><td align="right"> 10K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="old-obj.scm">old-obj.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="picture.scm">picture.scm</a> </td><td align="right">2000-10-02 11:44 </td><td align="right">3.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">207 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prisoner.scm">prisoner.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="pronounce.scm">pronounce.scm</a> </td><td align="right">2012-12-14 09:39 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="query.scm">query.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ref-man.txt">ref-man.txt</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="resist.scm">resist.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="review">review</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="rps.scm">rps.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scheme1.scm">scheme1.scm</a> </td><td align="right">2007-10-10 09:09 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scmset">scmset</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 81 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="serial.scm">serial.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">542 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="small-world.scm">small-world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tables.scm">tables.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">441 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="test.logo">test.logo</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">576 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tri.l">tri.l</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="turkey">turkey</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="twenty-one.scm">twenty-one.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="vambeval.scm">vambeval.scm</a> </td><td align="right">2000-12-03 14:33 </td><td align="right"> 14K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=N;O=D new file mode 100644 index 0000000..5b79407 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=N;O=D @@ -0,0 +1,58 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lib</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lib</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="vambeval.scm">vambeval.scm</a> </td><td align="right">2000-12-03 14:33 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="twenty-one.scm">twenty-one.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="turkey">turkey</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tri.l">tri.l</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="test.logo">test.logo</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">576 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tables.scm">tables.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">441 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="small-world.scm">small-world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="serial.scm">serial.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">542 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scmset">scmset</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 81 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scheme1.scm">scheme1.scm</a> </td><td align="right">2007-10-10 09:09 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="rps.scm">rps.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="review">review</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="resist.scm">resist.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ref-man.txt">ref-man.txt</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="query.scm">query.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="pronounce.scm">pronounce.scm</a> </td><td align="right">2012-12-14 09:39 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prisoner.scm">prisoner.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">207 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="picture.scm">picture.scm</a> </td><td align="right">2000-10-02 11:44 </td><td align="right">3.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="old-obj.scm">old-obj.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mceval.scm">mceval.scm</a> </td><td align="right">2001-04-14 20:22 </td><td align="right"> 10K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="maze.scm">maze.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo.scm">logo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo-meta.scm">logo-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="lazy.scm">lazy.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="labyrinth.scm">labyrinth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="huffman.scm">huffman.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="constraint.scm">constraint.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="concurrent.scm">concurrent.scm</a> </td><td align="right">2003-04-23 11:28 </td><td align="right">6.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter3.code">chapter3.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 41K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="chapter2.code">chapter2.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 47K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter1.code">chapter1.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2008-02-13 19:37 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">710 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="berkeley.scmm">berkeley.scmm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 54K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl.scm">apl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl-meta.scm">apl-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="animal.scm">animal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="analyze.scm">analyze.scm</a> </td><td align="right">2004-04-30 13:16 </td><td align="right">3.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="ambeval.scm">ambeval.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">9.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ambdiff">ambdiff</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv.scm">adv.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv-world.scm">adv-world.scm</a> </td><td align="right">2005-10-22 09:17 </td><td align="right">2.9K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=S;O=A new file mode 100644 index 0000000..09372f1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=S;O=A @@ -0,0 +1,58 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lib</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lib</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scmset">scmset</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 81 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">207 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tables.scm">tables.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">441 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="serial.scm">serial.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">542 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="test.logo">test.logo</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">576 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">710 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2008-02-13 19:37 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="small-world.scm">small-world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="twenty-one.scm">twenty-one.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="huffman.scm">huffman.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="turkey">turkey</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="rps.scm">rps.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="resist.scm">resist.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="maze.scm">maze.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="review">review</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="animal.scm">animal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="labyrinth.scm">labyrinth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv-world.scm">adv-world.scm</a> </td><td align="right">2005-10-22 09:17 </td><td align="right">2.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tri.l">tri.l</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="picture.scm">picture.scm</a> </td><td align="right">2000-10-02 11:44 </td><td align="right">3.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="analyze.scm">analyze.scm</a> </td><td align="right">2004-04-30 13:16 </td><td align="right">3.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prisoner.scm">prisoner.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="pronounce.scm">pronounce.scm</a> </td><td align="right">2012-12-14 09:39 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="lazy.scm">lazy.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo.scm">logo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ref-man.txt">ref-man.txt</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="constraint.scm">constraint.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl.scm">apl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="concurrent.scm">concurrent.scm</a> </td><td align="right">2003-04-23 11:28 </td><td align="right">6.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv.scm">adv.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl-meta.scm">apl-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scheme1.scm">scheme1.scm</a> </td><td align="right">2007-10-10 09:09 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="old-obj.scm">old-obj.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="ambeval.scm">ambeval.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">9.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ambdiff">ambdiff</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo-meta.scm">logo-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mceval.scm">mceval.scm</a> </td><td align="right">2001-04-14 20:22 </td><td align="right"> 10K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="vambeval.scm">vambeval.scm</a> </td><td align="right">2000-12-03 14:33 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter1.code">chapter1.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="query.scm">query.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter3.code">chapter3.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 41K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="chapter2.code">chapter2.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 47K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="berkeley.scmm">berkeley.scmm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 54K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=S;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=S;O=D new file mode 100644 index 0000000..7378e03 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/index.html?C=S;O=D @@ -0,0 +1,58 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Lib</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Lib</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="berkeley.scmm">berkeley.scmm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 54K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="chapter2.code">chapter2.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 47K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter3.code">chapter3.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 41K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="query.scm">query.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="chapter1.code">chapter1.code</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="vambeval.scm">vambeval.scm</a> </td><td align="right">2000-12-03 14:33 </td><td align="right"> 14K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="mceval.scm">mceval.scm</a> </td><td align="right">2001-04-14 20:22 </td><td align="right"> 10K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo-meta.scm">logo-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ambdiff">ambdiff</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="ambeval.scm">ambeval.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">9.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="old-obj.scm">old-obj.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="obj.scm">obj.scm</a> </td><td align="right">2006-01-23 09:52 </td><td align="right">9.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scheme1.scm">scheme1.scm</a> </td><td align="right">2007-10-10 09:09 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl-meta.scm">apl-meta.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv.scm">adv.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="concurrent.scm">concurrent.scm</a> </td><td align="right">2003-04-23 11:28 </td><td align="right">6.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="apl.scm">apl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">6.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="constraint.scm">constraint.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="ref-man.txt">ref-man.txt</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="logo.scm">logo.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="lazy.scm">lazy.scm</a> </td><td align="right">2004-04-30 13:15 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="pronounce.scm">pronounce.scm</a> </td><td align="right">2012-12-14 09:39 </td><td align="right">4.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="prisoner.scm">prisoner.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="analyze.scm">analyze.scm</a> </td><td align="right">2004-04-30 13:16 </td><td align="right">3.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="picture.scm">picture.scm</a> </td><td align="right">2000-10-02 11:44 </td><td align="right">3.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tri.l">tri.l</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">3.2K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="adv-world.scm">adv-world.scm</a> </td><td align="right">2005-10-22 09:17 </td><td align="right">2.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="labyrinth.scm">labyrinth.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">2.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="animal.scm">animal.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="review">review</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="maze.scm">maze.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="resist.scm">resist.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="rps.scm">rps.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.7K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="turkey">turkey</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="huffman.scm">huffman.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="twenty-one.scm">twenty-one.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="small-world.scm">small-world.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">1.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="calc.scm">calc.scm</a> </td><td align="right">2008-02-13 19:37 </td><td align="right">875 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="bst.scm">bst.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">710 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="test.logo">test.logo</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">576 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="serial.scm">serial.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">542 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="tables.scm">tables.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">441 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="pigl.scm">pigl.scm</a> </td><td align="right">2000-05-30 12:38 </td><td align="right">207 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="scmset">scmset</a> </td><td align="right">2000-05-30 12:38 </td><td align="right"> 81 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/labyrinth.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/labyrinth.scm new file mode 100644 index 0000000..5a1f3ab --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/labyrinth.scm @@ -0,0 +1,93 @@ +;;; To make a labyrinth underneath sproul-plaza, say +;;; (instantiate labyrinth sproul-plaza) +;;; now go down from sproul to enter + +;;; You might also want your character to maintain a list of rooms visited on +;;; its property list so you can find your way back to the earth's surface. + +(define-class (labyrinth connect-place) + (instance-vars (places (make-populated-places 100 60 4 'underground-room))) + (initialize + (can-go connect-place 'down (car places)) + (can-go (car places) 'up connect-place) + (connect-places places) + 'okay)) + +;;; You may find this helpful for moving around +;;; You may want to modify it so that you can look around +;;; in nearby rooms before entering so that you can avoid thieves. +(define (fancy-move-loop who) + (newline) + (let ((things (ask who 'look-around))) + (if things + (begin (print "You see") + (for-each (lambda (thing) + (display thing) + (display " ")) + things)))) + (newline) + (print (ask who 'exits)) + (display "? > ") + (let ((dir (read))) + (if (equal? dir 'stop) + (newline) + (begin (ask who 'go dir) + (fancy-move-loop who))))) + + + +(define (make-places count name) + (define (iter n) + (if (> n count) + '() + (cons (instantiate place (word name '- n)) + (iter (1+ n)) ))) + (iter 1)) + +(define *object-types* '(gold lead pizza potstickers burritos)) + +(define (make-populated-places n-places n-objects n-thieves place-name) + (let ((places (make-places n-places place-name))) + (dotimes n-objects + (lambda (count) + (ask (pick-random places) + 'appear + (instantiate thing (pick-random *object-types*))))) + (dotimes n-thieves + (lambda (count) + (instantiate thief + (word 'Nasty '- count) + (pick-random places)))) + places)) + +(define direction-pairs '((north . south) (south . north) + (east . west) (west . east) + (up . down) (down . up))) + +(define (connect-places places) + (for-each (lambda (place) + (connect-pair place (pick-random places))) + places)) + +(define (connect-pair place1 place2) + (define (c-p-helper place1 place2 dir-pairs) + (cond ((null? dir-pairs) 'done) + ((and (can-connect? place1 (caar dir-pairs)) + (can-connect? place2 (cdar dir-pairs))) + (can-go place1 (caar dir-pairs) place2) + (can-go place2 (cdar dir-pairs) place1)) + (else (c-p-helper place1 place2 (cdr dir-pairs))))) + (c-p-helper place1 place2 direction-pairs)) + +(define (can-connect? place direction) + (not (member? direction (ask place 'exits)))) + +(define (dotimes limit f) + ;; dotimes calls the procedure f on the numbers from 1 to the limit + ;; dotimes is for side effect only + (define (dotimes-iter count) + (if (> count limit) + 'done ;; dotimes is for side-effect + (begin (f count) + (dotimes-iter (1+ count))))) + (dotimes-iter 1)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/lazy.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/lazy.scm new file mode 100644 index 0000000..76970cc --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/lazy.scm @@ -0,0 +1,165 @@ +;;;;LAZY EVALUATOR FROM SECTION 4.2 OF +;;;; STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS + +;;;;Matches code in ch4.scm +;;;; Also includes enlarged primitive-procedures list + +;;;;This file can be loaded into Scheme as a whole. +;;;;**NOTE**This file loads the metacircular evaluator of +;;;; sections 4.1.1-4.1.4, since it uses the expression representation, +;;;; environment representation, etc. +;;;; You may need to change the (load ...) expression to work in your +;;;; version of Scheme. + +;;;;Then you can initialize and start the evaluator by evaluating +;;;; the expression (mce). + + +;;**implementation-dependent loading of evaluator file +;;Note: It is loaded first so that the section 4.2 definition +;; of eval overrides the definition from 4.1.1 +(load "~/61a/Lib/mceval.scm") + + +;; To run without memoization, reload the first version of force-it below + + +;;;SECTION 4.2.2 + +;;; Modifying the evaluator + +(define (mc-eval exp env) + (cond ((self-evaluating? exp) exp) + ((variable? exp) (lookup-variable-value exp env)) + ((quoted? exp) (text-of-quotation exp)) + ((assignment? exp) (eval-assignment exp env)) + ((definition? exp) (eval-definition exp env)) + ((if? exp) (eval-if exp env)) + ((lambda? exp) + (make-procedure (lambda-parameters exp) + (lambda-body exp) + env)) + ((begin? exp) + (eval-sequence (begin-actions exp) env)) + ((cond? exp) (mc-eval (cond->if exp) env)) + ((application? exp) ; clause from book + (mc-apply (actual-value (operator exp) env) + (operands exp) + env)) + (else + (error "Unknown expression type -- EVAL" exp)))) + +(define (actual-value exp env) + (force-it (mc-eval exp env))) + +(define (mc-apply procedure arguments env) + (cond ((primitive-procedure? procedure) + (apply-primitive-procedure + procedure + (list-of-arg-values arguments env))) ; changed + ((compound-procedure? procedure) + (eval-sequence + (procedure-body procedure) + (extend-environment + (procedure-parameters procedure) + (list-of-delayed-args arguments env) ; changed + (procedure-environment procedure)))) + (else + (error + "Unknown procedure type -- APPLY" procedure)))) + +(define (list-of-arg-values exps env) + (if (no-operands? exps) + '() + (cons (actual-value (first-operand exps) env) + (list-of-arg-values (rest-operands exps) + env)))) + +(define (list-of-delayed-args exps env) + (if (no-operands? exps) + '() + (cons (delay-it (first-operand exps) env) + (list-of-delayed-args (rest-operands exps) + env)))) + +(define (eval-if exp env) + (if (true? (actual-value (if-predicate exp) env)) + (mc-eval (if-consequent exp) env) + (mc-eval (if-alternative exp) env))) + +(define input-prompt ";;; L-Eval input:") +(define output-prompt ";;; L-Eval value:") + +(define (driver-loop) + (prompt-for-input input-prompt) + (let ((input (read))) + (let ((output + (actual-value input the-global-environment))) + (announce-output output-prompt) + (user-print output))) + (driver-loop)) + + +;;; Representing thunks + +;; non-memoizing version of force-it + +(define (force-it obj) + (if (thunk? obj) + (actual-value (thunk-exp obj) (thunk-env obj)) + obj)) + +;; thunks + +(define (delay-it exp env) + (list 'thunk exp env)) + +(define (thunk? obj) + (tagged-list? obj 'thunk)) + +(define (thunk-exp thunk) (cadr thunk)) +(define (thunk-env thunk) (caddr thunk)) + +;; "thunk" that has been forced and is storing its (memoized) value +(define (evaluated-thunk? obj) + (tagged-list? obj 'evaluated-thunk)) + +(define (thunk-value evaluated-thunk) (cadr evaluated-thunk)) + + +;; memoizing version of force-it + +(define (force-it obj) + (cond ((thunk? obj) + (let ((result (actual-value + (thunk-exp obj) + (thunk-env obj)))) + (set-car! obj 'evaluated-thunk) + (set-car! (cdr obj) result) ; replace exp with its value + (set-cdr! (cdr obj) '()) ; forget unneeded env + result)) + ((evaluated-thunk? obj) + (thunk-value obj)) + (else obj))) + + +;; A longer list of primitives -- suitable for running everything in 4.2 +;; Overrides the list in ch4-mceval.scm + +(define primitive-procedures + (list (list 'car car) + (list 'cdr cdr) + (list 'cons cons) + (list 'null? null?) + (list 'list list) + (list '+ +) + (list '- -) + (list '* *) + (list '/ /) + (list '= =) + (list 'newline newline) + (list 'display display) +;; more primitives + )) + +'LAZY-EVALUATOR-LOADED diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/logo-meta.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/logo-meta.scm new file mode 100644 index 0000000..3a9c5e1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/logo-meta.scm @@ -0,0 +1,337 @@ +;;; logo-meta.scm Part of programming project #4 + +;;; Differences between the book and this version: Eval and apply have +;;; been changed to logo-eval and logo-apply so as not to overwrite the Scheme +;;; versions of these routines. An extra procedure initialize-logo has been +;;; added. This routine resets the global environment and then executes the +;;; driver loop. This procedure should be invoked to start the Logo +;;; evaluator executing. Note: It will reset your global environment and all +;;; definitions to the Logo interpreter will be lost. To restart the Logo +;;; interpreter without resetting the global environment, just invoke +;;; driver-loop. Don't forget that typing control-C will get you out of +;;; the Logo evaluator back into Scheme. + +;;; Problems A1, A2, and B2 are entirely in logo.scm +;;; Problems A3, B3, and 6 require you to find and change existing procedures. + +;;; Procedures that you must write from scratch: + +;;; Problem B1 eval-line + +(define (eval-line line-obj env) + (error "eval-line not written yet!")) + + +;;; Problem B3 variables (other procedures must be modified, too) +;;; data abstraction procedures + +(define (variable? exp) + #f) ;; not written yet but we fake it for now + +(define (variable-name exp) + (error "variable-name not written yet!")) + + +;;; Problem A4 handle-infix + +(define (de-infix token) + (cdr (assoc token '((+ . sum) + (- . difference) + (* . product) + (/ . quotient) + (= . equalp) + (< . lessp) + (> . greaterp))))) + +(define (handle-infix value line-obj env) + value) ;; This doesn't give an error message, so other stuff works. + + +;;; Problem B4 eval-definition + +(define (eval-definition line-obj) + (error "eval-definition not written yet!")) + + +;;; Problem 5 eval-sequence + +(define (eval-sequence exps env) + (error "eval-seqence not written yet!")) + + + + +;;; SETTING UP THE ENVIRONMENT + +(define the-primitive-procedures '()) + +(define (add-prim name count proc) + (set! the-primitive-procedures + (cons (list name 'primitive count proc) + the-primitive-procedures))) + +(add-prim 'first 1 first) +(add-prim 'butfirst 1 bf) +(add-prim 'bf 1 bf) +(add-prim 'last 1 last) +(add-prim 'butlast 1 bl) +(add-prim 'bl 1 bl) +(add-prim 'word 2 word) +(add-prim 'sentence 2 se) +(add-prim 'se 2 se) +(add-prim 'list 2 list) +(add-prim 'fput 2 cons) + +(add-prim 'sum 2 (make-logo-arith +)) +(add-prim 'difference 2 (make-logo-arith -)) +(add-prim '=unary-minus= 1 (make-logo-arith -)) +(add-prim '- 1 (make-logo-arith -)) +(add-prim 'product 2 (make-logo-arith *)) +(add-prim 'quotient 2 (make-logo-arith /)) +(add-prim 'remainder 2 (make-logo-arith remainder)) + +(add-prim 'print 1 logo-print) +(add-prim 'pr 1 logo-print) +(add-prim 'show 1 logo-show) +(add-prim 'type 1 logo-type) +(add-prim 'make '(2) make) + +(add-prim 'run '(1) run) +(add-prim 'if '(2) logo-if) +(add-prim 'ifelse '(3) ifelse) +(add-prim 'equalp 2 (logo-pred (make-logo-arith equalp))) +(add-prim 'lessp 2 (logo-pred (make-logo-arith <))) +(add-prim 'greaterp 2 (logo-pred (make-logo-arith >))) +(add-prim 'emptyp 1 (logo-pred empty?)) +(add-prim 'numberp 1 (logo-pred (make-logo-arith number?))) +(add-prim 'listp 1 (logo-pred list?)) +(add-prim 'wordp 1 (logo-pred (lambda (x) (not (list? x))))) + +(add-prim 'stop 0 (lambda () '=stop=)) +(add-prim 'output 1 (lambda (x) (cons '=output= x))) +(add-prim 'op 1 (lambda (x) (cons '=output= x))) + +(add-prim 'load 1 meta-load) + +(define the-global-environment '()) +(define the-procedures the-primitive-procedures) + +;;; INITIALIZATION AND DRIVER LOOP + +;;; The following code initializes the machine and starts the Logo +;;; system. You should not call it very often, because it will clobber +;;; the global environment, and you will lose any definitions you have +;;; accumulated. + +(define (initialize-logo) + (set! the-global-environment (extend-environment '() '() '())) + (set! the-procedures the-primitive-procedures) + (driver-loop)) + +(define (driver-loop) + (define (helper) + (prompt "? ") + (let ((line (logo-read))) + (if (not (null? line)) + (let ((result (eval-line (make-line-obj line) + the-global-environment))) + (if (not (eq? result '=no-value=)) + (logo-print (list "You don't say what to do with" result)))))) + (helper)) + (logo-read) + (helper)) + +;;; APPLYING PRIMITIVE PROCEDURES + +;;; To apply a primitive procedure, we ask the underlying Scheme system +;;; to perform the application. (Of course, an implementation on a +;;; low-level machine would perform the application in some other way.) + +(define (apply-primitive-procedure p args) + (apply (text p) args)) + + +;;; Now for the code that's based on the book!!! + + +;;; Section 4.1.1 + +;; Given an expression like (proc :a :b :c)+5 +;; logo-eval calls eval-prefix for the part in parentheses, and then +;; handle-infix to check for and process the infix arithmetic. +;; Eval-prefix is comparable to Scheme's eval. + +(define (logo-eval line-obj env) + (handle-infix (eval-prefix line-obj env) line-obj env)) + +(define (eval-prefix line-obj env) + (define (eval-helper paren-flag) + (let ((token (ask line-obj 'next))) + (cond ((self-evaluating? token) token) + ((variable? token) + (lookup-variable-value (variable-name token) env)) + ((quoted? token) (text-of-quotation token)) + ((definition? token) (eval-definition line-obj)) + ((left-paren? token) + (let ((result (handle-infix (eval-helper #t) + line-obj + env))) + (let ((token (ask line-obj 'next))) + (if (right-paren? token) + result + (error "Too much inside parens"))))) + ((right-paren? token) + (error "Unexpected ')'")) + (else + (let ((proc (lookup-procedure token))) + (if (not proc) (error "I don't know how to" token)) + (logo-apply proc + (collect-n-args (arg-count proc) + line-obj + env) + env))) ))) + (eval-helper #f)) + +(define (logo-apply procedure arguments env) + (cond ((primitive-procedure? procedure) + (apply-primitive-procedure procedure arguments)) + ((compound-procedure? procedure) + (eval-sequence (procedure-body procedure) + (extend-environment + (parameters procedure) + arguments + env))) + (else + (error "Unknown procedure type -- LOGO-APPLY" procedure)))) + +(define (collect-n-args n line-obj env) + (cond ((= n 0) '()) + ((and (< n 0) (not (ask line-obj 'empty?))) + (let ((token (ask line-obj 'next))) + (ask line-obj 'put-back token) + (if (right-paren? token) + '() + (let ((next (logo-eval line-obj env))) + (cons next + (collect-n-args (-1+ n) line-obj env)) )))) + (else + (let ((next (logo-eval line-obj env))) + (cons next + (collect-n-args (-1+ n) line-obj env)) )))) + +;;; Section 4.1.2 -- Representing expressions + +;;; numbers + +(define (self-evaluating? exp) (number? exp)) + +;;; quote + +(define (quoted? exp) + (or (list? exp) + (eq? (string-ref (word->string (first exp)) 0) #\"))) + +(define (text-of-quotation exp) + (if (list? exp) + exp + (bf exp))) + +;;; parens + +(define (left-paren? exp) (eq? exp left-paren-symbol)) + +(define (right-paren? exp) (eq? exp right-paren-symbol)) + +;;; definitions + +(define (definition? exp) + (eq? exp 'to)) + +;;; procedures + +(define (lookup-procedure name) + (assoc name the-procedures)) + +(define (primitive-procedure? p) + (eq? (cadr p) 'primitive)) + +(define (compound-procedure? p) + (eq? (cadr p) 'compound)) + +(define (arg-count proc) + (caddr proc)) + +(define (text proc) + (cadddr proc)) + +(define (parameters proc) (car (text proc))) + +(define (procedure-body proc) (cdr (text proc))) + +;;; Section 4.1.3 + +;;; Operations on environments + +(define (enclosing-environment env) (cdr env)) + +(define (first-frame env) (car env)) + +(define the-empty-environment '()) + +(define (make-frame variables values) + (cons variables values)) + +(define (frame-variables frame) (car frame)) +(define (frame-values frame) (cdr frame)) + +(define (add-binding-to-frame! var val frame) + (set-car! frame (cons var (car frame))) + (set-cdr! frame (cons val (cdr frame)))) + +(define (extend-environment vars vals base-env) + (if (= (length vars) (length vals)) + (cons (make-frame vars vals) base-env) + (if (< (length vars) (length vals)) + (error "Too many arguments supplied" vars vals) + (error "Too few arguments supplied" vars vals)))) + +(define (lookup-variable-value var env) + (define (env-loop env) + (define (scan vars vals) + (cond ((null? vars) + (env-loop (enclosing-environment env))) + ((eq? var (car vars)) + (car vals)) + (else (scan (cdr vars) (cdr vals))))) + (if (eq? env the-empty-environment) + (error "Unbound variable" var) + (let ((frame (first-frame env))) + (scan (frame-variables frame) + (frame-values frame))))) + (env-loop env)) + +(define (set-variable-value! var val env) + (define (env-loop env) + (define (scan vars vals) + (cond ((null? vars) + (env-loop (enclosing-environment env))) + ((eq? var (car vars)) + (set-car! vals val)) + (else (scan (cdr vars) (cdr vals))))) + (if (eq? env the-empty-environment) + (error "Unbound variable -- SET!" var) + (let ((frame (first-frame env))) + (scan (frame-variables frame) + (frame-values frame))))) + (env-loop env)) + +(define (define-variable! var val env) + (let ((frame (first-frame env))) + (define (scan vars vals) + (cond ((null? vars) + (add-binding-to-frame! var val frame)) + ((eq? var (car vars)) + (set-car! vals val)) + (else (scan (cdr vars) (cdr vals))))) + (scan (frame-variables frame) + (frame-values frame)))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/logo.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/logo.scm new file mode 100644 index 0000000..49fdab1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/logo.scm @@ -0,0 +1,173 @@ +;;; logo.scm part of programming project #4 + + +;;; Problem A1 make-line-obj + +(define (make-line-obj text) + (error "make-line-obj not written yet!")) + + +;;; Problem A2 logo-type + +(define (logo-type val) + (error "logo-type not written yet!")) + +(define (logo-print val) + (logo-type val) + (newline) + '=no-value=) + +(define (logo-show val) + (logo-print (list val))) + + + +;;; Problem B3 variables (logo-meta.scm is also affected) + +(define (make env var val) + (error "make not written yet!") + '=no-value=) + + +;;; Here are the primitives RUN, IF, and IFELSE. Problem B2 provides +;;; support for these, but you don't have to modify them. + +(define (run env exp) + (eval-line (make-line-obj exp) env)) + +(define (logo-if env t/f exp) + (cond ((eq? t/f 'true) (eval-line (make-line-obj exp) env)) + ((eq? t/f 'false) '=no-value=) + (else (error "Input to IF not true or false" t/f)))) + +(define (ifelse env t/f exp1 exp2) + (cond ((eq? t/f 'true) (eval-line (make-line-obj exp1) env)) + ((eq? t/f 'false) (eval-line (make-line-obj exp2) env)) + (else (error "Input to IFELSE not true or false" t/f)))) + + +;;; Problem B2 logo-pred + +(define (logo-pred pred) + pred) ;; This isn't written yet but we fake it for now. + + +;;; Here is an example of a Scheme predicate that will be turned into +;;; a Logo predicate by logo-pred: + +(define (equalp a b) + (if (and (number? a) (number? b)) + (= a b) + (equal? a b))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Stuff below here is needed for the interpreter to work but you ;;; +;;; don't have to modify anything or understand how they work. ;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;;; The Logo reader + +(define left-paren-symbol (string->symbol (make-string 1 #\( ))) +(define right-paren-symbol (string->symbol (make-string 1 #\) ))) +(define quote-symbol (string->symbol (make-string 1 #\" ))) + +(define (logo-read) + (define lookahead #f) + (define (logo-read-help depth) + (define (get-char) + (if lookahead + (let ((char lookahead)) + (set! lookahead #f) + char) + (let ((char (read-char))) + (if (eq? char #\\) + (list (read-char)) + char)))) + (define (quoted char) + (if (pair? char) + char + (list char))) + (define (get-symbol char) + (define (iter sofar char) + (cond ((pair? char) (iter (cons (car char) sofar) (get-char))) + ((memq char + '(#\space #\newline #\+ #\- #\* #\/ + #\= #\< #\> #\( #\) #\[ #\] )) + (set! lookahead char) + sofar) + (else (iter (cons char sofar) (get-char))) )) + (string->word (list->string (reverse (iter '() char)))) ) + (define (get-token space-flag) + (let ((char (get-char))) + (cond ((eq? char #\space) (get-token #t)) + ((memq char '(#\+ #\* #\/ #\= #\< #\> #\( #\) )) + (string->symbol (make-string 1 char))) + ((eq? char #\-) + (if space-flag + (let ((char (get-char))) + (let ((result (if (eq? char #\space) + '- + '=unary-minus=))) + (set! lookahead char) + result)) + '-)) + ((eq? char #\[) (logo-read-help (1+ depth))) + ((pair? char) (get-symbol char)) + ((eq? char #\") + (let ((char (get-char))) + (if (memq char '(#\[ #\] #\newline)) + (begin (set! lookahead char) quote-symbol) + (string->symbol (word quote-symbol + (get-symbol (quoted char))))))) + (else (get-symbol char)) ))) + (define (after-space) + (let ((char (get-char))) + (if (eq? char #\space) + (after-space) + char))) + (let ((char (get-char))) + (cond ((eq? char #\newline) + (if (> depth 0) (set! lookahead char)) + '()) + ((eq? char #\space) + (let ((char (after-space))) + (if (eq? char #\newline) + (begin (if (> depth 0) (set! lookahead char)) + '()) + (begin (set! lookahead char) + (let ((token (get-token #t))) + (cons token (logo-read-help depth))))))) + ((eq? char #\]) + (if (> depth 0) '() (error "Unexpected ]"))) + ((eof-object? char) char) + (else (set! lookahead char) + (let ((token (get-token #f))) + (cons token (logo-read-help depth)) ))))) + (logo-read-help 0)) + + +;;; Assorted stuff + +(define (make-logo-arith op) + (lambda args (apply op (map maybe-num args)))) + +(define (maybe-num val) + (string->word (word->string val))) + +(define tty-port (current-input-port)) + +(define (prompt string) + (if (eq? (current-input-port) tty-port) (display string))) + +(define (meta-load fn) + (define (loader) + (let ((exp (logo-read))) + (if (eof-object? exp) + '() + (begin (eval-line (make-line-obj exp) + the-global-environment) + (loader))))) + (with-input-from-file (symbol->string fn) loader) + '=no-value=) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/maze.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/maze.scm new file mode 100644 index 0000000..cddce36 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/maze.scm @@ -0,0 +1,64 @@ +(define make-square list) + +(define row car) + +(define column cadr) + +(define adas-maze + (list + (make-square 1 3) (make-square 1 4) + (make-square 2 1) (make-square 2 2) (make-square 2 4) + (make-square 3 1) (make-square 3 4) (make-square 3 5) + (make-square 4 1) (make-square 4 2) (make-square 4 4) + (make-square 5 2) (make-square 5 3) (make-square 5 4))) + +(define (neighbors square) + (list (make-square (- (row square) 1) (column square)) + (make-square (+ (row square) 1) (column square)) + (make-square (row square) (- (column square) 1)) + (make-square (row square) (+ (column square) 1)))) + +(define (find-path start goal maze) + (try-paths (list (list start)) goal maze)) + +(define (try-paths paths goal maze) + (define (try-loop p) + (cond ((null? p) + (try-paths (extend-all-paths paths maze) + goal + maze)) + ((complete? goal (car p)) + (car p)) + (else (try-loop (cdr p))))) + (try-loop paths)) + +(define (complete? goal path) + (same-square? goal (car path))) + +(define (same-square? s1 s2) + (and (= (row s1) (row s2)) + (= (column s1) (column s2)))) + +(define (extend-all-paths paths maze) + (if (null? paths) + '() + (append (extend-path (car paths) + (neighbors (car (car paths))) + maze) + (extend-all-paths (cdr paths) maze)))) + +(define (extend-path path neighbors maze) + (cond ((null? neighbors) '()) + ((allowed-extension? (car neighbors) maze) + (cons (cons (car neighbors) path) + (extend-path path (cdr neighbors) maze))) + (else (extend-path path (cdr neighbors) maze)))) + +(define (allowed-extension? square maze) + (square-in-list? square maze)) + +(define (square-in-list? square lst) + (cond ((null? lst) #f) + ((same-square? square (car lst)) #t) + (else (square-in-list? square (cdr lst))))) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/mceval.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/mceval.scm new file mode 100644 index 0000000..ed95fd1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/mceval.scm @@ -0,0 +1,375 @@ +;;;;METACIRCULAR EVALUATOR FROM CHAPTER 4 (SECTIONS 4.1.1-4.1.4) of +;;;; STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS + +;;;;Matches code in ch4.scm + +;;;;This file can be loaded into Scheme as a whole. +;;;;Then you can initialize and start the evaluator by evaluating +;;;; the expression (mce). + +;;;from section 4.1.4 -- must precede def of metacircular apply +(define apply-in-underlying-scheme apply) + +;;;SECTION 4.1.1 + +(define (mc-eval exp env) + (cond ((self-evaluating? exp) exp) + ((variable? exp) (lookup-variable-value exp env)) + ((quoted? exp) (text-of-quotation exp)) + ((assignment? exp) (eval-assignment exp env)) + ((definition? exp) (eval-definition exp env)) + ((if? exp) (eval-if exp env)) + ((lambda? exp) + (make-procedure (lambda-parameters exp) + (lambda-body exp) + env)) + ((begin? exp) + (eval-sequence (begin-actions exp) env)) + ((cond? exp) (mc-eval (cond->if exp) env)) + ((application? exp) + (mc-apply (mc-eval (operator exp) env) + (list-of-values (operands exp) env))) + (else + (error "Unknown expression type -- EVAL" exp)))) + +(define (mc-apply procedure arguments) + (cond ((primitive-procedure? procedure) + (apply-primitive-procedure procedure arguments)) + ((compound-procedure? procedure) + (eval-sequence + (procedure-body procedure) + (extend-environment + (procedure-parameters procedure) + arguments + (procedure-environment procedure)))) + (else + (error + "Unknown procedure type -- APPLY" procedure)))) + + +(define (list-of-values exps env) + (if (no-operands? exps) + '() + (cons (mc-eval (first-operand exps) env) + (list-of-values (rest-operands exps) env)))) + +(define (eval-if exp env) + (if (true? (mc-eval (if-predicate exp) env)) + (mc-eval (if-consequent exp) env) + (mc-eval (if-alternative exp) env))) + +(define (eval-sequence exps env) + (cond ((last-exp? exps) (mc-eval (first-exp exps) env)) + (else (mc-eval (first-exp exps) env) + (eval-sequence (rest-exps exps) env)))) + +(define (eval-assignment exp env) + (set-variable-value! (assignment-variable exp) + (mc-eval (assignment-value exp) env) + env) + 'ok) + +(define (eval-definition exp env) + (define-variable! (definition-variable exp) + (mc-eval (definition-value exp) env) + env) + 'ok) + +;;;SECTION 4.1.2 + +(define (self-evaluating? exp) + (cond ((number? exp) true) + ((string? exp) true) + ((boolean? exp) true) + (else false))) + +(define (quoted? exp) + (tagged-list? exp 'quote)) + +(define (text-of-quotation exp) (cadr exp)) + +(define (tagged-list? exp tag) + (if (pair? exp) + (eq? (car exp) tag) + false)) + +(define (variable? exp) (symbol? exp)) + +(define (assignment? exp) + (tagged-list? exp 'set!)) + +(define (assignment-variable exp) (cadr exp)) + +(define (assignment-value exp) (caddr exp)) + + +(define (definition? exp) + (tagged-list? exp 'define)) + +(define (definition-variable exp) + (if (symbol? (cadr exp)) + (cadr exp) + (caadr exp))) + +(define (definition-value exp) + (if (symbol? (cadr exp)) + (caddr exp) + (make-lambda (cdadr exp) + (cddr exp)))) + +(define (lambda? exp) (tagged-list? exp 'lambda)) + +(define (lambda-parameters exp) (cadr exp)) +(define (lambda-body exp) (cddr exp)) + +(define (make-lambda parameters body) + (cons 'lambda (cons parameters body))) + + +(define (if? exp) (tagged-list? exp 'if)) + +(define (if-predicate exp) (cadr exp)) + +(define (if-consequent exp) (caddr exp)) + +(define (if-alternative exp) + (if (not (null? (cdddr exp))) + (cadddr exp) + 'false)) + +(define (make-if predicate consequent alternative) + (list 'if predicate consequent alternative)) + + +(define (begin? exp) (tagged-list? exp 'begin)) + +(define (begin-actions exp) (cdr exp)) + +(define (last-exp? seq) (null? (cdr seq))) +(define (first-exp seq) (car seq)) +(define (rest-exps seq) (cdr seq)) + +(define (sequence->exp seq) + (cond ((null? seq) seq) + ((last-exp? seq) (first-exp seq)) + (else (make-begin seq)))) + +(define (make-begin seq) (cons 'begin seq)) + + +(define (application? exp) (pair? exp)) +(define (operator exp) (car exp)) +(define (operands exp) (cdr exp)) + +(define (no-operands? ops) (null? ops)) +(define (first-operand ops) (car ops)) +(define (rest-operands ops) (cdr ops)) + + +(define (cond? exp) (tagged-list? exp 'cond)) + +(define (cond-clauses exp) (cdr exp)) + +(define (cond-else-clause? clause) + (eq? (cond-predicate clause) 'else)) + +(define (cond-predicate clause) (car clause)) + +(define (cond-actions clause) (cdr clause)) + +(define (cond->if exp) + (expand-clauses (cond-clauses exp))) + +(define (expand-clauses clauses) + (if (null? clauses) + 'false ; no else clause + (let ((first (car clauses)) + (rest (cdr clauses))) + (if (cond-else-clause? first) + (if (null? rest) + (sequence->exp (cond-actions first)) + (error "ELSE clause isn't last -- COND->IF" + clauses)) + (make-if (cond-predicate first) + (sequence->exp (cond-actions first)) + (expand-clauses rest)))))) + +;;;SECTION 4.1.3 + +(define (true? x) + (not (eq? x false))) + +(define (false? x) + (eq? x false)) + + +(define (make-procedure parameters body env) + (list 'procedure parameters body env)) + +(define (compound-procedure? p) + (tagged-list? p 'procedure)) + + +(define (procedure-parameters p) (cadr p)) +(define (procedure-body p) (caddr p)) +(define (procedure-environment p) (cadddr p)) + + +(define (enclosing-environment env) (cdr env)) + +(define (first-frame env) (car env)) + +(define the-empty-environment '()) + +(define (make-frame variables values) + (cons variables values)) + +(define (frame-variables frame) (car frame)) +(define (frame-values frame) (cdr frame)) + +(define (add-binding-to-frame! var val frame) + (set-car! frame (cons var (car frame))) + (set-cdr! frame (cons val (cdr frame)))) + +(define (extend-environment vars vals base-env) + (if (= (length vars) (length vals)) + (cons (make-frame vars vals) base-env) + (if (< (length vars) (length vals)) + (error "Too many arguments supplied" vars vals) + (error "Too few arguments supplied" vars vals)))) + +(define (lookup-variable-value var env) + (define (env-loop env) + (define (scan vars vals) + (cond ((null? vars) + (env-loop (enclosing-environment env))) + ((eq? var (car vars)) + (car vals)) + (else (scan (cdr vars) (cdr vals))))) + (if (eq? env the-empty-environment) + (error "Unbound variable" var) + (let ((frame (first-frame env))) + (scan (frame-variables frame) + (frame-values frame))))) + (env-loop env)) + +(define (set-variable-value! var val env) + (define (env-loop env) + (define (scan vars vals) + (cond ((null? vars) + (env-loop (enclosing-environment env))) + ((eq? var (car vars)) + (set-car! vals val)) + (else (scan (cdr vars) (cdr vals))))) + (if (eq? env the-empty-environment) + (error "Unbound variable -- SET!" var) + (let ((frame (first-frame env))) + (scan (frame-variables frame) + (frame-values frame))))) + (env-loop env)) + +(define (define-variable! var val env) + (let ((frame (first-frame env))) + (define (scan vars vals) + (cond ((null? vars) + (add-binding-to-frame! var val frame)) + ((eq? var (car vars)) + (set-car! vals val)) + (else (scan (cdr vars) (cdr vals))))) + (scan (frame-variables frame) + (frame-values frame)))) + +;;;SECTION 4.1.4 + +(define (setup-environment) + (let ((initial-env + (extend-environment (primitive-procedure-names) + (primitive-procedure-objects) + the-empty-environment))) + (define-variable! 'true true initial-env) + (define-variable! 'false false initial-env) + (define-variable! 'import + (list 'primitive + (lambda (name) + (define-variable! name + (list 'primitive (eval name)) + the-global-environment))) + initial-env) + initial-env)) + +;[do later] (define the-global-environment (setup-environment)) + +(define (primitive-procedure? proc) + (tagged-list? proc 'primitive)) + +(define (primitive-implementation proc) (cadr proc)) + +(define primitive-procedures + (list (list 'car car) + (list 'cdr cdr) + (list 'cons cons) + (list 'null? null?) + (list '+ +) + (list '- -) + (list '* *) + (list '/ /) + (list '= =) + (list 'list list) + (list 'append append) + (list 'equal? equal?) +;; more primitives + )) + +(define (primitive-procedure-names) + (map car + primitive-procedures)) + +(define (primitive-procedure-objects) + (map (lambda (proc) (list 'primitive (cadr proc))) + primitive-procedures)) + +;[moved to start of file] (define apply-in-underlying-scheme apply) + +(define (apply-primitive-procedure proc args) + (apply-in-underlying-scheme + (primitive-implementation proc) args)) + + + +(define input-prompt ";;; M-Eval input:") +(define output-prompt ";;; M-Eval value:") + +(define (driver-loop) + (prompt-for-input input-prompt) + (let ((input (read))) + (let ((output (mc-eval input the-global-environment))) + (announce-output output-prompt) + (user-print output))) + (driver-loop)) + +(define (prompt-for-input string) + (newline) (newline) (display string) (newline)) + +(define (announce-output string) + (newline) (display string) (newline)) + +(define (user-print object) + (if (compound-procedure? object) + (display (list 'compound-procedure + (procedure-parameters object) + (procedure-body object) + '<procedure-env>)) + (display object))) + +;;;Following are commented out so as not to be evaluated when +;;; the file is loaded. +;;(define the-global-environment (setup-environment)) +;;(driver-loop) + +;; Added at Berkeley: +(define the-global-environment '()) + +(define (mce) + (set! the-global-environment (setup-environment)) + (driver-loop)) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/obj.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/obj.scm new file mode 100644 index 0000000..d4a9d7a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/obj.scm @@ -0,0 +1,279 @@ +;;; obj.scm version 4.0 5/18/2000 +;;; -- implementation of the object-oriented syntax +;; By Matt Wright, based on a handout from MIT +;; Revised for STk by Brian Gaeke - removed scm and procedure->macro + +;;; Utilities + +;; MAKNAM: create a new symbol whose name is the concatenation of the +;; names of those in the symbol list SYMBOLS. +(define (maknam . symbols) + (string->symbol (apply string-append (map symbol->string symbols)))) + +;; ASK: send a message to an object + +; The dot in the first line of the definition of ASK, below, makes it +; take a variable number of arguments. The first argument is associated +; with the formal parameter OBJECT; the second with MESSAGE; any extra +; actual arguments are put in a list, and that list is associated with +; the formal parameter ARGS. (If there are only two actual args, then +; ARGS will be the empty list.) + +; APPLY takes two arguments, a procedure and a list, and applies the +; procedure to the things in the list, which are used as actual +; argument values. + +(define (ask object message . args) + (let ((method (object message))) + (if (method? method) + (apply method args) + (error "No method " message " in class " (cadr method))))) + +(define (no-method name) + (list 'no-method name)) + +(define (no-method? x) + (if (pair? x) + (eq? (car x) 'no-method) + #f)) + +(define (method? x) + (not (no-method? x))) + + +;; INSTANTIATE and INSTANTIATE-PARENT: Create an instance of a class + +; The difference is that only INSTANTIATE initializes the new object + +(define (instantiate class . arguments) + (let ((new-instance (apply (class 'instantiate) arguments))) + (ask new-instance 'initialize new-instance) + new-instance)) + +(define (instantiate-parent class . arguments) + (apply (class 'instantiate) arguments)) + +;; GET-METHOD: Send a message to several objects and return the first +;; method found (for multiple inheritance) + +(define (get-method give-up-name message . objects) + (if (null? objects) + (no-method give-up-name) + (let ((method ((car objects) message))) + (if (method? method) + method + (apply get-method (cons give-up-name + (cons message (cdr objects)) )))))) + + + +;; USUAL: Invoke a parent's method +;; Note: The 'send-usual-to-parent method is put in automatically by +;; define-class. + +(define-macro (usual . args) + `(ask dispatch 'send-usual-to-parent . ,args)) + + +;; DEFINE-CLASS: Create a new class. + +; DEFINE-CLASS is a special form. When you type (define-class body...) +; it's as if you typed (make-definitions (quote body...)). In other +; words, the argument to DEFINE-CLASS isn't evaluated. This makes sense +; because the argument isn't Scheme syntax, but rather is the special +; object-oriented programming language we're defining. +; Make-definitions transforms the OOP notation into a standard Scheme +; expression, then uses EVAL to evaluate the result. (You'll see EVAL +; again in chapter 4 with the metacircular evaluator.) + +; When you define a class named THING, for example, two global Scheme +; variables are created. The variable THING has as its value the +; procedure that represents the class. This procedure is invoked by +; INSTANTIATE to create instances of the class. A second variable, +; THING-DEFINITION, has as its value the text of the Scheme expression +; that defines THING. This text is used only by SHOW-CLASS, the +; procedure that lets you examine the result of the OOP-to-Scheme +; translation process. + +(define-macro (define-class . body) (make-definitions body)) + +(define (make-definitions form) + (let ((definition (translate form))) + (eval `(define ,(maknam (class-name form) '-definition) ',definition)) + (eval definition) + (list 'quote (class-name form)))) + +(define (show-class name) + (eval (maknam name '-definition)) ) + +; TRANSLATE does all the work of DEFINE-CLASS. +; The backquote operator (`) works just like regular quote (') except +; that expressions proceeded by a comma are evaluated. Also, expressions +; proceeded by ",@" evaluate to lists; the lists are inserted into the +; text without the outermost level of parentheses. + +(define (translate form) + (cond ((null? form) (error "Define-class: empty body")) + ((not (null? (obj-filter form (lambda (x) (not (pair? x)))))) + (error "Each argument to define-class must be a list")) + ((not (null? (extra-clauses form))) + (error "Unrecognized clause in define-class:" (extra-clauses form))) + (else + `(define ,(class-name form) + (let ,(class-var-bindings form) + (lambda (class-message) + (cond + ,@(class-variable-methods form) + ((eq? class-message 'instantiate) + (lambda ,(instantiation-vars form) + (let ((self '()) + ,@(parent-let-list form) + ,@(instance-vars-let-list form)) + (define (dispatch message) + (cond + ,(init-clause form) + ,(usual-clause form) + ,@(method-clauses form) + ,@(local-variable-methods form) + ,(else-clause form) )) + dispatch ))) + (else (error "Bad message to class" class-message)) ))))))) + +(define *legal-clauses* + '(instance-vars class-vars method default-method parent initialize)) + +(define (extra-clauses form) + (obj-filter (cdr form) + (lambda (x) (null? (member (car x) *legal-clauses*))))) + +(define class-name caar) + +(define (class-var-bindings form) + (let ((classvar-clause (find-a-clause 'class-vars form))) + (if (null? classvar-clause) + '() + (cdr classvar-clause) ))) + +(define instantiation-vars cdar) + +(define (parent-let-list form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map (lambda (parent-and-args) + (list (maknam 'my- (car parent-and-args)) + (cons 'instantiate-parent parent-and-args))) + (cdr parent-clause))))) + +(define (instance-vars-let-list form) + (let ((instance-vars-clause (find-a-clause 'instance-vars form))) + (if (null? instance-vars-clause) + '() + (cdr instance-vars-clause)))) + +(define (init-clause form) + (define (parent-initialization form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map + (lambda (parent-and-args) + `(ask ,(maknam 'my- (car parent-and-args)) 'initialize self) ) + (cdr parent-clause) )))) + (define (my-initialization form) + (let ((init-clause (find-a-clause 'initialize form))) + (if (null? init-clause) '() + (cdr init-clause)))) + (define (init-body form) + (append (parent-initialization form) + (my-initialization form) )) + + `((eq? message 'initialize) + (lambda (value-for-self) + (set! self value-for-self) + ,@(init-body form) ))) + +(define (variable-list var-type form) + (let ((clause (find-a-clause var-type form))) + (if (null? clause) + '() + (map car (cdr clause)) ))) + +(define (class-variable-methods form) + (cons `((eq? class-message 'class-name) (lambda () ',(class-name form))) + (map (lambda (variable) + `((eq? class-message ',variable) (lambda () ,variable))) + (variable-list 'class-vars form)))) + +(define (local-variable-methods form) + (cons `((eq? message 'class-name) (lambda () ',(class-name form))) + (map (lambda (variable) + `((eq? message ',variable) (lambda () ,variable))) + (append (cdr (car form)) + (variable-list 'instance-vars form) + (variable-list 'class-vars form))))) + +(define (method-clauses form) + (map + (lambda (method-defn) + (let ((this-message (car (cadr method-defn))) + (args (cdr (cadr method-defn))) + (body (cddr method-defn))) + `((eq? message ',this-message) + (lambda ,args ,@body)))) + (obj-filter (cdr form) (lambda (x) (eq? (car x) 'method))) )) + +(define (parent-list form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map (lambda (class) (maknam 'my- class)) + (map car (cdr parent-clause)))))) + +(define (usual-clause form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + `((eq? message 'send-usual-to-parent) + (error "Can't use USUAL without a parent." ',(class-name form))) + `((eq? message 'send-usual-to-parent) + (lambda (message . args) + (let ((method (get-method ',(class-name form) + message + ,@(parent-list form)))) + (if (method? method) + (apply method args) + (error "No USUAL method" message ',(class-name form)) ))))))) + +(define (else-clause form) + (let ((parent-clause (find-a-clause 'parent form)) + (default-method (find-a-clause 'default-method form))) + (cond + ((and (null? parent-clause) (null? default-method)) + `(else (no-method ',(class-name form)))) + ((null? parent-clause) + `(else (lambda args ,@(cdr default-method)))) + ((null? default-method) + `(else (get-method ',(class-name form) message ,@(parent-list form))) ) + (else + `(else (let ((method (get-method ',(class-name form) + message + ,@(parent-list form)))) + (if (method? method) + method + (lambda args ,@(cdr default-method)) ))))))) + +(define (find-a-clause clause-name form) + (let ((clauses (obj-filter (cdr form) + (lambda (x) (eq? (car x) clause-name))))) + (cond ((null? clauses) '()) + ((null? (cdr clauses)) (car clauses)) + (else (error "Error in define-class: too many " + clause-name "clauses.")) ))) + +(define (obj-filter l pred) + (cond ((null? l) '()) + ((pred (car l)) + (cons (car l) (obj-filter (cdr l) pred))) + (else (obj-filter (cdr l) pred)))) + +(provide "obj") diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/old-obj.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/old-obj.scm new file mode 100644 index 0000000..cee6aae --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/old-obj.scm @@ -0,0 +1,277 @@ +;;; obj.scm version 3.0 1/9/95 +;;; -- implementation of the object-oriented syntax +;;; This version is supposed to work with Unix SCM, PC SCM, and Mac Gambit +;;; This version does class names right. +;;; Also, explicit methods come before instance variable methods +;; By Matt Wright, based on a handout from MIT + +;; ASK: send a message to an object + +; The dot in the first line of the definition of ASK, below, makes it +; take a variable number of arguments. The first argument is associated +; with the formal parameter OBJECT; the second with MESSAGE; any extra +; actual arguments are put in a list, and that list is associated with +; the formal parameter ARGS. (If there are only two actual args, then +; ARGS will be the empty list.) + +; APPLY takes two arguments, a procedure and a list, and applies the +; procedure to the things in the list, which are used as actual +; argument values. + +(define (ask object message . args) + (let ((method (object message))) + (if (method? method) + (apply method args) + (error "No method" message (cadr method))))) + +(define (no-method name) + (list 'no-method name)) + +(define (no-method? x) + (if (pair? x) + (eq? (car x) 'no-method) + #f)) + +(define (method? x) + (not (no-method? x))) + + +;; INSTANTIATE and INSTANTIATE-PARENT: Create an instance of a class + +; The difference is that only INSTANTIATE initializes the new object + +(define (instantiate class . arguments) + (let ((new-instance (apply (class 'instantiate) arguments))) + (ask new-instance 'initialize new-instance) + new-instance)) + +(define (instantiate-parent class . arguments) + (apply (class 'instantiate) arguments)) + +;; GET-METHOD: Send a message to several objects and return the first +;; method found (for multiple inheritance) + +(define (get-method give-up-name message . objects) + (if (null? objects) + (no-method give-up-name) + (let ((method ((car objects) message))) + (if (method? method) + method + (apply get-method (cons give-up-name + (cons message (cdr objects)) )))))) + + + +;; USUAL: Invoke a parent's method +;; Note: The 'send-usual-to-parent method is put in automatically by +;; define-class. + +(if scm? + (defmacro usual args `(ask dispatch 'send-usual-to-parent . ,args)) + (eval '(define-macro (usual . args) + `(ask dispatch 'send-usual-to-parent . ,args)))) + + +;; DEFINE-CLASS: Create a new class. + +; DEFINE-CLASS is a special form. When you type (define-class body...) +; it's as if you typed (make-definitions (quote body...)). In other +; words, the argument to DEFINE-CLASS isn't evaluated. This makes sense +; because the argument isn't Scheme syntax, but rather is the special +; object-oriented programming language we're defining. +; Make-definitions transforms the OOP notation into a standard Scheme +; expression, then uses EVAL to evaluate the result. (You'll see EVAL +; again in chapter 4 with the metacircular evaluator.) + +; When you define a class named THING, for example, two global Scheme +; variables are created. The variable THING has as its value the +; procedure that represents the class. This procedure is invoked by +; INSTANTIATE to create instances of the class. A second variable, +; THING-DEFINITION, has as its value the text of the Scheme expression +; that defines THING. This text is used only by SHOW-CLASS, the +; procedure that lets you examine the result of the OOP-to-Scheme +; translation process. + +(if scm? + (defmacro define-class body (make-definitions body)) + (eval '(define-macro (define-class . body) (make-definitions body)))) + +(define (make-definitions form) + (let ((definition (translate form))) + (eval `(define ,(word (class-name form) '-definition) ',definition)) + (eval definition) + (list 'quote (class-name form)))) + +(define (show-class name) + (eval (word name '-definition)) ) + +; TRANSLATE does all the work of DEFINE-CLASS. +; The backquote operator (`) works just like regular quote (') except +; that expressions proceeded by a comma are evaluated. Also, expressions +; proceeded by ",@" evaluate to lists; the lists are inserted into the +; text without the outermost level of parentheses. + +(define (translate form) + (cond ((null? form) (error "Define-class: empty body")) + ((not (null? (obj-filter form (lambda (x) (not (pair? x)))))) + (error "Each argument to define-class must be a list")) + ((not (null? (extra-clauses form))) + (error "Unrecognized clause in define-class:" (extra-clauses form))) + (else + `(define ,(class-name form) + (let ,(class-var-bindings form) + (lambda (class-message) + (cond + ,@(class-variable-methods form) + ((eq? class-message 'instantiate) + (lambda ,(instantiation-vars form) + (let ((self '()) + ,@(parent-let-list form) + ,@(instance-vars-let-list form)) + (define (dispatch message) + (cond + ,(init-clause form) + ,(usual-clause form) + ,@(method-clauses form) + ,@(local-variable-methods form) + ,(else-clause form) )) + dispatch ))) + (else (error "Bad message to class" class-message)) ))))))) + +(define *legal-clauses* + '(instance-vars class-vars method default-method parent initialize)) + +(define (extra-clauses form) + (obj-filter (cdr form) + (lambda (x) (not (member? (car x) *legal-clauses*))))) + +(define class-name caar) + +(define (class-var-bindings form) + (let ((classvar-clause (find-a-clause 'class-vars form))) + (if (null? classvar-clause) + '() + (cdr classvar-clause) ))) + +(define instantiation-vars cdar) + +(define (parent-let-list form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map (lambda (parent-and-args) + (list (word 'my- (car parent-and-args)) + (cons 'instantiate-parent parent-and-args))) + (cdr parent-clause))))) + +(define (instance-vars-let-list form) + (let ((instance-vars-clause (find-a-clause 'instance-vars form))) + (if (null? instance-vars-clause) + '() + (cdr instance-vars-clause)))) + +(define (init-clause form) + (define (parent-initialization form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map + (lambda (parent-and-args) + `(ask ,(word 'my- (car parent-and-args)) 'initialize self) ) + (cdr parent-clause) )))) + (define (my-initialization form) + (let ((init-clause (find-a-clause 'initialize form))) + (if (null? init-clause) '() + (cdr init-clause)))) + (define (init-body form) + (append (parent-initialization form) + (my-initialization form) )) + + `((eq? message 'initialize) + (lambda (value-for-self) + (set! self value-for-self) + ,@(init-body form) ))) + +(define (variable-list var-type form) + (let ((clause (find-a-clause var-type form))) + (if (null? clause) + '() + (map car (cdr clause)) ))) + +(define (class-variable-methods form) + (cons `((eq? class-message 'class-name) (lambda () ',(class-name form))) + (map (lambda (variable) + `((eq? class-message ',variable) (lambda () ,variable))) + (variable-list 'class-vars form)))) + +(define (local-variable-methods form) + (cons `((eq? message 'class-name) (lambda () ',(class-name form))) + (map (lambda (variable) + `((eq? message ',variable) (lambda () ,variable))) + (append (cdr (car form)) + (variable-list 'instance-vars form) + (variable-list 'class-vars form))))) + +(define (method-clauses form) + (map + (lambda (method-defn) + (let ((this-message (car (cadr method-defn))) + (args (cdr (cadr method-defn))) + (body (cddr method-defn))) + `((eq? message ',this-message) + (lambda ,args ,@body)))) + (obj-filter (cdr form) (lambda (x) (eq? (car x) 'method))) )) + +(define (parent-list form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map (lambda (class) (word 'my- class)) + (map car (cdr parent-clause)))))) + +(define (usual-clause form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + `((eq? message 'send-usual-to-parent) + (error "Can't use USUAL without a parent." ',(class-name form))) + `((eq? message 'send-usual-to-parent) + (lambda (message . args) + (let ((method (get-method ',(class-name form) + message + ,@(parent-list form)))) + (if (method? method) + (apply method args) + (error "No USUAL method" message ',(class-name form)) ))))))) + +(define (else-clause form) + (let ((parent-clause (find-a-clause 'parent form)) + (default-method (find-a-clause 'default-method form))) + (cond + ((and (null? parent-clause) (null? default-method)) + `(else (no-method ',(class-name form)))) + ((null? parent-clause) + `(else (lambda args ,@(cdr default-method)))) + ((null? default-method) + `(else (get-method ',(class-name form) message ,@(parent-list form))) ) + (else + `(else (let ((method (get-method ',(class-name form) + message + ,@(parent-list form)))) + (if (method? method) + method + (lambda args ,@(cdr default-method)) ))))))) + +(define (find-a-clause clause-name form) + (let ((clauses (obj-filter (cdr form) + (lambda (x) (eq? (car x) clause-name))))) + (cond ((null? clauses) '()) + ((null? (cdr clauses)) (car clauses)) + (else (error "Error in define-class: too many " + clause-name "clauses.")) ))) + +(define (obj-filter l pred) + (cond ((null? l) '()) + ((pred (car l)) + (cons (car l) (obj-filter (cdr l) pred))) + (else (obj-filter (cdr l) pred)))) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/picture.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/picture.scm new file mode 100644 index 0000000..7369e42 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/picture.scm @@ -0,0 +1,129 @@ +;; Code for CS61A project 2 -- picture language + +(define (flipped-pairs painter) + (let ((painter2 (beside painter (flip-vert painter)))) + (below painter2 painter2))) + +(define (right-split painter n) + (if (= n 0) + painter + (let ((smaller (right-split painter (- n 1)))) + (beside painter (below smaller smaller))))) + +(define (corner-split painter n) + (if (= n 0) + painter + (let ((up (up-split painter (- n 1))) + (right (right-split painter (- n 1)))) + (let ((top-left (beside up up)) + (bottom-right (below right right)) + (corner (corner-split painter (- n 1)))) + (beside (below painter top-left) + (below bottom-right corner)))))) + +(define (square-limit painter n) + (let ((quarter (corner-split painter n))) + (let ((half (beside (flip-horiz quarter) quarter))) + (below (flip-vert half) half)))) + +(define (square-of-four tl tr bl br) + (lambda (painter) + (let ((top (beside (tl painter) (tr painter))) + (bottom (beside (bl painter) (br painter)))) + (below bottom top)))) + +(define (identity x) x) + +(define (flipped-pairs painter) + (let ((combine4 (square-of-four identity flip-vert + identity flip-vert))) + (combine4 painter))) + +;; or + +; (define flipped-pairs +; (square-of-four identity flip-vert identity flip-vert)) + +(define (square-limit painter n) + (let ((combine4 (square-of-four flip-horiz identity + rotate180 flip-vert))) + (combine4 (corner-split painter n)))) + +(define (frame-coord-map frame) + (lambda (v) + (add-vect + (origin-frame frame) + (add-vect (scale-vect (xcor-vect v) + (edge1-frame frame)) + (scale-vect (ycor-vect v) + (edge2-frame frame)))))) + +(define (segments->painter segment-list) + (lambda (frame) + (for-each + (lambda (segment) + (draw-line + ((frame-coord-map frame) (start-segment segment)) + ((frame-coord-map frame) (end-segment segment)))) + segment-list))) + +(define (draw-line v1 v2) + (penup) + (setxy (- (* (xcor-vect v1) 200) 100) + (- (* (ycor-vect v1) 200) 100)) + (pendown) + (setxy (- (* (xcor-vect v2) 200) 100) + (- (* (ycor-vect v2) 200) 100))) + +(define (transform-painter painter origin corner1 corner2) + (lambda (frame) + (let ((m (frame-coord-map frame))) + (let ((new-origin (m origin))) + (painter + (make-frame new-origin + (sub-vect (m corner1) new-origin) + (sub-vect (m corner2) new-origin))))))) + +(define (flip-vert painter) + (transform-painter painter + (make-vect 0.0 1.0) + (make-vect 1.0 1.0) + (make-vect 0.0 0.0))) + +(define (shrink-to-upper-right painter) + (transform-painter painter + (make-vect 0.5 0.5) + (make-vect 1.0 0.5) + (make-vect 0.5 1.0))) + +(define (rotate90 painter) + (transform-painter painter + (make-vect 1.0 0.0) + (make-vect 1.0 1.0) + (make-vect 0.0 0.0))) + +(define (squash-inwards painter) + (transform-painter painter + (make-vect 0.0 0.0) + (make-vect 0.65 0.35) + (make-vect 0.35 0.65))) + +(define (beside painter1 painter2) + (let ((split-point (make-vect 0.5 0.0))) + (let ((paint-left + (transform-painter painter1 + (make-vect 0.0 0.0) + split-point + (make-vect 0.0 1.0))) + (paint-right + (transform-painter painter2 + split-point + (make-vect 1.0 0.0) + (make-vect 0.5 1.0)))) + (lambda (frame) + (paint-left frame) + (paint-right frame))))) + +(define full-frame (make-frame (make-vect -0.5 -0.5) + (make-vect 2 0) + (make-vect 0 2))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/pigl.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/pigl.scm new file mode 100644 index 0000000..74e028e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/pigl.scm @@ -0,0 +1,10 @@ +(define (pigl wd) + (if (pl-done? wd) + (word wd 'ay) + (pigl (word (bf wd) (first wd))) ) ) + +(define (pl-done? wd) + (vowel? (first wd)) ) + +(define (vowel? letter) + (member? letter '(a e i o u)) ) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/prisoner.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/prisoner.scm new file mode 100644 index 0000000..c81e90c --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/prisoner.scm @@ -0,0 +1,133 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; OVERVIEW: +;; +;; +;; The PLAY-LOOP procedure takes as its arguments two prisoner's +;; dilemma strategies, and plays an iterated game of approximately +;; one hundred rounds. A strategy is a procedure that takes +;; two arguments: a history of the player's previous plays and +;; a history of the other player's previous plays. A history consists +;; of a sentence of C's and D's. Likewise, a strategy procedure +;; returns either the word C (for "cooperate") or D ("defect"). +;; We also need a way to find out the player's scores; GET-SCORES +;; takes two histories and computes the net score for one player. +;; +;; Note that we are inventing various types of objects: strategies, +;; histories, etc. Each type of thing has certain specified +;; properties. For example, a history is a sentence with zero or +;; more words, each of which is a C or D. To help us use these +;; objects, we write procedures that let us forget the details and +;; think about things in terms of histories and rounds, not in terms +;; of sentences and words. (For example, see GET-NTH-FROM-LAST-PLAY, +;; ADD-TO-HISTORY, etc.) +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define (play-loop strategy1 strategy2) + + ;; returns final scores + + (define (play-loop-helper strat1 strat2 history1 history2 counter limit) + (if (= counter limit) + (final-scores history1 history2 limit) + (let ((result1 (strat1 history1 history2)) + (result2 (strat2 history2 history1))) + ;; note that the strategy's + ;; own history comes first + (play-loop-helper strat1 strat2 + (add-to-history result1 history1) + (add-to-history result2 history2) + (1+ counter) + limit)))) ; end of helper + + (play-loop-helper strategy1 strategy2 ; play-loop body + empty-history empty-history + 0 + (+ 90 (random 21)))) + + + +(define (final-scores history1 history2 num-of-rounds) + + ;; returns average score per round for the two histories + + (se (/ (get-scores history1 history2) num-of-rounds) + (/ (get-scores history2 history1) num-of-rounds) )) + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Procedures about histories +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define empty-history '()) + +(define empty-history? empty?) + +(define (add-to-history result history) + (se history result)) + +(define (last-play history) + (last history)) + +(define (previous-history history) + (bl history)) + +(define (get-nth-to-last-play n history) + (cond ((empty? history) '()) + ((= n 1) (last history)) + (else (get-nth-to-last-play (1- n) (butlast history))))) + + +(define (get-scores my-hist other-hist) + + ;; returns total score for first player + + (if (or (empty? my-hist) (empty? other-hist)) + 0 + (+ (get-score (first my-hist) (first other-hist)) + (get-scores (bf my-hist) (bf other-hist))))) + +(define (get-score my-play other-play) + + ;; returns the score of the first player for this round + + (let ((round (se my-play other-play))) + (cond ((equal? round '(C C)) 3) + ((equal? round '(C D)) 0) + ((equal? round '(D C)) 5) + ((equal? round '(D D)) 1) ))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Some strategies. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(define (all-defect my-history other-history) + 'D) + +(define (poor-trusting-fool my-history other-history) + 'C) + +(define (unforgiving my-history other-history) + (define (ever-defected? history) + (if (empty-history? history) + #f + (or (equal? (last-play history) 'D) + (ever-defected? (previous-history history))))) + (if (ever-defected? other-history) 'D 'C)) + +(define (tit-for-tat my-history other-history) + (if (empty-history? other-history) + 'C + (last-play other-history))) + +(define (random-strategy my-history other-history) + (nth (random 2) '(C D))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/pronounce.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/pronounce.scm new file mode 100644 index 0000000..638e160 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/pronounce.scm @@ -0,0 +1,165 @@ +; How to pronounce cxr-family function names + +(define (say name) + (accent (pronounce name))) + +; PRONOUNCE takes a cxr-family word as argument and returns a sentence +; of syllables. + +(define (pronounce name) + (cond ((eq? name 'car) '(car)) + ((eq? name 'caar) '(cuh are)) + ((empty? name) '()) + ((eq? (first-two name) 'ca) (se 'caa (pronounce (bf-two name)))) + ((eq? (first name) 'c) (se 'cuh (pronounce (bf name)))) + ((eq? (last-three name) 'dar) (se (pronounce (bl-three name)) 'dar)) + ((eq? (last-two name) 'ar) (se (pronounce (bl-two name)) 'are)) + ((eq? (last-two name) 'dr) (se (pronounce (bl-two name)) 'der)) + ((eq? (first-two name) 'da) (se 'daa (pronounce (bf-two name)))) + ((eq? (first name) 'a) (se 'aa (pronounce (bf name)))) + (else (se 'de (pronounce (bf name)))))) + +; ACCENT takes a sentence of syllables (as returned by PRONOUNCE) and inserts +; an exclamation point at the emphasized syllable. I'm less sure that these +; rules are universally agreed to than for PRONOUNCE. + +; In particular, all my life I've said "CUH de der" for cddr, but apparently +; to be consistent I should be saying "cuh DE der." I think I have heard people +; say it that way, though, so I'm reluctant to special-case it like the first +; syllable of caar in PRONOUNCE. + +(define (accent syls) + (define (help prev rest) + (if (null? rest) + (se (word prev '!)) + (let ((winover (assoc prev '((caa . (daa dar de der)) + (cuh . (der)) + (aa . (dar de der)) + (daa . (aa are daa dar de der)) + (de . (de der)))))) + (if (member? (car rest) (cdr winover)) + (cons (word prev '!) rest) + (cons prev (help (car rest) (cdr rest))))))) + (if (null? (cdr syls)) + syls + (help (car syls) (cdr syls)))) + +; Utility functions to get a table of pronunciations of all names up to length n + +(define (table n) + (for-each (lambda (w) (print (list w (say w)))) (cr n))) + +(define (cr n) + (if (= n 0) + '() + (append (cr (- n 1)) + (map (lambda (w) (word 'c w 'r)) (cross n))))) + +(define (cross n) + (if (= n 0) + '("") + (let ((small (cross (- n 1)))) + (append (map (lambda (w) (word w 'a)) small) + (map (lambda (w) (word w 'd)) small))))) + +; Helper functions are obvious except to note that they test for too-short +; arguments so that we can make more specific tests first in PRONOUNCE above. +; ("More specific" means that we test for long substrings before short ones.) + +(define (first-two wd) + (if (< (count wd) 2) + wd + (word (first wd) (first (bf wd))))) + +(define (bf-two wd) + (if (< (count wd) 2) + "" + (bf (bf wd)))) + +(define (last-two wd) + (if (< (count wd) 2) + wd + (word (last (bl wd)) (last wd)))) + +(define (bl-two wd) + (if (< (count wd) 2) + "" + (bl (bl wd)))) + +(define (last-three wd) + (if (< (count wd) 3) + wd + (word (last (bl (bl wd))) (last (bl wd)) (last wd)))) + +(define (bl-three wd) + (if (< (count wd) 3) + "" + (bl (bl (bl wd))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Results: + +; > (table 5) +; (car (car)) +; (cdr (cuh! der)) +; (caar (cuh are!)) +; (cdar (cuh dar!)) +; (cadr (caa! der)) +; (cddr (cuh de! der)) +; (caaar (caa aa are!)) +; (cdaar (cuh daa! are)) +; (cadar (caa! dar)) +; (cddar (cuh de dar!)) +; (caadr (caa aa! der)) +; (cdadr (cuh daa! der)) +; (caddr (caa! de der)) +; (cdddr (cuh de! de der)) +; (caaaar (caa aa aa are!)) +; (cdaaar (cuh daa! aa are)) +; (cadaar (caa! daa are)) +; (cddaar (cuh de daa! are)) +; (caadar (caa aa! dar)) +; (cdadar (cuh daa! dar)) +; (caddar (caa! de dar)) +; (cdddar (cuh de! de dar)) +; (caaadr (caa aa aa! der)) +; (cdaadr (cuh daa! aa der)) +; (cadadr (caa! daa der)) +; (cddadr (cuh de daa! der)) +; (caaddr (caa aa! de der)) +; (cdaddr (cuh daa! de der)) +; (cadddr (caa! de de der)) +; (cddddr (cuh de! de de der)) +; (caaaaar (caa aa aa aa are!)) +; (cdaaaar (cuh daa! aa aa are)) +; (cadaaar (caa! daa aa are)) +; (cddaaar (cuh de daa! aa are)) +; (caadaar (caa aa daa! are)) +; (cdadaar (cuh daa! daa are)) +; (caddaar (caa! de daa are)) +; (cdddaar (cuh de! de daa are)) +; (caaadar (caa aa aa! dar)) +; (cdaadar (cuh daa! aa dar)) +; (cadadar (caa! daa dar)) +; (cddadar (cuh de daa! dar)) +; (caaddar (caa aa! de dar)) +; (cdaddar (cuh daa! de dar)) +; (cadddar (caa! de de dar)) +; (cddddar (cuh de! de de dar)) +; (caaaadr (caa aa aa aa! der)) +; (cdaaadr (cuh daa! aa aa der)) +; (cadaadr (caa! daa aa der)) +; (cddaadr (cuh de daa! aa der)) +; (caadadr (caa aa daa! der)) +; (cdadadr (cuh daa! daa der)) +; (caddadr (caa! de daa der)) +; (cdddadr (cuh de! de daa der)) +; (caaaddr (caa aa aa! de der)) +; (cdaaddr (cuh daa! aa de der)) +; (cadaddr (caa! daa de der)) +; (cddaddr (cuh de daa! de der)) +; (caadddr (caa aa! de de der)) +; (cdadddr (cuh daa! de de der)) +; (caddddr (caa! de de de der)) +; (cdddddr (cuh de! de de de der)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/query.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/query.scm new file mode 100644 index 0000000..f103ac2 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/query.scm @@ -0,0 +1,667 @@ +;;;;QUERY SYSTEM FROM SECTION 4.4.4 OF +;;;; STRUCTURE AND INTERPRETATION OF COMPUTER PROGRAMS + +;;;;Matches code in ch4.scm +;;;;Includes: +;;;; -- supporting code from 4.1, chapter 3, and instructor's manual +;;;; -- data base from Section 4.4.1 -- see microshaft-data-base below + +;;;;This file can be loaded into Scheme as a whole. +;;;;In order to run the query system, the Scheme must support streams. + +;;;;NB. PUT's are commented out and no top-level table is set up. +;;;;Instead use initialize-data-base (from manual), supplied in this file. + + +;;;SECTION 4.4.4.1 +;;;The Driver Loop and Instantiation + +(define input-prompt ";;; Query input:") +(define output-prompt ";;; Query results:") + +(define (query-driver-loop) + (prompt-for-input input-prompt) + (let ((q (query-syntax-process (read)))) + (cond ((assertion-to-be-added? q) + (add-rule-or-assertion! (add-assertion-body q)) + (newline) + (display "Assertion added to data base.") + (query-driver-loop)) + (else + (newline) + (display output-prompt) + ;; [extra newline at end] (announce-output output-prompt) + (display-stream + (stream-map + (lambda (frame) + (instantiate q + frame + (lambda (v f) + (contract-question-mark v)))) + (qeval q (singleton-stream '())))) + (query-driver-loop))))) + +(define (instantiate exp frame unbound-var-handler) + (define (copy exp) + (cond ((var? exp) + (let ((binding (binding-in-frame exp frame))) + (if binding + (copy (binding-value binding)) + (unbound-var-handler exp frame)))) + ((pair? exp) + (cons (copy (car exp)) (copy (cdr exp)))) + (else exp))) + (copy exp)) + + +;;;SECTION 4.4.4.2 +;;;The Evaluator + +(define (qeval query frame-stream) + (let ((qproc (get (type query) 'qeval))) + (if qproc + (qproc (contents query) frame-stream) + (simple-query query frame-stream)))) + +;;;Simple queries + +(define (simple-query query-pattern frame-stream) + (stream-flatmap + (lambda (frame) + (stream-append-delayed + (find-assertions query-pattern frame) + (delay (apply-rules query-pattern frame)))) + frame-stream)) + +;;;Compound queries + +(define (conjoin conjuncts frame-stream) + (if (empty-conjunction? conjuncts) + frame-stream + (conjoin (rest-conjuncts conjuncts) + (qeval (first-conjunct conjuncts) + frame-stream)))) + +;;(put 'and 'qeval conjoin) + + +(define (disjoin disjuncts frame-stream) + (if (empty-disjunction? disjuncts) + the-empty-stream + (interleave-delayed + (qeval (first-disjunct disjuncts) frame-stream) + (delay (disjoin (rest-disjuncts disjuncts) + frame-stream))))) + +;;(put 'or 'qeval disjoin) + +;;;Filters + +(define (negate operands frame-stream) + (stream-flatmap + (lambda (frame) + (if (stream-null? (qeval (negated-query operands) + (singleton-stream frame))) + (singleton-stream frame) + the-empty-stream)) + frame-stream)) + +;;(put 'not 'qeval negate) + +(define (lisp-value call frame-stream) + (stream-flatmap + (lambda (frame) + (if (execute + (instantiate + call + frame + (lambda (v f) + (error "Unknown pat var -- LISP-VALUE" v)))) + (singleton-stream frame) + the-empty-stream)) + frame-stream)) + +;;(put 'lisp-value 'qeval lisp-value) + +(define (execute exp) + (apply (eval (predicate exp)) ; (eval (...) user-initial-environment) + (args exp))) + +(define (always-true ignore frame-stream) frame-stream) + +;;(put 'always-true 'qeval always-true) + +;;;SECTION 4.4.4.3 +;;;Finding Assertions by Pattern Matching + +(define (find-assertions pattern frame) + (stream-flatmap (lambda (datum) + (check-an-assertion datum pattern frame)) + (fetch-assertions pattern frame))) + +(define (check-an-assertion assertion query-pat query-frame) + (let ((match-result + (pattern-match query-pat assertion query-frame))) + (if (eq? match-result 'failed) + the-empty-stream + (singleton-stream match-result)))) + +(define (pattern-match pat dat frame) + (cond ((eq? frame 'failed) 'failed) + ((equal? pat dat) frame) + ((var? pat) (extend-if-consistent pat dat frame)) + ((and (pair? pat) (pair? dat)) + (pattern-match (cdr pat) + (cdr dat) + (pattern-match (car pat) + (car dat) + frame))) + (else 'failed))) + +(define (extend-if-consistent var dat frame) + (let ((binding (binding-in-frame var frame))) + (if binding + (pattern-match (binding-value binding) dat frame) + (extend var dat frame)))) + +;;;SECTION 4.4.4.4 +;;;Rules and Unification + +(define (apply-rules pattern frame) + (stream-flatmap (lambda (rule) + (apply-a-rule rule pattern frame)) + (fetch-rules pattern frame))) + +(define (apply-a-rule rule query-pattern query-frame) + (let ((clean-rule (rename-variables-in rule))) + (let ((unify-result + (unify-match query-pattern + (conclusion clean-rule) + query-frame))) + (if (eq? unify-result 'failed) + the-empty-stream + (qeval (rule-body clean-rule) + (singleton-stream unify-result)))))) + +(define (rename-variables-in rule) + (let ((rule-application-id (new-rule-application-id))) + (define (tree-walk exp) + (cond ((var? exp) + (make-new-variable exp rule-application-id)) + ((pair? exp) + (cons (tree-walk (car exp)) + (tree-walk (cdr exp)))) + (else exp))) + (tree-walk rule))) + +(define (unify-match p1 p2 frame) + (cond ((eq? frame 'failed) 'failed) + ((equal? p1 p2) frame) + ((var? p1) (extend-if-possible p1 p2 frame)) + ((var? p2) (extend-if-possible p2 p1 frame)) ; {\em ; ***} + ((and (pair? p1) (pair? p2)) + (unify-match (cdr p1) + (cdr p2) + (unify-match (car p1) + (car p2) + frame))) + (else 'failed))) + +(define (extend-if-possible var val frame) + (let ((binding (binding-in-frame var frame))) + (cond (binding + (unify-match + (binding-value binding) val frame)) + ((var? val) ; {\em ; ***} + (let ((binding (binding-in-frame val frame))) + (if binding + (unify-match + var (binding-value binding) frame) + (extend var val frame)))) + ((depends-on? val var frame) ; {\em ; ***} + 'failed) + (else (extend var val frame))))) + +(define (depends-on? exp var frame) + (define (tree-walk e) + (cond ((var? e) + (if (equal? var e) + true + (let ((b (binding-in-frame e frame))) + (if b + (tree-walk (binding-value b)) + false)))) + ((pair? e) + (or (tree-walk (car e)) + (tree-walk (cdr e)))) + (else false))) + (tree-walk exp)) + +;;;SECTION 4.4.4.5 +;;;Maintaining the Data Base + +(define THE-ASSERTIONS the-empty-stream) + +(define (fetch-assertions pattern frame) + (if (use-index? pattern) + (get-indexed-assertions pattern) + (get-all-assertions))) + +(define (get-all-assertions) THE-ASSERTIONS) + +(define (get-indexed-assertions pattern) + (get-stream (index-key-of pattern) 'assertion-stream)) + +(define (get-stream key1 key2) + (let ((s (get key1 key2))) + (if s s the-empty-stream))) + +(define THE-RULES the-empty-stream) + +(define (fetch-rules pattern frame) + (if (use-index? pattern) + (get-indexed-rules pattern) + (get-all-rules))) + +(define (get-all-rules) THE-RULES) + +(define (get-indexed-rules pattern) + (stream-append + (get-stream (index-key-of pattern) 'rule-stream) + (get-stream '? 'rule-stream))) + +(define (add-rule-or-assertion! assertion) + (if (rule? assertion) + (add-rule! assertion) + (add-assertion! assertion))) + +(define (add-assertion! assertion) + (store-assertion-in-index assertion) + (let ((old-assertions THE-ASSERTIONS)) + (set! THE-ASSERTIONS + (cons-stream assertion old-assertions)) + 'ok)) + +(define (add-rule! rule) + (store-rule-in-index rule) + (let ((old-rules THE-RULES)) + (set! THE-RULES (cons-stream rule old-rules)) + 'ok)) + +(define (store-assertion-in-index assertion) + (if (indexable? assertion) + (let ((key (index-key-of assertion))) + (let ((current-assertion-stream + (get-stream key 'assertion-stream))) + (put key + 'assertion-stream + (cons-stream assertion + current-assertion-stream)))))) + +(define (store-rule-in-index rule) + (let ((pattern (conclusion rule))) + (if (indexable? pattern) + (let ((key (index-key-of pattern))) + (let ((current-rule-stream + (get-stream key 'rule-stream))) + (put key + 'rule-stream + (cons-stream rule + current-rule-stream))))))) + +(define (indexable? pat) + (or (constant-symbol? (car pat)) + (var? (car pat)))) + +(define (index-key-of pat) + (let ((key (car pat))) + (if (var? key) '? key))) + +(define (use-index? pat) + (constant-symbol? (car pat))) + +;;;SECTION 4.4.4.6 +;;;Stream operations + +(define (stream-append-delayed s1 delayed-s2) + (if (stream-null? s1) + (force delayed-s2) + (cons-stream + (stream-car s1) + (stream-append-delayed (stream-cdr s1) delayed-s2)))) + +(define (interleave-delayed s1 delayed-s2) + (if (stream-null? s1) + (force delayed-s2) + (cons-stream + (stream-car s1) + (interleave-delayed (force delayed-s2) + (delay (stream-cdr s1)))))) + +(define (stream-flatmap proc s) + (flatten-stream (stream-map proc s))) + +(define (flatten-stream stream) + (if (stream-null? stream) + the-empty-stream + (interleave-delayed + (stream-car stream) + (delay (flatten-stream (stream-cdr stream)))))) + + +(define (singleton-stream x) + (cons-stream x the-empty-stream)) + + +;;;SECTION 4.4.4.7 +;;;Query syntax procedures + +(define (type exp) + (if (pair? exp) + (car exp) + (error "Unknown expression TYPE" exp))) + +(define (contents exp) + (if (pair? exp) + (cdr exp) + (error "Unknown expression CONTENTS" exp))) + +(define (assertion-to-be-added? exp) + (eq? (type exp) 'assert!)) + +(define (add-assertion-body exp) + (car (contents exp))) + +(define (empty-conjunction? exps) (null? exps)) +(define (first-conjunct exps) (car exps)) +(define (rest-conjuncts exps) (cdr exps)) + +(define (empty-disjunction? exps) (null? exps)) +(define (first-disjunct exps) (car exps)) +(define (rest-disjuncts exps) (cdr exps)) + +(define (negated-query exps) (car exps)) + +(define (predicate exps) (car exps)) +(define (args exps) (cdr exps)) + + +(define (rule? statement) + (tagged-list? statement 'rule)) + +(define (conclusion rule) (cadr rule)) + +(define (rule-body rule) + (if (null? (cddr rule)) + '(always-true) + (caddr rule))) + +(define (query-syntax-process exp) + (map-over-symbols expand-question-mark exp)) + +(define (map-over-symbols proc exp) + (cond ((pair? exp) + (cons (map-over-symbols proc (car exp)) + (map-over-symbols proc (cdr exp)))) + ((symbol? exp) (proc exp)) + (else exp))) + +(define (expand-question-mark symbol) + (let ((chars (symbol->string symbol))) + (if (string=? (substring chars 0 1) "?") + (list '? + (string->symbol + (substring chars 1 (string-length chars)))) + symbol))) + +(define (var? exp) + (tagged-list? exp '?)) + +(define (constant-symbol? exp) (symbol? exp)) + +(define rule-counter 0) + +(define (new-rule-application-id) + (set! rule-counter (+ 1 rule-counter)) + rule-counter) + +(define (make-new-variable var rule-application-id) + (cons '? (cons rule-application-id (cdr var)))) + +(define (contract-question-mark variable) + (string->symbol + (string-append "?" + (if (number? (cadr variable)) + (string-append (symbol->string (caddr variable)) + "-" + (number->string (cadr variable))) + (symbol->string (cadr variable)))))) + + +;;;SECTION 4.4.4.8 +;;;Frames and bindings +(define (make-binding variable value) + (cons variable value)) + +(define (binding-variable binding) + (car binding)) + +(define (binding-value binding) + (cdr binding)) + + +(define (binding-in-frame variable frame) + (assoc variable frame)) + +(define (extend variable value frame) + (cons (make-binding variable value) frame)) + + +;;;;From Section 4.1 + +(define (tagged-list? exp tag) + (if (pair? exp) + (eq? (car exp) tag) + false)) + +(define (prompt-for-input string) + (newline) (newline) (display string) (newline)) + + +;;;;Stream support from Chapter 3 + +(define (stream-map proc s) + (if (stream-null? s) + the-empty-stream + (cons-stream (proc (stream-car s)) + (stream-map proc (stream-cdr s))))) + +(define (stream-for-each proc s) + (if (stream-null? s) + 'done + (begin (proc (stream-car s)) + (stream-for-each proc (stream-cdr s))))) + +(define (display-stream s) + (stream-for-each display-line s)) +(define (display-line x) + (newline) + (display x)) + +(define (stream-filter pred stream) + (cond ((stream-null? stream) the-empty-stream) + ((pred (stream-car stream)) + (cons-stream (stream-car stream) + (stream-filter pred + (stream-cdr stream)))) + (else (stream-filter pred (stream-cdr stream))))) + +(define (stream-append s1 s2) + (if (stream-null? s1) + s2 + (cons-stream (stream-car s1) + (stream-append (stream-cdr s1) s2)))) + +(define (interleave s1 s2) + (if (stream-null? s1) + s2 + (cons-stream (stream-car s1) + (interleave s2 (stream-cdr s1))))) + +;;;;Table support from Chapter 3, Section 3.3.3 (local tables) + +(define (make-table) + (let ((local-table (list '*table*))) + (define (lookup key-1 key-2) + (let ((subtable (assoc key-1 (cdr local-table)))) + (if subtable + (let ((record (assoc key-2 (cdr subtable)))) + (if record + (cdr record) + false)) + false))) + (define (insert! key-1 key-2 value) + (let ((subtable (assoc key-1 (cdr local-table)))) + (if subtable + (let ((record (assoc key-2 (cdr subtable)))) + (if record + (set-cdr! record value) + (set-cdr! subtable + (cons (cons key-2 value) + (cdr subtable))))) + (set-cdr! local-table + (cons (list key-1 + (cons key-2 value)) + (cdr local-table))))) + 'ok) + (define (dispatch m) + (cond ((eq? m 'lookup-proc) lookup) + ((eq? m 'insert-proc!) insert!) + (else (error "Unknown operation -- TABLE" m)))) + dispatch)) + +;;;; From instructor's manual + +(define get '()) + +(define put '()) + +(define (initialize-data-base rules-and-assertions) + (define (deal-out r-and-a rules assertions) + (cond ((null? r-and-a) + (set! THE-ASSERTIONS (list->stream assertions)) + (set! THE-RULES (list->stream rules)) + 'done) + (else + (let ((s (query-syntax-process (car r-and-a)))) + (cond ((rule? s) + (store-rule-in-index s) + (deal-out (cdr r-and-a) + (cons s rules) + assertions)) + (else + (store-assertion-in-index s) + (deal-out (cdr r-and-a) + rules + (cons s assertions)))))))) + (let ((operation-table (make-table))) + (set! get (operation-table 'lookup-proc)) + (set! put (operation-table 'insert-proc!))) + (put 'and 'qeval conjoin) + (put 'or 'qeval disjoin) + (put 'not 'qeval negate) + (put 'lisp-value 'qeval lisp-value) + (put 'always-true 'qeval always-true) + (deal-out rules-and-assertions '() '())) + +;; Do following to reinit the data base from microshaft-data-base +;; in Scheme (not in the query driver loop) +;; (initialize-data-base microshaft-data-base) + +(define microshaft-data-base + '( +;; from section 4.4.1 +(address (Bitdiddle Ben) (Slumerville (Ridge Road) 10)) +(job (Bitdiddle Ben) (computer wizard)) +(salary (Bitdiddle Ben) 60000) + +(address (Hacker Alyssa P) (Cambridge (Mass Ave) 78)) +(job (Hacker Alyssa P) (computer programmer)) +(salary (Hacker Alyssa P) 40000) +(supervisor (Hacker Alyssa P) (Bitdiddle Ben)) + +(address (Fect Cy D) (Cambridge (Ames Street) 3)) +(job (Fect Cy D) (computer programmer)) +(salary (Fect Cy D) 35000) +(supervisor (Fect Cy D) (Bitdiddle Ben)) + +(address (Tweakit Lem E) (Boston (Bay State Road) 22)) +(job (Tweakit Lem E) (computer technician)) +(salary (Tweakit Lem E) 25000) +(supervisor (Tweakit Lem E) (Bitdiddle Ben)) + +(address (Reasoner Louis) (Slumerville (Pine Tree Road) 80)) +(job (Reasoner Louis) (computer programmer trainee)) +(salary (Reasoner Louis) 30000) +(supervisor (Reasoner Louis) (Hacker Alyssa P)) + +(supervisor (Bitdiddle Ben) (Warbucks Oliver)) + +(address (Warbucks Oliver) (Swellesley (Top Heap Road))) +(job (Warbucks Oliver) (administration big wheel)) +(salary (Warbucks Oliver) 150000) + +(address (Scrooge Eben) (Weston (Shady Lane) 10)) +(job (Scrooge Eben) (accounting chief accountant)) +(salary (Scrooge Eben) 75000) +(supervisor (Scrooge Eben) (Warbucks Oliver)) + +(address (Cratchet Robert) (Allston (N Harvard Street) 16)) +(job (Cratchet Robert) (accounting scrivener)) +(salary (Cratchet Robert) 18000) +(supervisor (Cratchet Robert) (Scrooge Eben)) + +(address (Aull DeWitt) (Slumerville (Onion Square) 5)) +(job (Aull DeWitt) (administration secretary)) +(salary (Aull DeWitt) 25000) +(supervisor (Aull DeWitt) (Warbucks Oliver)) + +(can-do-job (computer wizard) (computer programmer)) +(can-do-job (computer wizard) (computer technician)) + +(can-do-job (computer programmer) + (computer programmer trainee)) + +(can-do-job (administration secretary) + (administration big wheel)) + +(rule (lives-near ?person-1 ?person-2) + (and (address ?person-1 (?town . ?rest-1)) + (address ?person-2 (?town . ?rest-2)) + (not (same ?person-1 ?person-2)))) + +(rule (same ?x ?x)) + +(rule (wheel ?person) + (and (supervisor ?middle-manager ?person) + (supervisor ?x ?middle-manager))) + +(rule (outranked-by ?staff-person ?boss) + (or (supervisor ?staff-person ?boss) + (and (supervisor ?staff-person ?middle-manager) + (outranked-by ?middle-manager ?boss)))) +)) + + +;;; Added at Berkeley: + +(define (query) + (initialize-data-base '()) + (query-driver-loop)) + +(define (aa query) + (add-rule-or-assertion! + (add-assertion-body + (query-syntax-process (list 'assert! query))))) + +(initialize-data-base '()) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/ref-man.txt b/js/games/nluqo.github.io/~bh/61a-pages/Lib/ref-man.txt new file mode 100644 index 0000000..76bfb85 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/ref-man.txt @@ -0,0 +1,148 @@ +Reference Manual for the OOP Language + +There are only three procedures that you need to use: define-class, +which defines a class; instantiate, which takes a class as its argument +and returns an instance of the class; and ask, which asks an object to do +something. Here are the explanations of the procedures: + + +ASK: (ask object message . bigit args) + +Ask gets a method from object corresponding to message. If the object +has such a method, invoke it with the given args; otherwise it's an error. + + +INSTANTIATE: (instantiate class . arguments) + +Instantiate creates a new instance of the given class, initializes it, +and returns it. To initialize a class, instantiate runs the initialize +clauses of all the parent classes of the object and then runs the +initialize clause of this class. + +The extra arguments to instantiate give the values of the new object's +instantiation variables. So if you say + +(define-class (account balance) ...) + +then saying + +(define my-acct (instantiate account 100)) + +will cause my-acct's balance variable to be bound to 100. + + +DEFINE-CLASS: + +(define-class (class-name args...) clauses...) + +This defines a new class named class-name. The instantiation arguments +for this class are args. (See the explanation of instantiate above.) + +The rest of the arguments to define-class are various clauses of the +following types. All clauses are optional. You can have any number of +method clauses, in any order. + + +(METHOD (message arguments...) body) + +A method clause gives the class a method corresponding to the message, +with the given arguments and body. A class definition may contain any +number of method clauses. You invoke methods with ask. For example, say +there's an object with a + +(method (add x y) (+ x y)) + +clause. Then (ask object 'add 2 5) returns 7. + +Inside a method, the variable self is bound to the object whose method this +is. (Note that self might be an instance of a child class of the class in +which the method is defined.) A method defined within a particular class +has access to the instantiation variables, instance variables, and class +variables that are defined within the same class, but does not have access +to variables defined in parent or child classes. (This is similar to the +scope rules for variables within procedures outside of the OOP system.) + +Any method that is usable within a given object can invoke any other such +method by invoking (ask self message). However, if a method wants to invoke +the method of the same name within a parent class, it must instead ask for +that explicitly by saying + +(usual message args...) + +where message is the name of the method you want and args... are the +arguments to the method. + + +(INSTANCE-VARS (var1 value1) (var2 value2) ...) + +Instance-vars sets up local state variables var1, var2, etc. Each +instance of the class will have its own private set of variables with +these names. These are visible inside the bodies of the methods and the +initialization code within the same class definition. The initial values +of the variables are calculated when an instance is created by evaluating +the expressions value1, value2, etc. There can be any number of +variables. If there is no instance-vars clause then the instances of +this class won't have any instance variables. It is an error for a class +definition to contain more than one instance-vars clause. + + +(CLASS-VARS (var1 value1) (var2 value2) ...) + + +Class-vars sets up local state variables var1, var2, etc. The class has +only one set of variables with these names, shared by every instance of +the class. (Compare the instance-vars clause described above.) These +variables are visible inside the bodies of the methods and the +initialization code within the same class definition. The initial values +of the variables are calculated when the class is defined by evaluating +the expressions value1, value2, etc. There can be any number of +variables. If there is no class-vars clause then the class won't have +any class variables. It is an error for a class definition to contain +more than one class-vars clause. + + +(PARENT (parent1 args...) (parent2 args...)) + +Parent defines the parents of a class. The args are the arguments used +to instantiate the parent objects. For example, let's say that the +rectangle class has two arguments: height and width: + +(define-class (rectangle height width) ...) + +A square is a kind of rectangle; the height and width of the square's +rectangle are both the side-length of the square: + +(define-class (square side-length) + (parent (rectangle side-length side-length)) + ...) + +When an object class doesn't have an explicit method for a message it +receives, it looks for methods of that name in the definitions of the +parent classes, in the order they appear in the parent clause. The method +that gets invoked is from the first parent class that recognizes the +message. + +A method can invoke a parent's method of the same name with usual; see +the notes on the method clause above. + + +(DEFAULT-METHOD body) + +A default-method clause specifies the code that an object should execute +if it receives an unrecognized message (i.e., a message that does not +name a method in this class or any of its superclasses). When the body is +executed, the variable message is bound to the message, and the variable +args is bound to a list of the additional arguments to ask. + + +(INITIALIZE body) + +The body of the initialize clause contains code that is executed whenever +an instance of this class is created. + +If the class has parents, their initialize code gets executed before the +initialize clause in the class itself. If the class has two or more +parents, their initialize code is executed in the order that they appear +in the parent clause. + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/resist.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/resist.scm new file mode 100644 index 0000000..42c0e6b --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/resist.scm @@ -0,0 +1,79 @@ +(define (make-resistor resistance) + (attach-type 'resistor resistance)) + +(define (resistor? ckt) + (eq? (type ckt) 'resistor)) + +(define (make-series ckt1 ckt2) + (attach-type 'series (list ckt1 ckt2))) + +(define (series? ckt) + (eq? (type ckt) 'series)) + +(define (make-parallel ckt1 ckt2) + (attach-type 'parallel (list ckt1 ckt2))) + +(define (parallel? ckt) + (eq? (type ckt) 'parallel)) + + +(define (resistance ckt) + (cond ((resistor? ckt) + (resistance-resistor (contents ckt))) + ((parallel? ckt) + (resistance-parallel (contents ckt))) + ((series? ckt) + (resistance-series (contents ckt))))) + +(define (conductance ckt) + (cond ((resistor? ckt) + (conductance-resistor (contents ckt))) + ((parallel? ckt) + (conductance-parallel (contents ckt))) + ((series? ckt) + (conductance-series (contents ckt))))) + + +(define (resistance-resistor resistor) + resistor) + +(define (conductance-resistor resistor) + (/ 1 (resistance-resistor resistor))) + + +(define (resistance-series ckt) + (+ (resistance (left-branch ckt)) + (resistance (right-branch ckt)))) + +(define (conductance-series ckt) + (/ 1 (resistance-series ckt))) + +(define (conductance-parallel ckt) + (+ (conductance (left-branch ckt)) + (conductance (right-branch ckt)))) + +(define (resistance-parallel ckt) + (/ 1 (conductance-parallel ckt))) + + + +(define left-branch car) +(define right-branch cadr) +(define attach-type cons) +(define type car) +(define contents cdr) + + + +(define (repeated f n) + (lambda (x) + (if (= n 0) + x + ((repeated f (-1+ n)) (f x))))) + +(define (L-extend base series-part parallel-part) + (make-series series-part (make-parallel parallel-part base))) + +(define (ladder-extension stages base series-part parallel-part) + ((repeated (lambda (x) (L-extend x series-part parallel-part)) stages) + base)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/review b/js/games/nluqo.github.io/~bh/61a-pages/Lib/review new file mode 100644 index 0000000..63a4837 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/review @@ -0,0 +1,54 @@ +CS 60A Course summary + + +You aren't expected to understand this yet, but keep it for reference +during the semester and see if it starts to make sense! + +------------------------------ + +ABSTRACTION: + voluntary submission to a discipline + in order to gain expressive power + +------------------------------ + +1. FUNCTIONAL PROGRAMMING + focus: repeatable input-output behavior + composition of functions to layer complexity + hidden: side effect mechanisms (assignment) + internal control structure of procedures + +2. DATA ABSTRACTION + focus: semantic view of data aggregates + hidden: actual representation in memory + +3. OBJECT ORIENTED PROGRAMMING + focus: time-varying local state + metaphor of many autonomous actors + hidden: scheduling of interactions within the one computer + procedural methods within an object + +4. STREAMS + focus: metaphor of parallel operations on data aggregates + signal processing model of computation + hidden: actual sequence of events in the computation + +5. PROGRAMMING LANGUAGES + focus: provide a metaphor for computation + embody common elements of large groups of problems + hidden: technology-specific implementation medium + storage allocation, etc. + +6. LOGIC PROGRAMMING + focus: declarative representation of knowledge + inference rules + hidden: inference algorithm + + +Note: each of these abstractions can be approached "from above," focusing +on the view of computing that the abstraction provides, or "from below," +focusing on the techniques by which the abstraction is implemented. In +the metacircular evaluator we emphasize the view from below, since we've +been working all along with the view from above. In the query evaluator +we emphasize the view from above, barely mentioning the implementation +techniques. In our discussion of object programming both views are used. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/rps.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/rps.scm new file mode 100644 index 0000000..70c2ed9 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/rps.scm @@ -0,0 +1,49 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; The PLAY-LOOP procedure takes as its arguments two game +;; strategies, and plays an iterated game of 25 rounds. +;; A strategy is a procedure that takes two arguments: +;; a history of this player's previous plays and +;; a history of the other player's previous plays. The strategy +;; returns one of the words ROCK, PAPER, or SCISSORS. A history +;; is a list of previous plays, most recent first. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define (play-loop strat0 strat1) + (define (play-loop-iter strat0 strat1 + history0 history1 + score0 score1 + rounds) + (cond ((= rounds 0) (list score0 score1)) + (else (YOU-WRITE-THIS-PART)) )) + (play-loop-iter strat0 strat1 '() '() 0 0 25) ) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; This predicate procedure takes two plays as arguments and +;; returns TRUE if the first beats the second. +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define (beats? play0 play1) + (cond ((equal? play0 'paper) (equal? play1 'rock)) + ((equal? play0 'scissors) (equal? play1 'paper)) + ((equal? play0 'rock) (equal? play1 'scissors)) )) + +;; A sampler of strategies + +(define (tit-for-tat my-history other-history) + (if (empty? my-history) + 'rock ;; arbitrary -- could be a random choice here + (first other-history) )) + +(define (random-strategy my-history other-history) + (nth (random 3) '(rock paper scissors)) ) + +(define (heavy-metal my-history other-history) + 'scissors) + +(define (hard-rock my-history other-history) + 'rock) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/scheme1.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/scheme1.scm new file mode 100644 index 0000000..09be791 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/scheme1.scm @@ -0,0 +1,216 @@ +;; Simple evaluator for Scheme without DEFINE, using substitution model. +;; Version 1: No DEFINE, only primitive names are global. + +;; The "read-eval-print loop" (REPL): + +(define (scheme-1) + (display "Scheme-1: ") + (flush) + (print (eval-1 (read))) + (scheme-1)) + +;; Two important procedures: +;; EVAL-1 takes an expression and returns its value. +;; APPLY-1 takes a procedure and a list of actual argument values, and +;; calls the procedure. +;; They have these names to avoid conflict with STk's EVAL and APPLY, +;; which have similar meanings. + +;; Comments on EVAL-1: + +;; There are four basic expression types in Scheme: +;; 1. self-evaluating (a/k/a constant) expressions: numbers, #t, etc. +;; 2. symbols (variables) +;; 3. special forms (in this evaluator, just QUOTE, IF, and LAMBDA) +;; 4. procedure calls (can call a primitive or a LAMBDA-generated procedure) + +;; 1. The value of a constant is itself. Unlike real Scheme, an STk +;; procedure is here considered a constant expression. You can't type in +;; procedure values, but the value of a global variable can be a procedure, +;; and that value might get substituted for a parameter in the body of a +;; higher-order function such as MAP, so the evaluator has to be ready to +;; see a built-in procedure as an "expression." Therefore, the procedure +;; CONSTANT? includes a check for (PROCEDURE? EXP). + +;; 2. In the substitution model, we should never actually evaluate a *local* +;; variable name, because we should have substituted the actual value for +;; the parameter name before evaluating the procedure body. + +;; In this simple evaluator, there is no DEFINE, and so the only *global* +;; symbols are the ones representing primitive procedures. We cheat a little +;; by using STk's EVAL to get the values of these variables. + +;; 3. The value of the expression (QUOTE FOO) is FOO -- the second element of +;; the expression. + +;; To evaluate the expression (IF A B C) we first evaluate A; then, if A is +;; true, we evaluate B; if A is false, we evaluate C. + +;; The value of a LAMBDA expression is the expression itself. There is no +;; work to do until we actually call the procedure. (This won't be true +;; when we write a more realistic interpreter that handles more Scheme +;; features, but it works in the substitution model.) + +;; 4. To evaluate a procedure call, we recursively evaluate all the +;; subexpressions. We call APPLY-1 to handle the actual procedure invocation. + +(define (eval-1 exp) + (cond ((constant? exp) exp) + ((symbol? exp) (eval exp)) ; use underlying Scheme's EVAL + ((quote-exp? exp) (cadr exp)) + ((if-exp? exp) + (if (eval-1 (cadr exp)) + (eval-1 (caddr exp)) + (eval-1 (cadddr exp)))) + ((lambda-exp? exp) exp) + ((define-exp? exp) + (eval (list 'define (cadr exp) (maybe-quote (eval-1 (caddr exp)))))) + ((pair? exp) (apply-1 (eval-1 (car exp)) ; eval the operator + (map eval-1 (cdr exp)))) + (else (error "bad expr: " exp)))) + + +;; Comments on APPLY-1: + +;; There are two kinds of procedures: primitive and LAMBDA-created. + +;; We recognize a primitive procedure using the PROCEDURE? predicate in +;; the underlying STk interpreter. + +;; If the procedure isn't primitive, then it must be LAMBDA-created. +;; In this interpreter (but not in later, more realistic ones), the value +;; of a LAMBDA expression is the expression itself. So (CADR PROC) is +;; the formal parameter list, and (CADDR PROC) is the expression in the +;; procedure body. + +;; To call the procedure, we must substitute the actual arguments for +;; the formal parameters in the body; the result of this substitution is +;; an expression which we can then evaluate with EVAL-1. + +(define (apply-1 proc args) + (cond ((procedure? proc) ; use underlying Scheme's APPLY + (apply proc args)) + ((lambda-exp? proc) + (eval-1 (substitute (caddr proc) ; the body + (cadr proc) ; the formal parameters + args ; the actual arguments + '()))) ; bound-vars, see below + (else (error "bad proc: " proc)))) + + +;; Some trivial helper procedures: + +(define (constant? exp) + (or (number? exp) (boolean? exp) (string? exp) (procedure? exp))) + +(define (exp-checker type) + (lambda (exp) (and (pair? exp) (eq? (car exp) type)))) + +(define quote-exp? (exp-checker 'quote)) +(define if-exp? (exp-checker 'if)) +(define lambda-exp? (exp-checker 'lambda)) +(define define-exp? (exp-checker 'define)) + + +;; SUBSTITUTE substitutes actual arguments for *free* references to the +;; corresponding formal parameters. For example, given the expression +;; +;; ((lambda (x y) +;; ((lambda (x) (+ x y)) +;; (* x y))) +;; 5 8) +;; +;; the body of the procedure we're calling is +;; +;; ((lambda (x) (+ x y)) +;; (* x y)) +;; +;; and we want to substitute 5 for X and 8 for Y, but the result should be +;; +;; ((lambda (x) (+ x 8)) +;; (* 5 8)) +;; +;; and *NOT* +;; +;; ((lambda (5) (+ 5 8)) +;; (* 5 8)) +;; +;; The X in (* X Y) is a "free reference," but the X in (LAMBDA (X) (+ X Y)) +;; is a "bound reference." +;; +;; To make this work, in its recursive calls, SUBSTITUTE keeps a list of +;; bound variables in the current subexpression -- ones that shouldn't be +;; substituted for -- in its argument BOUND. This argument is the empty +;; list in the top-level call to SUBSTITUTE from APPLY-1. + +;; Another complication is that when an argument value isn't a self-evaluating +;; expression, we actually want to substitute the value *quoted*. For example, +;; consider the expression +;; +;; ((lambda (x) (first x)) 'foo) +;; +;; The actual argument value is FOO, but we want the result of the +;; substitution to be +;; +;; (first 'foo) +;; +;; and not +;; +;; (first foo) +;; +;; because what we're going to do with this expression is try to evaluate +;; it, and FOO would be an unbound variable. + +;; There is a strangeness in MAYBE-QUOTE, which must handle the +;; case of a primitive procedure as the actual argument value; these +;; procedures shouldn't be quoted. + +(define (substitute exp params args bound) + (cond ((constant? exp) exp) + ((symbol? exp) + (if (memq exp bound) + exp + (lookup exp params args))) + ((quote-exp? exp) exp) + ((lambda-exp? exp) + (list 'lambda + (cadr exp) + (substitute (caddr exp) params args (append bound (cadr exp))))) + (else (map (lambda (subexp) (substitute subexp params args bound)) + exp)))) + +(define (lookup name params args) + (cond ((null? params) name) + ((eq? name (car params)) (maybe-quote (car args))) + (else (lookup name (cdr params) (cdr args))))) + +(define (maybe-quote value) + (cond ((lambda-exp? value) value) + ((constant? value) value) + ((procedure? value) value) ; real Scheme primitive procedure + (else (list 'quote value)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Sample evaluation, computing factorial of 5: + +; Scheme-1: ((lambda (n) +; ((lambda (f) (f f n)) +; (lambda (f n) +; (if (= n 0) +; 1 +; (* n (f f (- n 1))) )) )) +; 5) +; 120 + +;; Sample evaluation, using a primitive as argument to MAP: + +; Scheme-1: ((lambda (f n) +; ((lambda (map) (map map f n)) +; (lambda (map f n) +; (if (null? n) +; '() +; (cons (f (car n)) (map map f (cdr n))) )) )) +; first +; '(the rain in spain)) +; (t r i s) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/scmset b/js/games/nluqo.github.io/~bh/61a-pages/Lib/scmset new file mode 100644 index 0000000..47f40aa --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/scmset @@ -0,0 +1,2 @@ +setenv SCM_INIT_PATH ~cs61a/scm/Init.scm +setenv SCHEME_LIBRARY_PATH ~cs61a/slib/ diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/serial.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/serial.scm new file mode 100644 index 0000000..52a4597 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/serial.scm @@ -0,0 +1,21 @@ +(define (make-serializer) + (let ((mutex (make-mutex))) + (lambda (p) + (define (serialized-p . args) + (mutex 'acquire) + (let ((val (apply p args))) + (mutex 'release) + val)) + serialized-p))) + +(define (make-mutex) + (let ((cell (list false))) + (define (the-mutex m) + (cond ((eq? m 'acquire) + (if (test-and-set! cell) + (the-mutex 'acquire))) + ((eq? m 'release) (clear! cell)))) + the-mutex)) + +(define (clear! cell) + (set-car! cell false)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/small-world.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/small-world.scm new file mode 100644 index 0000000..dcd6bd1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/small-world.scm @@ -0,0 +1,28 @@ +;;; small-world.scm +;;; Miniature game world for debugging the CS61A adventure game project. +;;; You can load this instead of adv-world.scm, and reload it quickly +;;; whenever you change a class. + +;;; How to use this file: +;;; If, for example, your person class doesn't work, and you do something +;;; like (define Matt (instantiate person 'Matt)), and then fix your +;;; person class definition, Matt is still bound to the faulty person +;;; object from before. However, reloading this file whenever you +;;; change something should redefine everything in your world with the +;;; currently loaded (i.e. most recent) versions of your classes. + +(define 61A-Lab (instantiate place '61A-Lab)) +(define Lounge (instantiate place 'Lounge)) +(can-go 61A-Lab 'up Lounge) +(can-go Lounge 'down 61A-Lab) +;;; Hopefully you'll see more of the world than this in real life +;;; while you're doing the project! + +(define homework-box (instantiate thing 'homework-box)) +(ask 61A-Lab 'appear homework-box) + +(define Coke (instantiate thing 'Coke)) +(ask Lounge 'appear Coke) + +(define laba (instantiate person 'Lab-assistant 61A-Lab)) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/tables.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/tables.scm new file mode 100644 index 0000000..010b712 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/tables.scm @@ -0,0 +1,20 @@ +;;; Section 3.3.3 -- Tables + +;;; One-dimensional tables + +(define (lookup key table) + (let ((record (assoc key (cdr table)))) + (if (not record) + #f + (cdr record)))) + +(define (insert! key value table) + (let ((record (assoc key (cdr table)))) + (if (not record) + (set-cdr! table + (cons (cons key value) (cdr table))) + (set-cdr! record value))) + 'ok) + +(define (make-table) + (list '*table*)) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/test.logo b/js/games/nluqo.github.io/~bh/61a-pages/Lib/test.logo new file mode 100644 index 0000000..bb2e15a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/test.logo @@ -0,0 +1,39 @@ +to second :thing +op first bf :thing +end + +to twice :thing +pr :thing +pr :thing +end + +to pigl :word +if vowelp first :word [op word :word "ay] +op pigl word bf :word first :word +end + +to vowelp :let +op memberp :let "aeiou +end + +to piglatin :sent +if emptyp :sent [op []] +op fput pigl first :sent piglatin bf :sent +end + +to factorial :n +if :n=0 [output 1] +output :n * factorial :n-1 +end + +to memberp :thing :list +if emptyp :list [op "false] +if equalp :thing first :list [op "true] +op memberp :thing bf :list +end + +to repeat :num :instr +if :num=0 [stop] +run :instr +repeat :num-1 :instr +end diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/tri.l b/js/games/nluqo.github.io/~bh/61a-pages/Lib/tri.l new file mode 100644 index 0000000..90e3918 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/tri.l @@ -0,0 +1,94 @@ +;; Program to solve triangles given partial information. + +;; Form of invocation is (triangle side1 side2 side3 angle1 angle2 angle3) +;; where each argument is zero if the corresponding side or angle is +;; unknown. Angles are entered in degrees (but converted internally +;; to radians). Angle1 is opposite side1, etc. The program must be +;; given at least three knowns, at least one of which must be a side. + +;; First, here are some useful definitions from trig class: + +(define pi 3.14159) + +(define (square x) (* x x)) + +(define (degrees rad) (* 180 (/ rad pi))) + +(define (radians deg) (* pi (/ deg 180))) + +(define (arcsin a) (atan a (sqrt (- 1 (square a))))) + +(define (arccos a) (atan (sqrt (- 1 (square a))) a)) + +;; This is the top-level procedure + +(define (triangle a b c alpha beta gamma) + + (define (triangle-rad a b c alpha beta gamma) + +;; The strategy is to keep increasing the number of sides we know, and at +;; the end to make sure we know the angles too. Here are some local +;; procedures to count how many sides we know. They are predicates that +;; return true if we know at least so many sides (or angles sometimes). + + (define (havethreesides) (not (or (= a 0) (= b 0) (= c 0)))) + + (define (havetwo a b c) + (cond ((= a 0) (not (or (= b 0) (= c 0)))) + (else (not (and (= b 0) (= c 0)))))) + (define (havetwosides) (havetwo a b c)) + (define (havetwoangles) (havetwo alpha beta gamma)) + + (define (haveone a b c) + (not (and (= a 0) (= b 0) (= c 0)))) + (define (haveoneside) (haveone a b c)) + (define (haveoneangle) (haveone alpha beta gamma)) + +;; If we know all three sides we can use the law of cosines to find +;; any angles that might be missing. + + (define (solvethreesides) + (define (lawcosangle side1 side2 hyp) + (arccos (/ (- (+ (square side1) (square side2)) (square hyp)) + (* 2 side1 side2)))) + (define (sidesbad) + (define (tri-ineq a b c) (> (+ a b) c)) + (not (and (tri-ineq a b c) (tri-ineq a c b) (tri-ineq b c a)))) + + (cond ((sidesbad) "Your sides fail the triangle inequality.") + ((= alpha 0) + (triangle-rad a b c (lawcosangle b c a) beta gamma)) + ((= beta 0) + (triangle-rad a b c alpha (lawcosangle a c b) gamma)) + ((= gamma 0) + (triangle-rad a b c alpha beta (lawcosangle a b c))) + (else + (list a b c (degrees alpha) (degrees beta) (degrees gamma))))) + +;; [You don't know about the procedure "list" yet, but it lets us return +;; more than one number in a single result.] + +;; We invoke this procedure if we know two sides: + + (define (solvetwosides) + +;; It'll make life easier if we rearrange things so that side C is unknown. + + (cond ((not (haveoneangle)) "Must know at least three values.") + ((= a 0) (triangle-rad b c a beta gamma alpha)) + ((= b 0) (triangle-rad a c b alpha gamma beta)) + (else "YOU FILL IN THE REST!"))) + +;; This is the executable body of triangle-rad: + + (cond ((havethreesides) (solvethreesides)) + ((havetwosides) (solvetwosides)) + ((haveoneside) (solveoneside)) + (else "Must know at least one side."))) + +;; This is the executable body of triangle. + + (cond ((> (+ alpha beta gamma) 180) + "Your angles add up to more than 180.") + (else (triangle-rad a b c + (radians alpha) (radians beta) (radians gamma))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/turkey b/js/games/nluqo.github.io/~bh/61a-pages/Lib/turkey new file mode 100644 index 0000000..1def834 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/turkey @@ -0,0 +1,50 @@ + MORTON THOMPSON'S TURKEY STUFFING + +From the book "Joe, the Wounded Tennis Player" by Morton Thompson, +adapted by Craig Claiborne in the NY Times. + +1 apple, peeled, cored, and diced +1 orange, peeled, seeded, and diced +1 no. 2 can crushed pineapple, drained +rind of one lemon, grated +3 tablespoons chopped preserved ginger +2 five-oz cans water chestnuts, drained and coarsely chopped +2 teaspoons powdered mustard +2 teaspoons caraway seeds +3 teaspoons celery seeds +2 teaspoons poppy seeds +2 1/2 teaspoons oregano +1 crushed bay leaf +1/2 teaspoon mace +1/4 teaspoon ground cloves +1/2 teaspoon turmeric +1/2 teaspoon marjoram +1/2 teaspoon summer savory +1 tablespoon poultry seasoning +3/4 teaspoon sage +3/4 teaspoon thyme +1/2 teaspoon basil +1/2 teaspoon chili powder +1/4 cup finely chopped parsley +5 cloves garlic, finely minced +6 large ribs celery, chopped +4 large onions, peeled and chopped +5 dashes Tabasco sauce +1 tablespoon salt +6 cups fresh bread crumbs, or 3 packages bread crumbs +3/4 pound ground veal +1/2 pound ground fresh pork or sausage +1/4 pound butter +1 16-pound to 20-pound turkey + +In one bowl, combine the diced apple, orange, crushed pineapple, +lemon rind, ginger, and chopped water chestnuts. Mix well. + +In a second (huge) bowl, combine all the herbs and spices, the +parsley, garlic, celery, onions, Tabasco, and salt. Toss well. + +Add the remaining ingredients and the contents of the first bowl. +Blend everything well with the fingers. Stuff the turkey and +skewer it. Roast according to any standard recipe. Any leftover +stuffing may be frozen and used later for chickens, ducks, or +another turkey. [Or just cooked on the stove and mixed in --BH] diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/twenty-one.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/twenty-one.scm new file mode 100644 index 0000000..0337c84 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/twenty-one.scm @@ -0,0 +1,42 @@ +(define (twenty-one strategy) + (define (play-dealer customer-hand dealer-hand-so-far rest-of-deck) + (cond ((> (best-total dealer-hand-so-far) 21) 1) + ((< (best-total dealer-hand-so-far) 17) + (play-dealer customer-hand + (se dealer-hand-so-far (first rest-of-deck)) + (bf rest-of-deck))) + ((< (best-total customer-hand) (best-total dealer-hand-so-far)) -1) + ((= (best-total customer-hand) (best-total dealer-hand-so-far)) 0) + (else 1))) + + (define (play-customer customer-hand-so-far dealer-up-card rest-of-deck) + (cond ((> (best-total customer-hand-so-far) 21) -1) + ((strategy customer-hand-so-far dealer-up-card) + (play-customer (se customer-hand-so-far (first rest-of-deck)) + dealer-up-card + (bf rest-of-deck))) + (else + (play-dealer customer-hand-so-far + (se dealer-up-card (first rest-of-deck)) + (bf rest-of-deck))))) + + (let ((deck (make-deck))) + (play-customer (se (first deck) (first (bf deck))) + (first (bf (bf deck))) + (bf (bf (bf deck))))) ) + +(define (make-ordered-deck) + (define (make-suit s) + (map (lambda (rank) (word rank s)) '(A 2 3 4 5 6 7 8 9 10 J Q K)) ) + (se (make-suit 'H) (make-suit 'S) (make-suit 'D) (make-suit 'C)) ) + +(define (make-deck) + (define (shuffle deck size) + (define (move-card in out which) + (if (= which 0) + (se (first in) (shuffle (se (bf in) out) (-1+ size))) + (move-card (bf in) (se (first in) out) (-1+ which)) )) + (if (= size 0) + deck + (move-card deck '() (random size)) )) + (shuffle (make-ordered-deck) 52) ) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lib/vambeval.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lib/vambeval.scm new file mode 100644 index 0000000..360800a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lib/vambeval.scm @@ -0,0 +1,511 @@ +;;;;Nondeterministic evaluator +;;;;Different from the one in chapter 4 of SICP, in that it's based on the +;;;; vanilla metacircular evaluator, rather than on the analyzing one. + +;;;;This file can be loaded into Scheme as a whole. +;;;;Then you can initialize and start the evaluator by evaluating +;;;; the expression (mce). + +;;;from section 4.1.4 -- must precede def of metacircular apply +(define apply-in-underlying-scheme apply) + +;;;SECTION 4.1.1 + +(define (ambeval exp env succeed fail) + (cond ((self-evaluating? exp) (succeed exp fail)) + ((variable? exp) + (succeed (lookup-variable-value exp env) + fail)) + ((quoted? exp) (succeed (text-of-quotation exp) fail)) + ((assignment? exp) (eval-assignment exp env succeed fail)) + ((definition? exp) (eval-definition exp env succeed fail)) + ((if? exp) (eval-if exp env succeed fail)) + ((lambda? exp) + (succeed (make-procedure (lambda-parameters exp) + (lambda-body exp) + env) + fail)) + ((begin? exp) + (eval-sequence (begin-actions exp) env succeed fail)) + ((cond? exp) (ambeval (cond->if exp) env succeed fail)) + ((let? exp) (ambeval (let->combination exp) env succeed fail)) ;** + ((amb? exp) (eval-amb exp env succeed fail)) ;** + ((application? exp) + (eval-application exp env succeed fail)) + (else + (error "Unknown expression type -- EVAL" exp)))) + +(define (eval-application exp env succeed fail) + (ambeval (operator exp) + env + (lambda (proc fail2) + (get-args (operands exp) + env + (lambda (args fail3) + (execute-application proc args succeed fail3)) + fail2)) + fail)) + +(define (get-args exps env succeed fail) + (if (null? exps) + (succeed '() fail) + (ambeval (car exps) + env + (lambda (arg fail2) + (get-args (cdr exps) + env + (lambda (args fail3) + (succeed (cons arg args) + fail3)) + fail2)) + fail))) + +(define (execute-application procedure arguments succeed fail) + (cond ((primitive-procedure? procedure) + (succeed (apply-primitive-procedure procedure arguments) fail)) + ((compound-procedure? procedure) + (eval-sequence + (procedure-body procedure) + (extend-environment + (procedure-parameters procedure) + arguments + (procedure-environment procedure)) + succeed + fail)) + (else + (error + "Unknown procedure type -- APPLY" procedure)))) + + +(define (eval-if exp env succeed fail) + (ambeval (if-predicate exp) + env + (lambda (pred-value fail2) + (if (true? pred-value) + (ambeval (if-consequent exp) + env + succeed + fail2) + (ambeval (if-alternative exp) + env + succeed + fail2))) + fail)) + +(define (eval-sequence exps env succeed fail) + (define (loop first-exp rest-exps succeed fail) + (if (null? rest-exps) + (ambeval first-exp env succeed fail) + (ambeval first-exp + env + (lambda (first-value fail2) + (loop (car rest-exps) (cdr rest-exps) succeed fail2)) + fail))) + (if (null? exps) + (error "Empty sequence") + (loop (car exps) (cdr exps) succeed fail))) + +(define (eval-definition exp env succeed fail) + (ambeval (definition-value exp) + env + (lambda (val fail2) + (define-variable! (definition-variable exp) val env) + (succeed 'ok fail2)) + fail)) + +(define (eval-assignment exp env succeed fail) + (ambeval (assignment-value exp) + env + (lambda (val fail2) + (let* ((var (assignment-variable exp)) + (old-value + (lookup-variable-value var env))) + (set-variable-value! var val env) + (succeed 'ok + (lambda () + (set-variable-value! var old-value env) + (fail2))))) + fail)) + + +(define (eval-amb exp env succeed fail) + (define (try-next choices) + (if (null? choices) + (fail) + (ambeval (car choices) + env + succeed + (lambda () + (try-next (cdr choices)))))) + (try-next (amb-choices exp))) + + +;;;SECTION 4.1.2 + +(define (self-evaluating? exp) + (cond ((number? exp) true) + ((string? exp) true) + ((boolean? exp) true) + (else false))) + +(define (quoted? exp) + (tagged-list? exp 'quote)) + +(define (text-of-quotation exp) (cadr exp)) + +(define (tagged-list? exp tag) + (if (pair? exp) + (eq? (car exp) tag) + false)) + +(define (variable? exp) (symbol? exp)) + +(define (assignment? exp) + (tagged-list? exp 'set!)) + +(define (assignment-variable exp) (cadr exp)) + +(define (assignment-value exp) (caddr exp)) + + +(define (definition? exp) + (tagged-list? exp 'define)) + +(define (definition-variable exp) + (if (symbol? (cadr exp)) + (cadr exp) + (caadr exp))) + +(define (definition-value exp) + (if (symbol? (cadr exp)) + (caddr exp) + (make-lambda (cdadr exp) + (cddr exp)))) + +(define (lambda? exp) (tagged-list? exp 'lambda)) + +(define (lambda-parameters exp) (cadr exp)) +(define (lambda-body exp) (cddr exp)) + +(define (make-lambda parameters body) + (cons 'lambda (cons parameters body))) + + +(define (if? exp) (tagged-list? exp 'if)) + +(define (if-predicate exp) (cadr exp)) + +(define (if-consequent exp) (caddr exp)) + +(define (if-alternative exp) + (if (not (null? (cdddr exp))) + (cadddr exp) + 'false)) + +(define (make-if predicate consequent alternative) + (list 'if predicate consequent alternative)) + + +(define (begin? exp) (tagged-list? exp 'begin)) + +(define (begin-actions exp) (cdr exp)) + +(define (last-exp? seq) (null? (cdr seq))) +(define (first-exp seq) (car seq)) +(define (rest-exps seq) (cdr seq)) + +(define (sequence->exp seq) + (cond ((null? seq) seq) + ((last-exp? seq) (first-exp seq)) + (else (make-begin seq)))) + +(define (make-begin seq) (cons 'begin seq)) + + +(define (application? exp) (pair? exp)) +(define (operator exp) (car exp)) +(define (operands exp) (cdr exp)) + +(define (no-operands? ops) (null? ops)) +(define (first-operand ops) (car ops)) +(define (rest-operands ops) (cdr ops)) + + +(define (cond? exp) (tagged-list? exp 'cond)) + +(define (cond-clauses exp) (cdr exp)) + +(define (cond-else-clause? clause) + (eq? (cond-predicate clause) 'else)) + +(define (cond-predicate clause) (car clause)) + +(define (cond-actions clause) (cdr clause)) + +(define (cond->if exp) + (expand-clauses (cond-clauses exp))) + +(define (expand-clauses clauses) + (if (null? clauses) + 'false ; no else clause + (let ((first (car clauses)) + (rest (cdr clauses))) + (if (cond-else-clause? first) + (if (null? rest) + (sequence->exp (cond-actions first)) + (error "ELSE clause isn't last -- COND->IF" + clauses)) + (make-if (cond-predicate first) + (sequence->exp (cond-actions first)) + (expand-clauses rest)))))) + +(define (amb? exp) (tagged-list? exp 'amb)) +(define (amb-choices exp) (cdr exp)) + +;;;SECTION 4.1.3 + +(define (true? x) + (not (eq? x false))) + +(define (false? x) + (eq? x false)) + + +(define (make-procedure parameters body env) + (list 'procedure parameters body env)) + +(define (compound-procedure? p) + (tagged-list? p 'procedure)) + + +(define (procedure-parameters p) (cadr p)) +(define (procedure-body p) (caddr p)) +(define (procedure-environment p) (cadddr p)) + + +(define (enclosing-environment env) (cdr env)) + +(define (first-frame env) (car env)) + +(define the-empty-environment '()) + +(define (make-frame variables values) + (cons variables values)) + +(define (frame-variables frame) (car frame)) +(define (frame-values frame) (cdr frame)) + +(define (add-binding-to-frame! var val frame) + (set-car! frame (cons var (car frame))) + (set-cdr! frame (cons val (cdr frame)))) + +(define (extend-environment vars vals base-env) + (if (= (length vars) (length vals)) + (cons (make-frame vars vals) base-env) + (if (< (length vars) (length vals)) + (error "Too many arguments supplied" vars vals) + (error "Too few arguments supplied" vars vals)))) + +(define (lookup-variable-value var env) + (define (env-loop env) + (define (scan vars vals) + (cond ((null? vars) + (env-loop (enclosing-environment env))) + ((eq? var (car vars)) + (car vals)) + (else (scan (cdr vars) (cdr vals))))) + (if (eq? env the-empty-environment) + (error "Unbound variable" var) + (let ((frame (first-frame env))) + (scan (frame-variables frame) + (frame-values frame))))) + (env-loop env)) + +(define (set-variable-value! var val env) + (define (env-loop env) + (define (scan vars vals) + (cond ((null? vars) + (env-loop (enclosing-environment env))) + ((eq? var (car vars)) + (set-car! vals val)) + (else (scan (cdr vars) (cdr vals))))) + (if (eq? env the-empty-environment) + (error "Unbound variable -- SET!" var) + (let ((frame (first-frame env))) + (scan (frame-variables frame) + (frame-values frame))))) + (env-loop env)) + +(define (define-variable! var val env) + (let ((frame (first-frame env))) + (define (scan vars vals) + (cond ((null? vars) + (add-binding-to-frame! var val frame)) + ((eq? var (car vars)) + (set-car! vals val)) + (else (scan (cdr vars) (cdr vals))))) + (scan (frame-variables frame) + (frame-values frame)))) + +;;;SECTION 4.1.4 + +(define (setup-environment) + (let ((initial-env + (extend-environment (primitive-procedure-names) + (primitive-procedure-objects) + the-empty-environment))) + (define-variable! 'true true initial-env) + (define-variable! 'false false initial-env) + initial-env)) + +;[do later] (define the-global-environment (setup-environment)) + +(define (primitive-procedure? proc) + (tagged-list? proc 'primitive)) + +(define (primitive-implementation proc) (cadr proc)) + +(define primitive-procedures + (list (list 'car car) + (list 'cdr cdr) + (list 'cons cons) + (list 'null? null?) + (list '+ +) + (list '- -) + (list '* *) + (list '/ /) + (list '= =) + (list 'list list) + (list 'append append) + (list 'equal? equal?) +;; more primitives + )) + +(define (primitive-procedure-names) + (map car + primitive-procedures)) + +(define (primitive-procedure-objects) + (map (lambda (proc) (list 'primitive (cadr proc))) + primitive-procedures)) + +;[moved to start of file] (define apply-in-underlying-scheme apply) + +(define (apply-primitive-procedure proc args) + (apply-in-underlying-scheme + (primitive-implementation proc) args)) + + + +(define input-prompt ";;; Amb-Eval input:") +(define output-prompt ";;; Amb-Eval value:") + +(define (driver-loop) + (define (internal-loop try-again) + (prompt-for-input input-prompt) + (let ((input (read))) + (if (eq? input 'try-again) + (try-again) + (begin + (newline) + (display ";;; Starting a new problem ") + (ambeval input + the-global-environment + ;; ambeval success + (lambda (val next-alternative) + (announce-output output-prompt) + (user-print val) + (internal-loop next-alternative)) + ;; ambeval failure + (lambda () + (announce-output + ";;; There are no more values of") + (user-print input) + (driver-loop))))))) + (internal-loop + (lambda () + (newline) + (display ";;; There is no current problem") + (driver-loop)))) + + +(define (prompt-for-input string) + (newline) (newline) (display string) (newline)) + +(define (announce-output string) + (newline) (display string) (newline)) + +(define (user-print object) + (if (compound-procedure? object) + (display (list 'compound-procedure + (procedure-parameters object) + (procedure-body object) + '<procedure-env>)) + (display object))) + +;;; Support for Let (as noted in footnote 56, p.428) + +(define (let? exp) (tagged-list? exp 'let)) +(define (let-bindings exp) (cadr exp)) +(define (let-body exp) (cddr exp)) + +(define (let-var binding) (car binding)) +(define (let-val binding) (cadr binding)) + +(define (make-combination operator operands) (cons operator operands)) + +(define (let->combination exp) + ;;make-combination defined in earlier exercise + (let ((bindings (let-bindings exp))) + (make-combination (make-lambda (map let-var bindings) + (let-body exp)) + (map let-val bindings)))) + +;; A longer list of primitives -- suitable for running everything in 4.3 +;; Overrides the list in ch4-mceval.scm +;; Has Not to support Require; various stuff for code in text (including +;; support for Prime?); integer? and sqrt for exercise code; +;; eq? for ex. solution + +(define primitive-procedures + (list (list 'car car) + (list 'cdr cdr) + (list 'cons cons) + (list 'null? null?) + (list 'list list) + (list 'append append) + (list 'memq memq) + (list 'member member) + (list 'not not) + (list '+ +) + (list '- -) + (list '* *) + (list '= =) + (list '> >) + (list '>= >=) + (list 'abs abs) + (list 'remainder remainder) + (list 'integer? integer?) + (list 'sqrt sqrt) + (list 'eq? eq?) + (list 'equal? equal?) + (list 'pair? pair?) +;; more primitives + )) + +;;;Following are commented out so as not to be evaluated when +;;; the file is loaded. +;;(define the-global-environment (setup-environment)) +;;(driver-loop) + +;; Added at Berkeley: +(define the-global-environment '()) + +(define (mce) + (set! the-global-environment (setup-environment)) + (ambeval '(define (require p) (if (not p) (amb))) + the-global-environment + (lambda (a b) #t) + (lambda () #t)) + (driver-loop)) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/explorin-vs-simply.txt b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/explorin-vs-simply.txt new file mode 100644 index 0000000..cf8432b --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/explorin-vs-simply.txt @@ -0,0 +1,164 @@ + Aug 25, 2006 + March 1, 2010 +README-explorin-vs-simply.txt + + +For CS61A/SICP, use stk-simply in the instructions below. + + +*stk-explorin and stk-simply*: +--------------------------- + + UCB Scheme includes several load modules that define the functions that + make up the Berkeley extensions for UCB CS classes. + + The UCB Scheme package now installs these options for starting scheme: + + "stk-simply" loads UCB procedures for CS3 and CS61A + "stk-explorin" loads UCB procedures for CS3S + "stk-grfx" loads UCB procedures for CS9D and CS47B (not on InstCD) + "stk" loads no UCB procedures + + (Prior to 2004, there were stk-cs3, stk-cs3s, stk-cs61a, stk-cs61a-2, + stk-cs9, etc. Those versions are now obsolete.) + + "stk-simply" loads the procedures as defined in these texts: + + "Simply Scheme - Introducing Computer Science" (Harvey and Wright) + "Structure and Interpretation of Computer Programs" (Abelson and Sussman) + + "stk-explorin" load the procedures as defined in this text: + + "Exploring Computer Science with Scheme" (Grillmeyer) + + Each program loads ALL of the UCB-defined procedures but, in the case of + conflicting definitions, favors the definition from the text book after + which it is named: "simply" or "explorin". ("explorin" omits the "g" for + historical reasons: MS-DOS required 8-character file names!) + + In these texts, there are 7 procedures that conflict because they use the + same names and arguments but behave differently. The conflicting + definitions are: + + count + first + every + accumulate + reduce + remove! + atom? (an STk primitive that is refined in Exploring) + + The 7 procedures are defined one way in simply.scm and another way in + explorin.scm. To load all the UCB procedures and resolve the conflicts: + + stk-simply loads everything else, then simply.scm + stk-explorin loads everything else, then explorin.scm + + This causes the desired definitions to replace the undesired ones. + + Here is how stk-simply and stk-explorin load on Windows (for example): + + The file "stk-simply" contains + stk -load "C:/Program Files/STk/site-scheme/load-simply" + + The file "load-simply" contains + ;; simply.scm must be loaded after explorin.scm + ;; modeler.stk must be loaded after simply.scm + (load "C:/Program Files/STk/site-scheme/berkeley.scm") + (load "C:/Program Files/STk/site-scheme/explorin.scm") + (load "C:/Program Files/STk/site-scheme/simply.scm") + (load "C:/Program Files/STk/site-scheme/modeler.stk") + (load "C:/Program Files/STk/site-scheme/obj.scm") + (load "C:/Program Files/STk/site-scheme/turtle-grfx.scm") + (load "C:/Program Files/STk/site-scheme/which-modeler.scm") + + The file "stk-explorin" contains + stk -load "C:/Program Files/STk/site-scheme/load-explorin" + + The file "load-explorin" contains + ;; explorin.scm must be loaded after simply.scm + ;; modeler.stk must be loaded after simply.scm + (load "C:/Program Files/STk/site-scheme/berkeley.scm") + (load "C:/Program Files/STk/site-scheme/simply.scm") + (load "C:/Program Files/STk/site-scheme/explorin.scm") + (load "C:/Program Files/STk/site-scheme/modeler.stk") + (load "C:/Program Files/STk/site-scheme/obj.scm") + (load "C:/Program Files/STk/site-scheme/turtle-grfx.scm") + (load "C:/Program Files/STk/site-scheme/which-modeler.scm") + + The (atom? '()) function is an STk primitive that is defined in the STk + sources as returning #t. It is redefined in explorin.scm to return #f. + To compensate for that, the original definition is copied to berkeley.scm + to ensure that it is set properly for those users. + + +*"(explorinOrSimply)" procedure* +------------------------------ + + If you are running stk-explorin, invoking the function (explorinOrSimply) + will return the string "explorin", but if you are running stk-simply, + invoking (explorinOrSimply) will return the string "simply". This can + be used within user scheme code to determine which version has been + loaded. + + +*Replacement Modeler* +------------------- + + The Replacement Modeler is a separate window that is invoked in stk by a + command such as (model (map odd? '(1 2 3 4))) + + The Modeler procedures are defined in the file "modeler.stk". The file + "which-modeler.stk" defines flags that are used to distinguish behaviors + for CS3 vs CS3S students. The flags are: + + (using-berkeley-scm?) (false for "explorin" users, true for others) + *harvey+wright* (false for "explorin" users, true for others) + *grillmeyer* (true for "explorin" users, false for others) + *they-know-lambda* (false for everyone) + + which-modeler.stk replaces the older cs3-modeler.stk and cs3s-modeler.stk. + + +*stk-grfx* +-------- + + 'stk-grfx' loads the Berkeley extensions in obj.scm and turtle-grfx.scm. + It is a new variant that was added to for cs9d and cs47b in Spring 2005. + It can be run as + + ~scheme/bin/stk-grfx + ~cs9d/bin/stk-grfx + ~cs47b/bin/stk-grfx + + It is only available on the computers in the EECS Instructional labs. It is + not available on the pre-packaged versions of Berkeley Scheme for Windows, + MacOSX or Linux. + + To test that turtle graphics is installed: + + STk> (cs) ;; TurtleGraphics X window pops up + STk> (ht) ;; the turtle pointer disappears + STk> (st) ;; the turtle pointer reappears + + +*STKDB Debugger* +-------------- + The STKDB Debugger was developed by Prof Hilfinger in 2003. It is + documented in https://people.cs.berkeley.edu/~bh/Scheme/stkdb.pdf. + + The debugger module is loaded into the scheme interpreter after you + start it. The debugger files are included in the UCB Scheme + distribution. The required files are: + + stk VERSION 4.0.1-ucb1.16 or newer + $DIR/stkdb/*.scm + $DIR/stk/slib + $DIR/emacs/lisp/stkdb.el + + $DIR is usually '/usr/local/lib' on your home computer, which is the + same as C:\cygwin\usr\local\lib on a Windows computer that is using + Cygwin with the latest version (Feb 2006) of UCB Scheme on Windows. + + + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/faq.html b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/faq.html new file mode 100644 index 0000000..d445b5e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/faq.html @@ -0,0 +1,71 @@ +<html><head> +<meta http-equiv="content-type" content="text/html; charset=windows-1252"> +<title>UCB Scheme - Frequently Asked Questions</title> +</head> +<body> + +<h1>UCB Scheme - Frequently Asked Questions</h1> +<p> +Nov 21, 2005 +</p><ol> + <li> "<i>The <b>arrow keys</b> output certain escape sequences (^[]A to ^[]D) + instead of moving the cursor." </i> + <p>STk does not support arrow keys. You can run STk from within Emacs (using, + e.g., M-x shell or M-x run-scheme) if you want to use arrow keys.</p></li> + + <li> "<i>I'm trying to install the STk rpm on <b>redhat linux 7.3</b> but + when I type in the command 'rpm -i STk-4.0.1-UCB6.i386.rpm' or + 'rpm -Uvh STk-4.0.1-UCB6.i386.rpm', an error message tells me that + there is a failed dependency because my system doesn't have the korn + shell running."</i> + <p>You can go ahead and run the command + 'rpm --nodeps -i STk-4.0.1-UCB6.i386.rpm'. + Or you could install ksh, with the command: + 'rpm -i ftp://ftp.redhat.com/pub/redhat/linux/7.3/en/os/i386/RedHat/RPMS/pdksh-5.2.14-16.i386.rpm'</p></li> + + <li> "<i> The 'File Save' window and the 'envdraw' command don't work. + I'm using the STk version of scm on a <b>Windows 9x</b> system."</i> + <p>This is a known bug that we cannot fix. The Tk calls that are + needed for the 'File Save' window and the 'envdraw' command do not + work on Windows9x. They do work on WindowsNT/2000/XP.</p></li> + + <li> "<i> I can't get STK to load onto my laptop with <b>Windows Me</b>. + I follow the instructions, add it to the start menu, but when I + click on the program to load it, it doesn't do anything: the cursor + goes to an hourglass to indicate action, but no window opens. What do I + do?"</i> + <p>The problem was that when you unzipped the file, it automatically saved + as C:\Program Files\STkWin32, so when you'd click on stk.exe, it would not + execute because the path was incorrect. To solve this, you just had + to drag the STk folder within STkWin32 to the Program Files folder.</p></li> + + <li> "<i> I'm logged into an Instructional UNIX system from a Mac [or Linux]. + I type 'stk' and I get an error that starts with:<p></p><ul> + <b>X Error of failed request: BadAtom (invalid Atom parameter)</b> + </ul></i> + <p>To correct this, use the "-Y" option with ssh, for example: + <b>ssh -l cs3 solar -X -Y</b>. This is not an bug in stk; it is + related to how openssh sends certain X calls over the encrypted channel. + +</p></li></ol><p></p> +<hr> +<h3>To Instructional Support:</h3> +The source for this faq.html file is +<b>/home/aa/projects/scheme/public_html/faq.html</b>. +To make it accessible from ~scheme and ~instcd, there is a hard link between +<ul> +<li>/home/aa/projects/scheme/public_html/faq.html</li> +<li>/home/aa/projects/instcd/public_html/inst-cd/source/stk/faq.html</li> +</ul> +References to it from the ~scheme and ~instcd WEB pages are relative to +one of those, ie +<ul> +<!-- Convert < to CGI-speak so it won't be interpreted as start of tag --> +<li><xmp><A HREF="../../faq.html"> under ~scheme</xmp></li> +<li><xmp><A HREF="../../source/stk/faq.html"> under ~instcd</xmp></li> +</ul> +This is to ensure that a single, current version is always accessible from +both WEB sites, and that a copy of it will always be burned into the ~instcd +ISO file when we make one. + +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/scheme.png b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/scheme.png new file mode 100644 index 0000000..ea1a99f --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/scheme.png Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/index.html new file mode 100644 index 0000000..46051ac --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/index.html @@ -0,0 +1,19 @@ +<html><body><pre> + + Source Distributions + +You can + +# download <a href="stk-1.3.6.tgz">stk-1.3.6.tgz</a>. +# <a href="src">view individual files</a>. + +Sources last updated: *Monday, 02-Aug-2010 12:48:11 PDT* + +Here are instructions for compiling UCB Stk: + + * <a href="unix.html">UNIX</a> + * <a href="windows.html">Windows</a> + * <a href="mac.html">MacOSX</a> + * <a href="linux.html">Linux</a> + +</pre></body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/linux.html b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/linux.html new file mode 100644 index 0000000..78f8a3e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/linux.html @@ -0,0 +1,122 @@ +<html><head> +<meta http-equiv="content-type" content="text/html; charset=windows-1252"> +<title>UCB Scheme - Red Hat Linux binary distribution</title> +</head> +<body> + +<!---<CENTER><IMG SRC="/images/iesg2.jpg" BORDER=0 ALIGN=CENTER></CENTER>---> +<p> +<img src="scheme.png" border="0"> +<br> + +</p><h1>Binary distribution for Red Hat Linux</h1> + +<p> +<b>Installing:</b> +</p><ul> +<p> + You need to have Korn Shell(ksh) installed + on your system for this to install. +</p><p> + For <b>Fedora Linux 4</b>, you can download the + precompiled UCB Scheme for Linux onto your home machine from + <a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/STk-4.0.1-ucb1.3.6.i386.rpm">STk-4.0.1-ucb1.3.6.i386.rpm</a>. + Then you can install it by running this command as root:</p> + <pre> # rpm -Uvh STk-4.0.1-ucb1.3.6.i386.rpm </pre> + +<p> + For <b>Debian GNU/Linux</b>, you can use a program called 'alien' to convert + the RPM package to a <code>*.deb</code> file. 'alien' is in the main + debian archive (see <a href="http://packages.debian.org/unstable/admin/alien"> + http://packages.debian.org/unstable/admin/alien</a>). IE, as root: + </p><pre> # wget http://inst.eecs.berkeley.edu/~scheme/precompiled/Linux/STk-4.0.1-ucb1.3.6.i386.rpm + # apt-get install alien + # alien -i STk-4.0.1-ucb1.3.6.i386.rpm (uses dpkg)</pre> + <b><i>Note</i></b>: There is a package name conflict between the UCB + Scheme ("stk") and a current package available through the Debian mirror + system + (<a href="http://packages.debian.org/unstable/sound/stk"> + http://packages.debian.org/unstable/sound/stk</a>), so if you run one of + these: + <pre> # apt-get upgrade + # apt-get dist-upgrade (upgrade all packages)</pre> + you should re-install UCB Scheme like this: + <pre> # apt-get remove stk (the sound synth toolkit) + # dpkg -i stk_4.0.1-1_i386.deb</pre> + <p> + For <b>Debian GNU/Linux</b> on a pure64 (amd64) system: + </p><pre> Use a 32-bit computer to 'alien STk-4.0.1-ucb1.3.6.i386.rpm' + On the 64-bit computer, run 'apt-get install ia32-libs' + copy the $STK.deb file from the 32-bit computer to the local amd64, ie: + 'scp user@32bHost:~/$STK.deb root@local64bHost:~/.' + On the 64-bit computer, run 'dpkg --force-architecture $STK.deb'</pre> + + (<i>Thanks to Joachim for providing the Debian information.</i>) + <p> + For <b>Centos 7</b>, we have these notes from a user (untested, Dec 2015): + </p><pre> Using is CentOS 7, 64 bit, with GNOME Desktop. + + 'rpm -Uvh STk-4.0.1-ucb1.3.6.i386.rpm' fails, saying some dependencies + were missing. + + 'rpm -i STk-4.0.1-ucb1.3.6.i386.rpm' works on one installation of + CentOS 7 and not on another. + + This seems to always work: + Click on the link for STk-4.0.1-ucb1.3.6.i386.rpm right inside of + Firefox, then Firefox will ask me to Save it, or to Open it using + installer. And if I use that Open it using installer option, then + it will install.</pre> + + (<i>Thanks to Kin for providing the Centos 7 information.</i>) + +<p> + It will be installed in <code>/usr/local/bin/stk</code>, + <code>/usr/local/bin/envdraw</code>, with support files in + <code>/usr/local/lib/stk</code>, and a few documentation files in + <code>/usr/doc/STk-4.0.1-ucb1.3.6</code>.</p><p> +</p><p> +We also have <a href="https://inst.eecs.berkeley.edu/%7Escheme/precompiled/Linux/STk-4.0.1-ucb1.3.6.src.rpm">the source RPM</a>, +and the <a href="https://inst.eecs.berkeley.edu/%7Escheme/precompiled/Linux/STk.spec">spec</a> file used for building the source +RPM, if you want to build from source. Here are <a href="https://inst.eecs.berkeley.edu/%7Escheme/precompiled/Linux/srcrebuild.html"> +instructions for building from source</a> for Linux.</p> +</ul> +<p> +<b>Running:</b> +</p><p> +</p><ul> +The STk versions for different classes are installed in the +<i>/usr/local/bin</i> directory. +<p> +</p><ul> +<table> + <tbody><tr> + <td><i>stk-explorin</i></td> + <td>Loads all UCB Scheme procedures including explorin.scm, for CS3S</td> + </tr> + <tr> + <td><i>stk-simply</i></td> + <td>loads all UCB Scheme procedures including simply.scm, for CS3 and CS61A</td> + </tr> + <tr> + <td><i>stk-grfx</i></td> + <td>loads UCB Scheme turtle graphics procedures, for CS9D and CS47B</td> + </tr> + <tr> + <td><i>stk</i></td> + <td>loads no UCB Scheme procedures, for CS9D and CS47B</td> + </tr> +</tbody></table> +</ul> +</ul> +<p> + Please see the <a href="https://inst.eecs.berkeley.edu/%7Escheme/faq.html">UCB Scheme FAQ file</a> + for more information. +</p><p> +<a href="https://inst.eecs.berkeley.edu/%7Escheme/">Go back to the main UCB Scheme site.</a> +</p><hr> +<a href="http://inst.eecs.berkeley.edu/">EECS Instuctional Support Group</a><br> +<address>scheme@inst.EECS.Berkeley.EDU</address> + + +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/mac.html b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/mac.html new file mode 100644 index 0000000..f84b7c8 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/mac.html @@ -0,0 +1,110 @@ +<html><head> +<meta http-equiv="content-type" content="text/html; charset=windows-1252"> +<title>UCB Scheme - Mac OS X binary distribution</title> +<style type="text/css">@namespace url(http://www.w3.org/1999/xhtml); +@font-face { + font-family: 'EasyRead2'; + font-style: normal; + font-weight: 400; + src: local('EasyRead2'), url(https://cdn.rawgit.com/PullJosh/files/gh-pages/Arial-LargePeriod2.woff) format('woff'); +}input[type="text"], input[type="textarea"], textarea { + font-family: "EasyRead2" !important; + }</style></head> +<body> + +<!--- <CENTER><IMG SRC="/images/iesg2.jpg" BORDER=0 ALIGN=CENTER></CENTER>--> +<p> +<img src="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/UCB%20Scheme%20-%20Mac%20OS%20X%20binary%20distribution_files/scheme.png" border="0"> +<br> + +</p><h1>Binary distribution for Mac OSX</h1> + +<p> +Please download the following executable and follow the directions given below.<br> +Please follow the directions supplied in the README. +</p> +<b>New UCB STk Distribution available as of August 2010.</b> +<p> +<a href="https://inst.eecs.berkeley.edu/%7Escheme/precompiled/OSX/STk-ucb1.3.6.dmg">STk-ucb1.3.6.dmg</a> (2225 Kbytes) + +<!--- +<P> +Please download the following executable and follow the directions given below.</br> +Please follow the directions supplied in the README. +</P> +<A HREF="STk-ucb1.3.6.dmg">STk-ucb1.3.6.dmg</A> (2952 Kbytes) + +<P> +<B>Errata:</B> +A typo in the "emacs.simply" file (in the Extras folder) will +cause this error when you start <i>emacs</i>: +<ul> +<ul><pre>File Error: Cannot open load file, stkdb</pre></ul> +To correct that, edit the line in emacs.simply<br> +from +<ul><code>(concat stkhome "/share/emacs/lisp")))</code></ul> +to +<ul><code>(concat stkhome "/share/emacs")))</code></ul> +and restart <i>emacs</i>. +</ul> + +---> + +</p><p> +<b>Running:</b> + +<i>These are STk versions that are used by CS classes: +</i></p><p><i> +</i></p><ul><i> +<table width="80%"> + <tbody><tr> + <td valign="top"><i>stk-explorin</i></td> + <td>Loads all UCB Scheme procedures including explorin.scm, for CS3S</td> + </tr> + <tr> + <td valign="top" width="20%"><i>stk-simply</i></td> + <td>Loads all UCB Scheme procedures including simply.scm, for CS3 and CS61A</td> + </tr> + <tr> + <td valign="top" width="20%"><i>stk-grfx</i></td> + <td>Loads UCB Scheme turtle graphics procedures, for CS9D and CS47B</td> + </tr> + <tr> + <td valign="top" width="20%"><i>stk</i></td> + <td>Loads no UCB Scheme procedures, for CS9D and CS47B</td> + </tr> + <tr> <td colspan="2"> </td></tr> + <tr> + <td valign="top" width="20%"><i>Graphics mode:</i></td> + <td> + To run these within emacs and to use other graphical features (such + as turtle graphics and envdraw), you need to have XWindows (X11) + installed on your MacOSX system. + <p> + On newer versions of MacOSX, you must install X11 from the Installation + CD (in "Optional Software") that came with your computer or operating + system purchase. + </p><p> + In the emacs window, type the 2 keys ESC-S at the same time to open + STk in an emacs buffer. It loads the version of stk that is defined + in your .emacs file. That file is typically in your home directory. + The line that defines what is loaded by ESC-S is one of these: + </p><p></p><pre> (setq scheme-program-name "stk-simply") + (setq scheme-program-name "stk-explorin") </pre> + If one of those are not there, you can add it and restart emacs. + </td> + </tr> + <tr> <td colspan="2"> </td></tr> +</tbody></table> +</i></ul><i> +<p> +Click here for <a href="https://inst.eecs.berkeley.edu/%7Escheme/precompiled/OSX/OLD/">old Mac OS X packages</a> which are no longer +supported.</p><p> + +<a href="https://inst.eecs.berkeley.edu/%7Escheme/">Go back to the main UCB Scheme site.</a><br> +</p><hr> +<a href="http://inst.eecs.berkeley.edu/">EECS Instuctional Support Group</a><br> +<address>scheme@inst.EECS.Berkeley.EDU</address> + + +</i></body></html> \ No newline at end of file diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/scheme.png b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/scheme.png new file mode 100644 index 0000000..ea1a99f --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/scheme.png Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=D;O=A new file mode 100644 index 0000000..41ae521 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=D;O=A @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Scheme/source/src</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Scheme/source/src</h1> + <table> + <tr><th valign="top"><img src="../../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/?C=D;O=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../index.html">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="stk/index.html">stk/</a> </td><td align="right">2020-01-23 00:16 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/ucb/">ucb/</a> </td><td align="right">2020-01-23 00:16 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=M;O=A new file mode 100644 index 0000000..8160c00 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=M;O=A @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Scheme/source/src</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Scheme/source/src</h1> + <table> + <tr><th valign="top"><img src="../../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/?C=N;O=A">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/?C=M;O=D">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../index.html">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="stk/index.html">stk/</a> </td><td align="right">2020-01-23 00:16 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/ucb/">ucb/</a> </td><td align="right">2020-01-23 00:16 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=N;O=D new file mode 100644 index 0000000..a18fec8 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=N;O=D @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Scheme/source/src</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Scheme/source/src</h1> + <table> + <tr><th valign="top"><img src="../../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="index.html?C=S%3BO=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../index.html">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/ucb/">ucb/</a> </td><td align="right">2020-01-23 00:16 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="stk/index.html">stk/</a> </td><td align="right">2020-01-23 00:16 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=S;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=S;O=A new file mode 100644 index 0000000..6e97957 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/index.html?C=S;O=A @@ -0,0 +1,16 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Scheme/source/src</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Scheme/source/src</h1> + <table> + <tr><th valign="top"><img src="../../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/?C=N;O=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/?C=S;O=D">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../index.html">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="stk/index.html">stk/</a> </td><td align="right">2020-01-23 00:16 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/ucb/">ucb/</a> </td><td align="right">2020-01-23 00:16 </td><td align="right"> - </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/stk/index.html b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/stk/index.html new file mode 100644 index 0000000..37af27c --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/src/stk/index.html @@ -0,0 +1,50 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Scheme/source/src/stk</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Scheme/source/src/stk</h1> + <table> + <tr><th valign="top"><img src="../../../../../../icons/blank.gif" alt="[ICO]"></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/?C=N;O=D">Name</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/?C=M;O=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/?C=S;O=A">Size</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/?C=D;O=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../src">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/BINARY_DISTRIB">BINARY_DISTRIB</a> </td><td align="right">2007-06-10 22:01 </td><td align="right">1.0K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/CHANGES">CHANGES</a> </td><td align="right">2007-06-10 22:01 </td><td align="right"> 17K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/COMPILING-HINTS">COMPILING-HINTS</a> </td><td align="right">2007-06-10 22:01 </td><td align="right">6.4K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/COPYRIGHTS">COPYRIGHTS</a> </td><td align="right">2007-06-10 22:01 </td><td align="right">5.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/ChangeLog">ChangeLog</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> 89K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/ChangeLog.1">ChangeLog.1</a> </td><td align="right">2007-09-11 12:07 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Contrib/">Contrib/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Demos/">Demos/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Doc/">Doc/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Extensions/">Extensions/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Gmp/">Gmp/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Help/">Help/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/INSTALL">INSTALL</a> </td><td align="right">2007-06-10 22:01 </td><td align="right">7.1K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/INSTALL.win32">INSTALL.win32</a> </td><td align="right">2007-06-10 22:01 </td><td align="right">1.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Lib/">Lib/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Makefile.in">Makefile.in</a> </td><td align="right">2010-08-02 12:43 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/STklos/">STklos/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Snow/">Snow/</a> </td><td align="right">2007-06-10 22:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Src/">Src/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Stack/">Stack/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Tcl/">Tcl/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Tk/">Tk/</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Utils/">Utils/</a> </td><td align="right">2007-06-10 22:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/VERSION">VERSION</a> </td><td align="right">2010-08-02 12:43 </td><td align="right"> 6 </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/folder.gif" alt="[DIR]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/Win32/">Win32/</a> </td><td align="right">2007-06-10 22:00 </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/config.guess">config.guess</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> 44K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/config.h.in">config.h.in</a> </td><td align="right">2007-09-11 12:07 </td><td align="right">3.3K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/config.sub">config.sub</a> </td><td align="right">2007-09-11 12:07 </td><td align="right"> 32K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/configure">configure</a> </td><td align="right">2010-08-02 12:43 </td><td align="right">218K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/configure.in">configure.in</a> </td><td align="right">2010-08-02 12:43 </td><td align="right"> 15K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/depcomp">depcomp</a> </td><td align="right">2007-06-10 22:01 </td><td align="right"> 13K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/install-sh">install-sh</a> </td><td align="right">2007-06-10 22:01 </td><td align="right">5.5K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/install.bat">install.bat</a> </td><td align="right">2007-06-10 22:01 </td><td align="right">1.8K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/missing">missing</a> </td><td align="right">2007-06-10 22:01 </td><td align="right"> 10K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/mkinstalldirs">mkinstalldirs</a> </td><td align="right">2007-06-10 22:01 </td><td align="right">1.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Scheme/source/src/stk/paths">paths</a> </td><td align="right">2007-09-11 12:07 </td><td align="right">270 </td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/stk-1.3.6.tgz b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/stk-1.3.6.tgz new file mode 100644 index 0000000..14bb327 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/stk-1.3.6.tgz Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/unix.html b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/unix.html new file mode 100644 index 0000000..60ec50e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/unix.html @@ -0,0 +1,52 @@ + + UCB Scheme - source building instructions for UNIX + +These instructions pertain to *Unix*, such as Solaris. Other unix +variants may require modifications in the source and build scripts. + +To build and install stk under Unix, please perform the following steps. + + 1. Obtain the most recent sources using subversion. + + svn co https://isvn.eecs.berkeley.edu/scheme/trunk + + 2. You will end up with two folders. One is labeled stk and the second + one ucb. + + 3. change directory into stk first and configure the stk distribution. + + INSTALLROOT is the location you want to install stk. The default is + /usr/local. + + cd stk + ./configure --prefix=$INSTALLROOT --disable-dynload --disable-elf --disable-dld + + 4. Once the configure is complete, compile stk. + + gmake + + 5. Once gmake completes, install stk. + + gmake install + + 6. Now change directory to the second folder labeled "ucb" + + cd ../ucb + + 7. Configure ucb with the same INSTALLROOT you choose for stk. + + ./configure --prefix=$INSTALLROOT + + 8. Once the configure is complete, compile ucb. + + gmake + + 9. Once gmake completes, install ucb files. + + gmake install + +------------------------------------------------------------------------ +Go back to the main UCB Scheme site. <http://inst/~scheme/> +------------------------------------------------------------------------ +scheme@inst.EECS.Berkeley.EDU + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/windows.html b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/windows.html new file mode 100644 index 0000000..4794a67 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Scheme/source/windows.html @@ -0,0 +1,171 @@ +<html><head> +<meta http-equiv="content-type" content="text/html; charset=windows-1252"> +<title>UCB Scheme - binary distribution for Windows</title> +</head> +<body> + +<!---<CENTER><IMG SRC="/images/iesg2.jpg" BORDER=0 ALIGN=CENTER></CENTER>--> +<p> +<img src="scheme.png" border="0"> +<br> + +</p><h1>Binary distribution for Windows</h1> +<p> +Please download the following executable and follow the directions given below.<br> +This version includes a subset of Cygwin, which emulates a UNIX environment<br> +and uses XWindows to enable an STk buffer within <b>emacs</b>.<br> +</p><p> +<a name="installing"> +<b>Installing:</b> +</a></p><p><a name="installing"> +These are steps you only need to do once, to install UCB Scheme. +</a></p><p><a name="installing"> +<table align="center" width="90%" border="0"> +<tbody><tr><td> +<b>New UCB STk Distribution available July 2010.</b> + +<ol> + +<li> Download + <a href="https://inst.eecs.berkeley.edu/%7Escheme/precompiled/MS-Windows/STk-ucb1.3.6.exe">STk-ucb1.3.6.exe</a> (100467 Kbytes).<br> + +</li><li> After downloading the above file double-click the icon. You will be<br> + prompted as to whether to install Berkeley Scheme. Click on 'Yes'<br> + and wait until the process completes.<br> + +</li><li> Once the script has completed you will find an icon on your desktop<br> + labeled <b>Cygwin</b>. Double-click this icon. After some initialization<br> + type <b>one</b> of these at the prompt.</li> + <pre> /usr/local/bin/setup-stk explorin (If you want the <a href="windows.html#explorin">explorin</a> setup) + or + /usr/local/bin/setup-stk simply (If you want the <a href="windows.html#simply">simply</a> setup)</pre> + +<li> Now you can start an X session in one of two ways. You can either<br> + double click on the <b>XWin Server</b> link on your desktop or type at<br> + the bash shell prompt "startxwin.exe". + +</li><li> If you are prompted by the windows security system, choose the + <b>unblock</b> option. + +</li><li> Finally you will get a window that has an <b>X</b> at the top left corner. + +</li><li> From now on, you only need to double-click on the <b>XWin Server</b> desktop<br> + icon to open a window for running UCB Scheme. + +</li></ol> +</td></tr></tbody></table> +</a><a name="running"> +<b>Running:</b> +</a></p><p><a name="running"> +To start UCB Scheme within <b>emacs</b>: +</a></p><ul><a name="running"> + <li> Double-click on the icon labeled <b>XWin Server</b> on your desktop. + </li><li> Wait a moment until a window pops up that has an <b>X</b> at the top left corner. + </li><li> In the "X" window, type "emacs &". An emacs window pops up. + </li><li> In the emacs window, type the 2 keys ESC-S at the same time + to open STk in an emacs buffer. (On a PC, the meta key is ESC.) + </li><li> This loads the version of stk that is defined in your + <i>.emacs</i> file. The line that defines what is loaded by + ESC-S is one of these: + <p></p><pre> (setq scheme-program-name "stk-simply") + (setq scheme-program-name "stk-explorin") + </pre> + You can change that by repeating step 5 above, or by editting the <i>.emacs</i> file directly. +</li></a></ul><a name="running"> +<p> +These are STk versions that are used by CS classes: +</p><p> +<table valign="top" align="center" width="90%" border="0"> + <tbody><tr> + <td valign="top" width="15%"><a name="explorin"><i>stk-explorin</i></a></td> + <td> </td> + <td> + For CS3S. + Loads all UCB Scheme procedures and explorin.scm takes precedence. + </td> + </tr> + <tr> + <td valign="top" width="15%"><a name="simply"><i>stk-simply</i></a></td> + <td> </td> + <td> + For CS3 and CS61A. + Loads all UCB Scheme procedures and simply.scm takes precedence. + </td> + </tr> + <tr> + <td valign="top" width="15%"><i>stk-grfx</i></td> + <td> </td> + <td> + For CS9D and CS47B. + Loads UCB Scheme turtle graphics procedures. + <ul> + <li> Double-click on the icon labeled "startx.bat" on your desktop. + </li><li> Wait a moment until a window pops up that has an <b>X</b> at the top left corner. + </li><li> In the "X" window, type "/usr/local/bin/stk-grfx" + </li><li> See <a href="http://inst.eecs.berkeley.edu/%7Escheme/README-explorin-vs-simply.txt"> http://inst.eecs.berkeley.edu/~scheme/README-explorin-vs-simply.txt</a> (section stk-grfx) for simple initializing of grafical window using stk-grfx. + </li></ul> + </td> + </tr> + <tr> + <td valign="top" width="15%"><i>stk</i></td> + <td> </td> + <td> + For CS9D and CS47B. + Loads no UCB Scheme procedures. + This version is currently not created on Windows for use with emacs, + but each of the versions above include all of the commands that are + used. + </td> + </tr> + <tr> + <td valign="top" width="15%"><i>stkdb</i></td> + <td> </td> + <td> + This is Prof Hilfinger's STk debugger. + <ul> + <li> See <a href="http://inst.eecs.berkeley.edu/%7Escheme/docs/stkdb.pdf"> + http://inst.eecs.berkeley.edu/~scheme/docs/stkdb.pdf</a> for help. + </li><li> Load it by typing these at the <code>STk></code> prompts: + <pre> (define stkdb-vicinity "/usr/local/lib/stkdb/") + (load "/usr/local/lib/stkdb/stkdb.scm") + (import stk-debugger)</pre> + </li></ul> + </td> + </tr> +</tbody></table> +</p></a><p><a name="running"> +</a><a name="alternate"> +<b>Alternate versions:</b> +</a></p><p><a name="alternate"> +</a></p><menu><a name="alternate"> +</a><li><a name="alternate"><b>Edwin/Emacs</b><br> +Users have reported that they successfully loaded and used the UC Berkeley +"</a><a href="https://inst.eecs.berkeley.edu/%7Escheme/source/src/ucb/bscheme/simply.scm">simply.scm</a>" +module on Microsoft Vista using the *scheme* mode buffer in the +<a href="http://www.gnu.org/software/mit-scheme/documentation/mit-scheme-user/Edwin.html">Edwin/Emacs</a> +editor that comes with +<a href="http://www.gnu.org/software/mit-scheme/">MIT/GNU Scheme</a>. + The default Edwin buffer is in *scheme* mode and additional +*scheme* buffers can be created using the Edwin REPL command. +Note that the UC Berkeley +"<a href="https://inst.eecs.berkeley.edu/%7Escheme/source/src/ucb/envdraw/">envdraw.scm</a>" module won't work +with this version of Scheme becuase it requires +<a href="http://kaolin.unice.fr/STk/">Tk</a>. +<p> +<!--- +<p>To recompile this distribution, first +<A HREF="/~scheme/source/">download the sources</A>, +and then follow the instructions in +<A HREF="http://inst.eecs.berkeley.edu/~scheme/cvsweb/cvsweb.cgi/~checkout~/stk/brg/win-rebuild.txt?only_with_tag=HEAD&content-type=text/plain">stk/brg/win-rebuild.txt</A>.</p> + +<p>Click here to find <A HREF="OLD/">old versions</A> which are no +longer supported.</p> +---> + +<a href="https://inst.eecs.berkeley.edu/%7Escheme/">Go back to the main UCB Scheme site.</a><br> +</p><hr> +<a href="http://inst.eecs.berkeley.edu/">EECS Instuctional Support Group</a><br> +<address>scheme@inst.EECS.Berkeley.EDU</address> + + +</li></menu></body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=D;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=D;O=A new file mode 100644 index 0000000..96770c5 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=D;O=A @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Solutions</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Solutions</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=D">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/proj2">proj2</a> </td><td align="right">2010-03-05 03:48 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week1">week1</a> </td><td align="right">2007-05-03 20:57 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week2">week2</a> </td><td align="right">2006-09-25 11:11 </td><td align="right"> 15K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week3">week3</a> </td><td align="right">2003-02-12 11:55 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week4">week4</a> </td><td align="right">2003-05-16 13:20 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week5">week5</a> </td><td align="right">2004-02-26 19:30 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week6">week6</a> </td><td align="right">2005-10-04 15:17 </td><td align="right"> 31K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week7">week7</a> </td><td align="right">2004-08-06 15:53 </td><td align="right"> 21K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week8">week8</a> </td><td align="right">2003-02-14 18:30 </td><td align="right">4.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week9">week9</a> </td><td align="right">2004-03-30 15:37 </td><td align="right"> 20K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week10">week10</a> </td><td align="right">2005-04-08 10:37 </td><td align="right"> 36K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week11">week11</a> </td><td align="right">2004-04-21 15:46 </td><td align="right"> 25K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week12">week12</a> </td><td align="right">2004-04-21 15:49 </td><td align="right"> 32K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week13">week13</a> </td><td align="right">2004-04-21 15:51 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week14">week14</a> </td><td align="right">2005-12-07 22:53 </td><td align="right"> 42K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week15">week15</a> </td><td align="right">2004-05-12 12:53 </td><td align="right">9.6K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=D;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=D;O=D new file mode 100644 index 0000000..97181b6 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=D;O=D @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Solutions</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Solutions</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week15">week15</a> </td><td align="right">2004-05-12 12:53 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week14">week14</a> </td><td align="right">2005-12-07 22:53 </td><td align="right"> 42K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week13">week13</a> </td><td align="right">2004-04-21 15:51 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week12">week12</a> </td><td align="right">2004-04-21 15:49 </td><td align="right"> 32K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week11">week11</a> </td><td align="right">2004-04-21 15:46 </td><td align="right"> 25K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week10">week10</a> </td><td align="right">2005-04-08 10:37 </td><td align="right"> 36K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week9">week9</a> </td><td align="right">2004-03-30 15:37 </td><td align="right"> 20K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week8">week8</a> </td><td align="right">2003-02-14 18:30 </td><td align="right">4.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week7">week7</a> </td><td align="right">2004-08-06 15:53 </td><td align="right"> 21K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week6">week6</a> </td><td align="right">2005-10-04 15:17 </td><td align="right"> 31K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week5">week5</a> </td><td align="right">2004-02-26 19:30 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week4">week4</a> </td><td align="right">2003-05-16 13:20 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week3">week3</a> </td><td align="right">2003-02-12 11:55 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week2">week2</a> </td><td align="right">2006-09-25 11:11 </td><td align="right"> 15K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week1">week1</a> </td><td align="right">2007-05-03 20:57 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/proj2">proj2</a> </td><td align="right">2010-03-05 03:48 </td><td align="right">5.9K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=M;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=M;O=A new file mode 100644 index 0000000..b284eed --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=M;O=A @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Solutions</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Solutions</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=D">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week3">week3</a> </td><td align="right">2003-02-12 11:55 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week8">week8</a> </td><td align="right">2003-02-14 18:30 </td><td align="right">4.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week4">week4</a> </td><td align="right">2003-05-16 13:20 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week5">week5</a> </td><td align="right">2004-02-26 19:30 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week9">week9</a> </td><td align="right">2004-03-30 15:37 </td><td align="right"> 20K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week11">week11</a> </td><td align="right">2004-04-21 15:46 </td><td align="right"> 25K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week12">week12</a> </td><td align="right">2004-04-21 15:49 </td><td align="right"> 32K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week13">week13</a> </td><td align="right">2004-04-21 15:51 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week15">week15</a> </td><td align="right">2004-05-12 12:53 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week7">week7</a> </td><td align="right">2004-08-06 15:53 </td><td align="right"> 21K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week10">week10</a> </td><td align="right">2005-04-08 10:37 </td><td align="right"> 36K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week6">week6</a> </td><td align="right">2005-10-04 15:17 </td><td align="right"> 31K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week14">week14</a> </td><td align="right">2005-12-07 22:53 </td><td align="right"> 42K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week2">week2</a> </td><td align="right">2006-09-25 11:11 </td><td align="right"> 15K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week1">week1</a> </td><td align="right">2007-05-03 20:57 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/proj2">proj2</a> </td><td align="right">2010-03-05 03:48 </td><td align="right">5.9K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=M;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=M;O=D new file mode 100644 index 0000000..56cfe86 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=M;O=D @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Solutions</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Solutions</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/proj2">proj2</a> </td><td align="right">2010-03-05 03:48 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week1">week1</a> </td><td align="right">2007-05-03 20:57 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week2">week2</a> </td><td align="right">2006-09-25 11:11 </td><td align="right"> 15K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week14">week14</a> </td><td align="right">2005-12-07 22:53 </td><td align="right"> 42K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week6">week6</a> </td><td align="right">2005-10-04 15:17 </td><td align="right"> 31K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week10">week10</a> </td><td align="right">2005-04-08 10:37 </td><td align="right"> 36K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week7">week7</a> </td><td align="right">2004-08-06 15:53 </td><td align="right"> 21K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week15">week15</a> </td><td align="right">2004-05-12 12:53 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week13">week13</a> </td><td align="right">2004-04-21 15:51 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week12">week12</a> </td><td align="right">2004-04-21 15:49 </td><td align="right"> 32K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week11">week11</a> </td><td align="right">2004-04-21 15:46 </td><td align="right"> 25K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week9">week9</a> </td><td align="right">2004-03-30 15:37 </td><td align="right"> 20K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week5">week5</a> </td><td align="right">2004-02-26 19:30 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week4">week4</a> </td><td align="right">2003-05-16 13:20 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week8">week8</a> </td><td align="right">2003-02-14 18:30 </td><td align="right">4.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week3">week3</a> </td><td align="right">2003-02-12 11:55 </td><td align="right"> 11K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=N;O=A b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=N;O=A new file mode 100644 index 0000000..b8f2eb8 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=N;O=A @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Solutions</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Solutions</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=D">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/proj2">proj2</a> </td><td align="right">2010-03-05 03:48 </td><td align="right">5.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week1">week1</a> </td><td align="right">2007-05-03 20:57 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week2">week2</a> </td><td align="right">2006-09-25 11:11 </td><td align="right"> 15K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week3">week3</a> </td><td align="right">2003-02-12 11:55 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week4">week4</a> </td><td align="right">2003-05-16 13:20 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week5">week5</a> </td><td align="right">2004-02-26 19:30 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week6">week6</a> </td><td align="right">2005-10-04 15:17 </td><td align="right"> 31K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week7">week7</a> </td><td align="right">2004-08-06 15:53 </td><td align="right"> 21K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week8">week8</a> </td><td align="right">2003-02-14 18:30 </td><td align="right">4.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week9">week9</a> </td><td align="right">2004-03-30 15:37 </td><td align="right"> 20K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week10">week10</a> </td><td align="right">2005-04-08 10:37 </td><td align="right"> 36K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week11">week11</a> </td><td align="right">2004-04-21 15:46 </td><td align="right"> 25K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week12">week12</a> </td><td align="right">2004-04-21 15:49 </td><td align="right"> 32K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week13">week13</a> </td><td align="right">2004-04-21 15:51 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week14">week14</a> </td><td align="right">2005-12-07 22:53 </td><td align="right"> 42K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week15">week15</a> </td><td align="right">2004-05-12 12:53 </td><td align="right">9.6K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=N;O=D b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=N;O=D new file mode 100644 index 0000000..97181b6 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/index.html?C=N;O=D @@ -0,0 +1,30 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + <head> + <title>Index of /~bh/61a-pages/Solutions</title> + </head> + <body> +<h1>Index of /~bh/61a-pages/Solutions</h1> + <table> + <tr><th valign="top"><img src="../../../icons/blank.gif" alt="[ICO]"></th><th><a href="index.html?C=N%3BO=A">Name</a></th><th><a href="index.html?C=M%3BO=A">Last modified</a></th><th><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/?C=S;O=A">Size</a></th><th><a href="index.html?C=D%3BO=A">Description</a></th></tr> + <tr><th colspan="5"><hr></th></tr> +<tr><td valign="top"><img src="../../../icons/back.gif" alt="[PARENTDIR]"></td><td><a href="../../61a-pages">Parent Directory</a> </td><td> </td><td align="right"> - </td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week15">week15</a> </td><td align="right">2004-05-12 12:53 </td><td align="right">9.6K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week14">week14</a> </td><td align="right">2005-12-07 22:53 </td><td align="right"> 42K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week13">week13</a> </td><td align="right">2004-04-21 15:51 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week12">week12</a> </td><td align="right">2004-04-21 15:49 </td><td align="right"> 32K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week11">week11</a> </td><td align="right">2004-04-21 15:46 </td><td align="right"> 25K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week10">week10</a> </td><td align="right">2005-04-08 10:37 </td><td align="right"> 36K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week9">week9</a> </td><td align="right">2004-03-30 15:37 </td><td align="right"> 20K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week8">week8</a> </td><td align="right">2003-02-14 18:30 </td><td align="right">4.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week7">week7</a> </td><td align="right">2004-08-06 15:53 </td><td align="right"> 21K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week6">week6</a> </td><td align="right">2005-10-04 15:17 </td><td align="right"> 31K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week5">week5</a> </td><td align="right">2004-02-26 19:30 </td><td align="right"> 19K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week4">week4</a> </td><td align="right">2003-05-16 13:20 </td><td align="right">3.9K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/week3">week3</a> </td><td align="right">2003-02-12 11:55 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week2">week2</a> </td><td align="right">2006-09-25 11:11 </td><td align="right"> 15K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/text.gif" alt="[TXT]"></td><td><a href="week1">week1</a> </td><td align="right">2007-05-03 20:57 </td><td align="right"> 11K</td><td> </td></tr> +<tr><td valign="top"><img src="../../../icons/unknown.gif" alt="[ ]"></td><td><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Solutions/proj2">proj2</a> </td><td align="right">2010-03-05 03:48 </td><td align="right">5.9K</td><td> </td></tr> + <tr><th colspan="5"><hr></th></tr> +</table> +</body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week1 b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week1 new file mode 100644 index 0000000..0616593 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week1 @@ -0,0 +1,325 @@ +CS 61A Week 1 Lab and Homework Solutions + +FIRST LAB: + +No problems that required original solutions! + +SECOND LAB: + +1. Nothing original. + +2. If the last letter is Y, then we have to look at the next-to-last: + +(define (plural wd) + (if (and (equal? (last wd) 'y) + (not (vowel? (last (bl wd))))) + (word (bl wd) 'ies) + (word wd 's))) + +If you didn't think to use AND in that way, it can be done with nested IFs: + +(define (plural wd) + (if (equal? (last wd) 'y) + (if (vowel? (last (bl wd))) + (word wd 's) + (word (bl wd) 'ies)) + (word wd 's))) + +Or, if that's too messy, with a subprocedure: + +(define (plural wd) + (if (equal? (last wd) 'y) + (y-plural (bl wd)) + (word wd 's))) + +(define (y-plural prefix) + (if (vowel? (last prefix)) + (word prefix 'ys) + (word prefix 'ies))) + +All of these assume the definition of vowel? in the handout. + + +3. There are, of course, many possible ways to write this. None is +perfectly elegant. The difficulty is figuring out which of the three +arguments is smallest, so you can leave it out of the computation. +The way I like best, I think, is a little tricky: + +(define (sum-square-large papa mama baby) + (define (square x) (* x x)) + (cond ((> mama papa) (sum-square-large mama papa baby)) + ((> baby mama) (sum-square-large papa baby mama)) + (else (+ (square papa) (square mama))))) + +I think this way is pretty concise and easy to read. However, it's okay +if you did it more straightforwardly like this: + +(define (sum-square-large a b c) + (define (square x) (* x x)) + (define (sumsq x y) (+ (square x) (square y))) + (cond ((and (<= a b) (<= a c)) (sumsq b c)) + ((and (<= b a) (<= b c)) (sumsq a c)) + (else (sumsq a b)) )) + +If you didn't think of using AND to identify the conditions, it could also +be done using nested IFs: + +(define (sum-square-large a b c) + (define (square x) (* x x)) + (define (sumsq x y) (+ (square x) (square y))) + (if (>= a b) + (if (>= b c) + (sumsq a b) + (sumsq a c)) + (if (>= a c) + (sumsq a b) + (sumsq b c)))) + +Some people wanted to start by solving a subproblem: a function to find +the two largest numbers. This can be done, but it's harder: + +(define (sum-square-large a b c) + (define (square x) (* x x)) + (define (sumsq nums) (+ (square (first nums)) (square (last nums)))) + (define (two-largest a b c) + (cond ((and (<= a b) (<= a c)) (sentence b c)) + ((and (<= b a) (<= b c)) (sentence a c)) + (else (sentence a b)))) + (sumsq (two-largest a b c))) + +The trick here is that a function can't return two values, so two-largest +has to return a sentence containing the two numbers. This hardly seems +worth the effort, but the attempt to split the problem into logical pieces +was well-motivated. It's a good idea in general, but it didn't work out +well this time. + +See also: +http://code.google.com/p/jrm-code-project/wiki/ProgrammingArt + + +4. Since we are examining each word of a sentence, the solution will +involve a recursion of the form (dupls-removed (bf sent)). The base +case is an empty sentence; otherwise, there are two possibilities, +namely, (first sent) either is or isn't duplicated later in the sentence. + +(define (dupls-removed sent) + (cond ((empty? sent) '()) + ((member? (first sent) (bf sent)) + (dupls-removed (bf sent))) + (else (sentence (first sent) (dupls-removed (bf sent)))))) + +============================================================ + +HOMEWORK: + +1. The Scheme interpreter applies an ordinary procedure by first evaluating +all the argument expressions and then invoking the procedure. Consider first +one of the examples that worked: + +> (new-if (= 2 3) 0 5) + +Scheme evaluates this expression as follows: + +(a) Evaluate the symbol new-if. Its value turns out to be an ordinary +procedure. Therefore the rest of the combination is evaluated normally. + +(b) Evaluate the three argument expressions. Their values are #f [i.e., +false], 0, and 5 respectively. + +(c) Apply the procedure new-if to the argument values #f, 0, and 5. By the +substitution model, this means we must substitute "#f" for "predicate", +"0" for "then-clause", and "5" for "else-clause": + (cond (#f 0) (else 5)) + +(d) Evaluate this new expression, getting the value 5. + +By contrast, if we'd entered the expression + +> (if (= 2 3) 0 5) + +Scheme would evaluate it as follows: + +(a) Notice that the symbol IF is a keyword, the name of a special form. +Therefore the rest of the combination is evaluated specially. + +(b) Invoke the special form with the UNEVALUATED argument expressions +"(= 2 3)", "0", and "5". + +(c) The "if" evaluation rule then causes its first argument to be +evaluated. Since the value is #f, i.e. false, it then evaluates +the expression "5", whose value is the number 5. The expression "0" +is never evaluated. + +In the example above, it doesn't make any PRACTICAL difference that the +expression "5" was evaluated to produce the number 5. [By the way, +Scheme uses quotation marks for a special purpose, which isn't what I +mean here. I'm just using them to delimit something you're to imagine as +having typed into the computer.] + +Now, on to the square root program. In the body of sqrt-iter, the third and +final argument to new-if is the expression + (sqrt-iter (improve guess x) x) +Suppose we invoke sqrt-iter with an expression like + (sqrt-iter 1 4) +Since sqrt-iter and new-if are both ordinary procedures, they are applied +just like the new-if example I described earlier: + +(a) Evaluate the symbol sqrt-iter. Its value turns out to be an ordinary +procedure. Therefore the rest of the combination is evaluated normally. + +(b) Evaluate the two argument expressions. Their values are 1 and 4, +respectively. + +(c) Apply the procedure sqrt-iter to the argument values 1 and 4. By the +substitution model, this means we must substitute "1" for "guess" and +"4" for "x": + (new-if (good-enough? 1 4) + 1 + (sqrt-iter (improve 1 4) + 4)) + +(d) Evaluate this new expression. Here is where the problem comes in. +Since new-if is an ordinary procedure, we follow steps (a)-(d) for this +sub-evaluation also: + +(a) Evaluate the symbol new-if. Its value turns out to be an ordinary +procedure. Therefore the rest of the combination is evaluated normally. + +(b) Evaluate the three argument expressions. The first one turns out +(after a sequence of (a)-(d) steps) to have the value #f, i.e., false. +The second has the value 1. The third invokes sqrt-iter, so we start +another (a)-(d) sequence of steps just like the first one. But the first +one is still pending, waiting for us to finish down here. That is, the +evaluation of the original (sqrt-iter 1 4) is waiting for the evaluation +of the new-if expression, and that's waiting for the evaluation of the new +sqrt-iter expression. But THAT will involve evaluating another new-if +expression, which will... This is an infinite regress. You'll never get +any answer at all. + +This business of nested evaluations isn't all wrong. In the real +sqrt-iter the same thing happens, with sqrt-iter invoking if, and if +invoking sqrt-iter, and so on. The difference is that with the real +if, a special form, Scheme gets to test whether the good-enough? expression +is true or false BEFORE it evaluates the inner sqrt-iter expression. At +first the good-enough? expression is false, so if invokes sqrt-iter repeatedly +just as in the new-if version. But eventually good-enough? returns a true +[that is, #t] value, and then the inner sqrt-iter expression need not be +evaluated. With new-if, we needed to evaluate the inner sqrt-iter before +we had a chance to see if good-enough? came out true or false. Therefore +Scheme never finds out that it's time to stop iterating. + + +2. + +(define (squares nums) + (if (empty? nums) + '() + (se (square (first nums)) + (squares (bf nums)) ))) + + +3. The tricky part is that the first word of the sentence must be +treated specially, so there has to be a top-level procedure that handles +it and also invokes a recursive subprocedure for the rest of the words: + +(define (switch sent) + (se (switch-first (first sent)) + (switch-rest (bf sent)) )) + +(define (switch-first wd) + (cond ((equal? wd 'you) 'I) + ((equal? wd 'I) 'you) + ((equal? wd 'me) 'you) + (else wd) )) + +(define (switch-rest sent) + (if (empty? sent) + '() + (se (switch-one (first sent)) + (switch-rest (bf sent)) ))) + +(define (switch-one wd) + (cond ((equal? wd 'you) 'me) + ((equal? wd 'I) 'you) + ((equal? wd 'me) 'you) + (else wd) )) + +4. + +(define (ordered? sent) + (cond ((empty? (bf sent)) #t) + ((> (first sent) (first (bf sent))) #f) + (else (ordered? (bf sent))) )) + +This procedure is written assuming that the argument is a sentence that +contains at least one word, and that all of the words are numbers. + + +5. + +(define (ends-e sent) + (cond ((empty? sent) '()) + ((equal? (last (first sent)) 'e) + (se (first sent) (ends-e (bf sent)))) + (else (ends-e (bf sent))))) + + +6. Are "and" and "or" ordinary functions or special forms? The general idea +of the solution is to type in an expression that will produce an error if all +its subexpressions are evaluated, and see if they all are. For example, +supposing there is no definition for the symbol "x" you could say + +> (or 1 2 x) + +According to the ordinary evaluation rule, the expressions "1" "2" and "x" +should all be evaluated before "or" is invoked, so you should get an error +message complaining about the unbound symbol. On the other hand, if "or" +is a special form, you'd expect it to stop as soon as it evaluates the "1" +and give 1 as its result. + +If you try this in Scheme, you don't get an error message. +This means, most likely, that "or" is a special form whose arguments +are evaluated one by one. If there were an error message could you +conclude that "or" is ordinary? No! "Or" could be a special form +that evaluates its arguments right-to-left. For that matter there is +no reason that "or" couldn't evaluate the middle argument first. How +would you test for that? + +(Of course, in reality you know that they're special forms because +the textbook told you so.) + +Why might a special form be a good idea? Here are a few reasons: + +(a) Efficiency. Suppose instead of numbers or symbols I used combinations +as the arguments to "or", and each combination takes several minutes to +compute. If the first one happens to be true, it'd be a shame to waste all +that time computing the others. + +(b) Conditions that depend on each other. Consider the expression + +> (or (= x 0) (> 5 (/ y x))) + +This will work fine if "or" is special and evaluates left-to-right, +otherwise we may be dividing by zero. + +Reasons why an ordinary function might be preferred: + +(c) Fewer kludges. It's very easy to read and understand a Lisp program +if you can be sure that everything that looks like (blah glorp zilch) +is evaluated by evaluating the subexpressions and then applying the +procedure "blah" to the arguments "glorp" and "zilch". Everything that +looks like a procedure application but is really a special case just makes +things that much harder to understand. + +(d) Creeping featurism. Where do we stop? Maybe we should make +multiplication a special form; after all, in the expression + +> (* 0 x) + +there's no real reason to evaluate x because we know zero times anything +is zero. Pretty soon there are no real functions left in the language. + +(e) Functional objects. You're not expected to know this yet, but +next week you'll learn that procedures can be manipulated as data, +just as numbers can. But special forms aren't procedures and there are +some things we can't do to them. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week10 b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week10 new file mode 100644 index 0000000..53e4817 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week10 @@ -0,0 +1,977 @@ +CS 61A -- Week 10 Solutions + + +LAB ASSIGNMENT: + +3.12 append vs. append! + +exp1 is (b); exp2 is (b c d). Append (without the !) makes copies of the +two pairs that are part of the list x. (You can tell because it uses +cons, which is the constructor function that generates a brand new pair.) +Append! does not invoke cons; it mutates the existing pairs to combine +the two argument lists. + + +2. Set! vs. set-cdr! + +There are two ways to think about this, and you should understand both +of them: + +The syntactic explanation -- SET! is a special form; its first argument +must be a symbol, not a compound expression. So anything of the form + (set! (...) ...) +must be an error. + +The semantic explanation -- SET! and SET-CDR! are about two completely +different purposes. SET! is about the bindings of variables in an +environment. SET-CDR! is about pointers within pairs. SET! has nothing +to do with pairs; SET-CDR! has nothing to do with variables. There is +no situation in which they are interchangeable. + +(Note: The book says, correctly, that the two are *equivalent* in the +sense that you can use one to implement the other. But what that means +is that, for example, if we didn't have pairs in our language we could +use the oop techniques we've learned, including local state variables +bound in an environment, to simulate pairs. Conversely, we'll see in +Chapter 4 that we can write a Scheme interpreter, including environments +as an abstract data type, building them out of pairs. But given that +we are using the regular Scheme's built-in pairs and built-in environments, +those have nothing to do with each other.) + + + +3a. Fill in the blanks. + +> (define list1 (list (list 'a) 'b)) +list1 +> (define list2 (list (list 'x) 'y)) +list2 +> (set-cdr! ____________ ______________) +okay +> (set-cdr! ____________ ______________) +okay +> list1 +((a x b) b) +> list2 +((x b) y) + +The key point here is that if we're only allowed these two SET-CDR!s then +we'd better modify list2 first, because the new value for list1 uses the +sublist (x b) that we'll create for list2. + +So it's + +(set-cdr! (car list2) (cdr list1)) + +(set-cdr! (car list1) (car list2)) + + + +3b. Now do (set-car! (cdr list1) (cadr list2)). + +Everything that used to be "b" is now "y" instead: + +> list1 +((a x y) y) +> list2 +((x y) y) + +The reason is that there was only one appearance of the symbol B in +the diagram, namely as the cadr of list1; every appearance of B in the +printed representation of list1 or list2 came from pointers to the +pair (cdr list1). The SET-CAR! only makes one change to one pair, +but three different things point (directly or indirectly) to it. + + + +3.13 make-cycle + +The diagram is + + +----------------+ + | | + V | +---> XX--->XX--->XX---+ + | | | + V V V + a b c + +(last-pair z) will never return, because there is always a non-empty +cdr to look at next. + + + +3.14 Mystery procedure. + +This procedure is REVERSE!, that is to say, it reverses the list +by mutation. After + + (define v (list 'a 'b 'c 'd)) + (define w (mystery v)) + +the value of w is the list (d c b a); the value of v is the list (a) +because v is still bound to the pair whose car is a. (The procedure +does not change the cars of any pairs.) + + + +5a. We want Scheme-2 to accept both the ordinary form + (define x 3) +and the procedure-abbreviation form + (define (square x) (* x x)) +The latter should be treated as if the user had typed + (define square (lambda (x) (* x x))) +The hint says we can use data abstraction to achieve this. + +Here is the existing code that handles DEFINE: + +(define (eval-2 exp env) + (cond ... + ((define-exp? exp) (put (cadr exp) + (eval-2 (caddr exp) env) + env) + 'okay) + ...)) + +We're going to use selectors for the pieces of the DEFINE expression: + +(define (eval-2 exp env) + (cond ... + ((define-exp? exp) (put (DEFINE-VARIABLE exp) + (eval-2 (DEFINE-VALUE exp) env) + env) + 'okay) + ...)) + +To get the original behavior we would define the selectors this way: + +(define define-variable cadr) +(define define-value caddr) + +But instead we'll check to see if the cadr of the expression is a +symbol (so we use the ordinary notation) or a list (abbreviating +a procedure definition): + +(define (define-variable exp) + (if (pair? (cadr exp)) + (caadr exp) ;(define (XXXX params) body) + (cadr exp))) + +(define (define-value exp) + (if (pair? (cadr exp)) + (cons 'lambda + (cons (cdadr exp) ;params + (cddr exp))) ;body + (caddr exp))) + +Writing selectors like this is the sort of situation in which the compositions +like CAADR are helpful. That particular one is (car (cadr exp)), which is the +first element of the second element of the expression. (You should recognize +CADR, CADDR, and CADDDR as selectors for the second, third, and fourth +elements of a list.) The second element of the expression is a list such as +(SQUARE X), so the car of that list is the variable name. + +Since DEFINE-VALUE is supposed to return an expression, we have to construct +a LAMBDA expression, making explicit what this notation abbreviates. + + +5c. In a procedure call, parameters are processed from left to right, +and PUT adds each parameter to the front of the environment. So they +end up in reverse order. Similarly, top-level DEFINEs add things to +the global environment in reverse order. So the sequence of expressions +should be + +Scheme-2: (define b 2) +Scheme-2: (define a 1) +Scheme-2: ((lambda (c b) 'foo) 4 3) + +It doesn't matter what's in the body of the procedure, since we're +interested in the environments rather than in the values returned. + + + +HOMEWORK: + +3.16 incorrect count-pairs + +This procedure would work fine for any list structure that can be expressed +as (quote <anything>). It fails when there are two pointers to the same pair. + +(define a '(1 2 3)) (count-pairs a) --> 3 + +(define b (list 1 2 3)) +(set-car! (cdr b) (cddr b)) (count-pairs b) --> 4 + +(define x (list 1)) +(define y (cons x x)) +(define c (cons y y)) (count-pairs c) --> 7 + +(define d (make-cycle (list 1 2 3))) (count-pairs d) --> infinite loop + +Note from example c that it's not necessary to use mutators to create +a list structure for which this count-pairs fails, but it is necessary +to have a name for a substructure so that you can make two pointers to it. +The name needn't be global, though; I could have said this: + +(define c + (let ((x (list 1))) + (let ((y (cons x x))) + (cons y y) ))) + + +3.17 correct count-pairs + +(define (count-pairs lst) + (let ((pairlist '()) + (count 0)) + (define (mark-pair pair) + (set! pairlist (cons pair pairlist)) + (set! count (+ count 1))) + (define (subcount pair) + (cond ((not (pair? pair)) 'done) + ((memq pair pairlist) 'done) + (else (mark-pair pair) + (subcount (car pair)) + (subcount (cdr pair))))) + (subcount lst) + count)) + +The list structure in pairlist can get very complicated, especially if +the original structure is complicated, but it doesn't matter. The cdrs +of pairlist form a straightforward, non-circular list; the cars may point +to anything, but we don't follow down the deep structure of the cars. We +use memq, which sees if PAIR (a pair) is eq? (NOT equal?) to the car of some +sublist of pairlist. Eq? doesn't care about the contents of a pair; it just +looks to see if the two arguments are the very same pair--the same location +in the computer's memory. + +[Non-experts can stop here and go on to the next problem. The following +optional material is just for experts, for a deeper understanding.] + +It's not necessary to use local state and mutation. That just makes the +problem easier. The reason is that a general list structure isn't a sequence; +it's essentially a binary tree of pairs (with non-pairs as the leaves). So +you have to have some way to have the pairs you encounter in the left branch +still remembered as you traverse the right branch. The easiest way to do +this is to remember all the pairs in a variable that's declared outside the +SUBCOUNT procedure, so it's not local to a particular subtree. + +But another way to do it is to have a more complicated helper procedure +that takes PAIRLIST as an argument, but also sequentializes the traversal by +keeping a list of yet-unvisited nodes, sort of like the breadth-first tree +traversal procedure (although this goes depth-first because TODO is a stack, +not a queue): + +(define (count-pairs lst) + (define (helper pair pairlist count todo) + (if (or (not (pair? pair)) (memq pair pairlist)) ; New pair? + (if (null? todo) ; No. More pairs? + count ; No. Finished. + (helper (car todo) pairlist count (cdr todo))) ; Yes, pop one. + (helper (car pair) (cons pair pairlist) (+ count 1) ; Yes, count it, + (cons (cdr pair) todo)))) ; do car, push cdr + (helper lst '() 0 '())) + +As you're reading this code, keep in mind that all the calls to HELPER +are tail calls, so this is an iterative process, unlike the solution +using mutation, in which the call (SUBCOUNT (CAR PAIR)) isn't a tail call +and so that solution generates a recursive process. + +And after you understand that version, try this one: + +(define (count-pairs lst) + (define (helper pair pairlist count todo) + (if (or (not (pair? pair)) (memq pair pairlist)) ; New pair? + (todo pairlist count) ; No. Continue. + (helper (car pair) (cons pair pairlist) (+ count 1) ; Yes, count it, + (lambda (pairlist count) ; do car, push cdr + (helper (cdr pair) pairlist count todo))))) + (helper lst '() 0 (lambda (pairlist count) count))) + +Here, instead of being a list of waiting pairs, TODO is a procedure that +knows what tasks remain. The name for such a procedure is a "continuation" +because it says how to continue after doing some piece of the problem. +This is an example of "continuation-passing style" (CPS). Since TODO is +tail-called, you can think of it as the target of a goto, if you've used +languages with that feature. + + +3.21 print-queue + +The extra pair used as the head of the queue has as its car an ordinary +list of all the items in the queue, and as its cdr a singleton list of +the last element of the queue. Each of Ben's examples print as a list of +two members; the first member is a list containing all the items in the +queue, and the second member is just the last item in the queue. If you +look at what Ben printed, take its car and you'll get the queue items; +take its cdr and you'll get a list of one member, namely the last queue +item. The only exception is Ben's last example. In that case, the car of +what Ben prints correctly indicates that the queue is empty, but the cdr +still contains the former last item. This is explained by footnote 22 +on page 265, which says that we don't bother updating the rear-ptr when we +delete the last (or any) member of the queue because a null front-ptr is +good enough to tell us the queue is empty. + +It's quite easy to print the sequence of items in the queue: + +(define print-queue front-ptr) + + +3.25 multi-key table + +Several students generalized the message-passing table implementation +from page 271, which is fine, but it's also fine (and a little easier) +to generalize the simpler version of page 270: + +(define (lookup keylist table) + (cond ((not table) #f) + ((null? keylist) (cdr table)) + (else (lookup (cdr keylist) + (assoc (car keylist) (cdr table)))))) + +(define (insert! keylist value table) + (if (null? keylist) + (set-cdr! table value) + (let ((record (assoc (car keylist) (cdr table)))) + (if (not record) + (begin + (set-cdr! table + (cons (list (car keylist)) (cdr table))) + (insert! (cdr keylist) value (cadr table))) + (insert! (cdr keylist) value record))))) + +That solution assumes all the entries are compatible. If you say + (insert! '(a) 'a-value my-table) + (insert! '(a b) 'ab-value my-table) +the second call will fail because it will try to + (assoc 'b (cdr 'a-value)) +and the CDR will cause an error. If you'd like to be able to have +values for both (a) and (a b), the solution is more complicated; +each table entry must contain both a value and a subtable. In the +version above, each association list entry is a pair whose CAR is +a key and whose CDR is *either* a value or a subtable. In the version +below, each association list entry is a pair whose CAR is a key and +whose CDR is *another pair* whose CAR is a value (initially #f) and whose +CDR is a subtable (initially empty). Changes are in CAPITALS below: + +(define (lookup keylist table) + (cond ; *** the clause ((not table) #f) is no longer needed + ((null? keylist) (CAR table)) ; *** + (else (LET ((RECORD (assoc (car keylist) (cdr table)))) + (IF (NOT RECORD) + #F + (lookup (cdr keylist) (CDR RECORD))))))) ; *** + +(define (insert! keylist value table) + (if (null? keylist) + (SET-CAR! table value) ; *** + (let ((record (assoc (car keylist) (cdr table)))) + (if (not record) + (begin + (set-cdr! table + (cons (LIST (CAR keylist) #F) (cdr table))) ; *** + (insert! (cdr keylist) value (CDADR table))) + (insert! (cdr keylist) value (CDR RECORD)))))) ; *** + + +Note: In a sense, this problem can be solved without doing any work at all. +In a problem like + + (lookup '(red blue green) color-table) + +you can think of (red blue green) as a list of three keys, each of which is +a word, or as a single key containing three words! So the original +one-dimensional implementation will accept this as a key. However, for a +large enough table, this would be inefficient because you have to look +through a very long list of length Theta(n^3) instead of three lists each +Theta(n) long. + + + +3.27 Memoization + +Here's what happened when I tried it, with annotations in [brackets]. +In the annotations, (fib n) really means that (memo-fib n) is called! +I just said "fib" to save space. + +> (memo-fib 3) +"CALLED" memo-fib 3 [user calls (fib 3)] + "CALLED" lookup 3 (*table*) + "RETURNED" lookup #f + "CALLED" memo-fib 2 [(fib 3) calls (fib 2)] + "CALLED" lookup 2 (*table*) + "RETURNED" lookup #f + "CALLED" memo-fib 1 [(fib 2) calls (fib 1)] + "CALLED" lookup 1 (*table*) + "RETURNED" lookup #f + "CALLED" insert! 1 1 (*table*) + "RETURNED" insert! ok + "RETURNED" memo-fib 1 [(fib 1) returns 1] + "CALLED" memo-fib 0 [(fib 2) calls (fib 0)] + "CALLED" lookup 0 (*table* (1 . 1)) + "RETURNED" lookup #f + "CALLED" insert! 0 0 (*table* (1 . 1)) + "RETURNED" insert! ok + "RETURNED" memo-fib 0 [(fib 0) returns 0] + "CALLED" insert! 2 1 (*table* (0 . 0) (1 . 1)) + "RETURNED" insert! ok + "RETURNED" memo-fib 1 [(fib 2) returns 1] + "CALLED" memo-fib 1 [(fib 3) calls (fib 1) ****] + "CALLED" lookup 1 (*table* (2 . 1) (0 . 0) (1 . 1)) + "RETURNED" lookup 1 + "RETURNED" memo-fib 1 [(fib 1) returns 1] + "CALLED" insert! 3 2 (*table* (2 . 1) (0 . 0) (1 . 1)) + "RETURNED" insert! ok +"RETURNED" memo-fib 2 [(fib 3) returns 2] +2 + +The line marked **** above is the only call to memo-fib in this example in +which the memoization actually finds a previous value. We are computing +(fib 1) for the second time, so memo-fib finds it in the table. + +In general, calling memo-fib for some larger argument will result in two +recursive calls for each smaller argument value. For example: + + fib 6 ---> fib 5, fib 4 + fib 5 ---> fib 4, fib 3 + fib 4 ---> fib 3, fib 2 + +and so on. (memo-fib 4) is evaluated once directly from (memo-fib 6) and once +from (memo-fib 5). But only one of those actually requires any computation; +the other finds the value in the table. + +This is why memo-fib takes Theta(n) time: it does about 2n recursive calls, +half of which are satisfied by values found in the table. + +If we didn't use memoization, or if we defined memo-fib to be (memoize fib), +we would have had to compute (f 1) twice. In this case there would only be +one duplicated computation, but the number grows exponentially; for (fib 4) +we have to compute (fib 2) twice and (fib 1) three times. + +By the way, notice that if we try (memo-fib 3) a second time from the Scheme +prompt, we get a result immediately: + +> (memo-fib 3) +"CALLED" memo-fib 3 + "CALLED" lookup 3 (*table* (3 . 2) (2 . 1) (0 . 0) (1 . 1)) + "RETURNED" lookup 2 +"RETURNED" memo-fib 2 +2 + + +Scheme-2 set!: This is actually tricky -- I got it wrong the first time +I tried it. The trouble is that the procedure PUT in scheme2.scm, which +was written for use by DEFINE, doesn't modify an existing binding, and +therefore isn't useful for implementing SET!. But it's not a good idea +to change PUT, because that breaks DEFINE. We want a DEFINE in an inner +environment (that is, a DEFINE in a procedure body) to make a new +variable, even if a variable with the same name exists in the global +environment. This is why PUT always adds a new binding, not checking +for an old one. But SET! should *only* modify an existing binding, +not create a new one. + +We change eval-2 like this: + +(define (eval-2 exp env) + (cond ... + ((define-exp? exp) (put (define-variable exp) + (eval-2 (define-value exp) env) + env) + 'okay) + ((SET!-EXP? EXP) (SET-PUT (CADR EXP) + (EVAL-2 (CADDR EXP) ENV) + ENV) + 'OKAY) + ...)) + +Then we define SET-PUT: + +(define (set-put var val env) + (let ((pair (assoc var (cdr env)))) + (if pair + (set-cdr! pair val) + (error "No such variable: " var)))) + + +Scheme-2 bug: This is a complicated diagram, and I'm going to +abbreviate it by not showing the pairs that are inside lambda +expressions. The notation (\x) below means (lambda (x) ...). + + +GLOBAL ENV ----> XX--->XX----------------->XX--------------------->X/ + +----/ ---^ | | | +-^ | + | +--/ V V V ! V + | | *TABLE* XX XX ! XX + | | | \ | \ ! | \ + | | V V V V ! V | + | | g XX--->XX--->X/ h XX--->XX--->X/ ! f | + | | | | | | | | ! | + | | V V | V V | ! | + | | PROC (\z) | PROC (\y) | ! | + | | | | ! | + | +-----------------------------+ | ! | + | +-+ ! | + | | ! | + | | ! | + | V ! | + | env for (f 3)----------> XX--->XX | + | | +-^| | + | V | V | + | *TABLE*| XX | + | | / \ | + | env for (h 4)--------> XX--->XX------------+ V V | + | | | x 3 | + | V V +-----------------+ + | *TABLE* XX V + | / \ XX--->XX--->X/ + | V V | | | + | y 4 PROC (\x) | + +----------------------------------------------------------+ + +The problem is with the vertical arrow made of exclamation points near +the right of the picture. It tells us that the environment created by +the call (f 3) extends the global environment *as it exists at the +time of this procedure call*! So the new environment has a new +binding for X, and the existing binding for F. This is the environment +that procedure H remembers, so when we call (h 4), within the body of H +the bindings of G and H are invisible. + +The whole point of this exercise is to convince you that it's not +good enough to represent an environment as a list of bindings. We +have to represent it as a list of frames, each of which is a list +of bindings. This is how the textbook does it, in week 12. + + +Vector exercises: + +1. VECTOR-APPEND is basically like VECTOR-CONS in the notes, +except that we need two loops, one for each source vector: + +(define (vector-append vec1 vec2) + (define (loop newvec vec n i) + (if (>= n 0) + (begin (vector-set! newvec i (vector-ref vec n)) + (loop newvec vec (- n 1) (- i 1))))) + (let ((result (make-vector (+ (vector-length vec1) (vector-length vec2))))) + (loop result vec1 (- (vector-length vec1) 1) (- (vector-length vec1) 1)) + (loop result vec2 (- (vector-length vec2) 1) (- (vector-length result) 1)) + result)) + + +2. VECTOR-FILTER is tough because we have to do the filtering twice, +first to get the length of the desired result vector, then again to +fill in the slots: + +(define (vector-filter pred vec) + (define (get-length n) + (cond ((< n 0) 0) + ((pred (vector-ref vec n)) + (+ 1 (get-length (- n 1)))) + (else (get-length (- n 1))))) + (define (loop newvec n i) + (cond ((< n 0) newvec) + ((pred (vector-ref vec n)) + (vector-set! newvec i (vector-ref vec n)) + (loop newvec (- n 1) (- i 1))) + (else (loop newvec (- n 1) i)))) + (let ((newlen (get-length (- (vector-length vec) 1)))) + (loop (make-vector newlen) (- (vector-length vec) 1) (- newlen 1)))) + + +3. Bubble sort is notorious because nobody ever uses it in practice, +because it's slow, but it always appears in programming course +exercises, because the operation of swapping two neighboring elements +is relatively easy to write. + +(a) Here's the program: + +(define (bubble-sort! vec) + (let ((len (vector-length vec))) + (define (loop n) + (define (bubble k) + (if (= k n) + 'one-pass-done + (let ((left (vector-ref vec (- k 1))) + (right (vector-ref vec k))) + (if (> left right) + (begin (vector-set! vec (- k 1) right) + (vector-set! vec k left))) + (bubble (+ k 1))))) + (if (< n 2) + vec + (begin (bubble 1) + (loop (- n 1))))) + (loop len))) + +(b) As the hint says, we start by proving that after calling (bubble 1) inside +the call to (loop n), element number n-1 is greater than any element to its +left. + +(Bubble 1) reorders elements 0 and 1 so that vec[0] is less than or equal to +vec[1] (I'm using C/Java notation for elements of vectors), then reorders +elements 1 (the *new* element 1, which is the larger of the original first +two elements) and element 2 so that vec[1] is less than or equal to vec[2]. +It continues, but let's stop here for the moment. After those two steps, +the new vec[2] is at least as large as vec[1]. But the intermediate value +of vec[1] was larger than the new vec[0], so vec[2] must be the largest. + +This might be clearer with a chart. There are six possible original +orderings of the first three elements; here they are, with the ordering +after the 0/1 swap and the ordering after the 1/2 swap. (To make the +table narrower, I've renamed VEC as V. Also, I'm calling the three +values 0, 1, and 2; it doesn't matter what the actual values are, as +long as they are in the same order as a particular line in the table.) + +original after 0/1 swap after 1/2 swap +-------------- -------------- -------------- +v[0] v[1] v[2] v[0] v[1] v[2] v[0] v[1] v[2] +---- ---- ---- ---- ---- ---- ---- ---- ---- + + 0 1 2 0 1 2 0 1 2 + 0 2 1 0 2 1 0 1 2 + 1 0 2 0 1 2 0 1 2 + 1 2 0 1 2 0 1 0 2 + 2 0 1 0 2 1 0 1 2 + 2 1 0 1 2 0 1 0 2 + +After the first swap, we have v[0] <= v[1]. After the second swap, +we have v[1] <= v[2]. But note that there is no guarantee about the +order of the final v[0] and v[1]! All that's guaranteed is that +the largest of the three values is now in v[2]. + +Similarly, after the 2/3 swap, we know that vec[3] is the largest +of the first four values, because either the original vec[3] was +already largest, in which case there is no swap, or the value of +vec[2] just before the 2/3 swap is the largest of the original +vec[0] through vec[2], so it's the largest of vec[0] through vec[3] +and will rightly end up as the new vec[3]. + +Subprocedure BUBBLE calls itself recursively until k=n, which means +that vec[n-1] is the largest of the first n elements. QED. + +Now, if that's true about a single pass, then the first pass +"bubbles" the largest number to the end of the vector (this is why +it's called bubble sort), and then we call LOOP recursively to +sort the remaining elements. The second pass gets vec[len-2] to +be the largest of the first len-1 elements, etc. After LEN passes, +the entire vector is sorted. + +This was a handwavy proof. To make it rigorous, it'd be done by +mathematical induction -- two inductions, one for the swaps in a +single pass, and one for the multiple passes. + +(c) It's Theta(N^2), for the usual reason: N passes, each of which +takes time Theta(N). + + +Extra for experts +----------------- + +3.19 constant-space cycle? predicate + +Just to make sure you understand the issue, let me first do 3.18, which +asks us to write cycle? without imposing a constant-space requirement. +It's a lot like the correct version of count-pairs; it has to keep track +of which pairs we've seen already. + +(define (cycle? lst) + (define (iter lst pairlist) + (cond ((not (pair? lst)) #f) + ((memq lst pairlist) #t) + (else (iter (cdr lst) (cons lst pairlist))))) + (iter lst '())) + +This is simpler than count-pairs because we only have to chase down pointers +in one direction (the cdr) instead of two, so it can be done iteratively. +I check (not (pair? lst)) rather than (null? lst) so that the program won't +blow up on a list structure like (a . b) by trying to take the cdr of b. + +The trouble is that the list pairlist will grow to be the same size as the +argument list, if the latter doesn't contain a cycle. What we need is to +find a way to keep the auxiliary list of already-seen pairs without using +up any extra space. + +Here is the very cleverest possible solution: + +(define (cycle? lst) + (define (iter fast slow) + (cond ((not (pair? fast)) #f) + ((not (pair? (cdr fast))) #f) + ((eq? fast slow) #t) + (else (iter (cddr fast) (cdr slow))) )) + (if (not (pair? lst)) + #f + (iter (cdr lst) lst) )) + +This solution runs in Theta(1) space and Theta(n) time. We send two +pointers CDRing down the list at different speeds. If the list is not a +cycle, the faster one will eventually hit the end of the list, and we'll +return false. If the list is a cycle, the faster one will eventually +overtake the slower one, and we'll return true. (You may think that this +will only work for odd-length cycles, or only for even-length cycles, +because in the opposite case the fast pointer will leapfrog over the slow +one, but if that happens the two pointers will become equal on the next +iteration.) + +If you didn't come up with this solution, don't be upset; most folks don't. +This is a classic problem, and struggling with it is a sort of initiation +ritual in the Lisp community. Here's a less clever solution that runs in +Theta(1) space but needs Theta(n^2) time. It is like the first solution, the +one that uses an auxiliary pairlist, but the clever idea is to use the +argument list itself as the pairlist. This can be done by clobbering its cdr +pointers temporarily. It's important to make sure we put the list back +together again before we leave! The idea is that at any time we will have +looked at some initial sublist of the argument, and we'll know for sure that +that part is cycle-free. We keep the tested part and the untested part +separate by changing the cdr of the last tested pair to the empty list, +remembering the old cdr in the single extra pointer variable that this +algorithm requires. + +(define (cycle? lst) + (define (subq? x list) + (cond ((null? list) #f) + ((eq? x list) #t) + (else (subq? x (cdr list))))) + (define (iter lst pairlist pairlist-tail) + (cond ((not (pair? lst)) + (set-cdr! pairlist-tail lst) + #f) + ((subq? lst pairlist) + (set-cdr! pairlist-tail lst) + #t) + (else + (let ((oldcdr (cdr lst))) + (set-cdr! pairlist-tail lst) + (set-cdr! lst '()) + (iter oldcdr pairlist lst) )))) + (cond ((null? lst) #f) + (else (let ((oldcdr (cdr lst))) + (set-cdr! lst '()) + (iter oldcdr lst lst))))) + +Be wary of computing (cdr lst) before you've tested whether or not lst is +empty. + + +3.23 Double-ended queue + +The only tricky part here is rear-delete-deque!. All the other deque +operations can be performed in Theta(1) time using exactly the same structure +used for the queue in 3.3.2. The trouble with rear-delete is that in order +to know where the new rear is, we have to be able to find the next-to-last +member of the queue. In the 3.3.2 queue, the only way to do that is to cdr +down from the front, which takes Theta(n) time for an n-item queue. To +avoid that, each item in the queue must point not only to the next item but +also to the previous item: + ++---+---+ +| | | --------------------------------------------+ ++-|-+---+ | + | | + V V ++---+---+ +---+---+ +---+---+ +---+--/+ +| | | --------->| | | --------->| | | --------->| | | / | ++-|-+---+ +-|-+---+ +-|-+---+ +-|-+/--+ + | ^ | ^ | ^ | + | +-----+ | +-----+ | +-----+ | + V | V | V | V ++--/+---+ | +---+---+ | +---+---+ | +---+---+ +| / | | | +------ | | | +------ | | | +------ | | | ++/--+-|-+ +---+-|-+ +---+-|-+ +---+-|-+ + | | | | + V V V V + a b c d + + +Whew! The first pair, at the top of the diagram, is the deque header, just +like the queue header in 3.3.2. The second row of four pairs is a regular +list representing the deque entries, again just like 3.3.2. But instead of +each car in the second row pointing to a queue item, each car in this +second row points to another pair, whose car points to the previous element +on the second row and whose cdr points to the actual item. + +;; data abstractions for deque members + +;; we use front-ptr, rear-ptr, set-front-ptr!, and set-rear-ptr! from p. 263 + +(define deque-item cdar) +(define deque-fwd-ptr cdr) +(define deque-back-ptr caar) +(define set-deque-fwd-ptr! set-cdr!) +(define (set-deque-back-ptr! member new-ptr) + (set-car! (car member) new-ptr)) + +;; Now the things we were asked to do: + +(define (make-deque) (cons '() '())) + +(define (empty-deque? deque) (null? (front-ptr deque))) + +(define (front-deque deque) + (if (empty-deque? deque) + (error "front-deque called with empty queue") + (deque-item (front-ptr deque)))) + +(define (rear-deque deque) + (if (empty-deque? deque) + (error "rear-deque called with empty queue") + (deque-item (rear-ptr deque)))) + +(define (front-insert-deque! deque item) + (let ((new-member (list (cons '() item)))) + (cond ((empty-deque? deque) + (set-front-ptr! deque new-member) + (set-rear-ptr! deque new-member) + "done") + (else + (set-deque-fwd-ptr! new-member (front-ptr deque)) + (set-deque-back-ptr! (front-ptr deque) new-member) + (set-front-ptr! deque new-member) + "done")))) + +(define (rear-insert-deque! deque item) + (let ((new-member (list (cons '() item)))) + (cond ((empty-deque? deque) + (set-front-ptr! deque new-member) + (set-rear-ptr! deque new-member) + "done") + (else + (set-deque-back-ptr! new-member (rear-ptr deque)) + (set-deque-fwd-ptr! (rear-ptr deque) new-member) + (set-rear-ptr! deque new-member) + "done")))) + +(define (front-delete-deque! deque) + (cond ((empty-deque? deque) + (error "front-delete-deque! called with empty queue")) + ((null? (deque-fwd-ptr (front-ptr deque))) + (set-front-ptr! deque '()) + (set-rear-ptr! deque '()) + "done") + (else + (set-deque-back-ptr! (deque-fwd-ptr (front-ptr deque)) '()) + (set-front-ptr! deque (deque-fwd-ptr (front-ptr deque))) + "done"))) + +(define (rear-delete-deque! deque) + (cond ((empty-deque? deque) + (error "rear-delete-deque! called with empty queue")) + ((null? (deque-back-ptr (rear-ptr deque))) + (set-front-ptr! deque '()) + (set-rear-ptr! deque '()) + "done") + (else + (set-deque-fwd-ptr! (deque-back-ptr (rear-ptr deque)) '()) + (set-rear-ptr! deque (deque-back-ptr (rear-ptr deque))) + "done"))) + +I could also have gotten away with leaving garbage in the rear-ptr of +an emptied deque, but the ugliness involved outweighs the slight time +saving to my taste. Notice an interesting property of the use of data +abstraction here: at the implementation level, set-deque-back-ptr! and +set-deque-fwd-ptr! are rather different, but once that difference is +abstracted away, rear-delete-deque! is exactly like front-delete-deque! +and ditto for the two insert procedures. + +The reason these procedures return "done" instead of returning deque, +like the single-end queue procedures in the book, is that the deque is a +circular list structure, so if we tried to print it we'd get in trouble. +We should probably invent print-deque: + +(define (print-deque deque) + (define (sub member) + (if (null? member) + '() + (cons (deque-item member) + (sub (deque-fwd-ptr member))))) + (sub (front-ptr deque))) + +But I'd say it's a waste of time to cons up this printable list every time +we insert or delete something. + + +2. cxr-name + +This is a harder problem than its inverse function cxr-function! We are +given a function as a black box, not knowing how it was defined; the only +way we can get any information about it is to invoke it on a cleverly +chosen argument. + +We need three ideas here. The first one is this: Suppose we knew that we +were given either CAR or CDR as the argument. We could determine which +of them by applying the mystery function to a pair with the word CAR as its +car, and the word CDR as its cdr: + +(define (simple-cxr-name fn) + (fn '(car . cdr))) + +You might think to generalize this by building a sort of binary tree with +function names at the leaves: + +(define (two-level-cxr-name fn) + (fn '((caar . cdar) . (cadr . cddr)))) + +But there are two problems with this approach. First, note that this +version *doesn't* work for CAR or CDR, only for functions with exactly +two CARs or CDRs composed. Second, the argument function might be a +composition of *any* number of CARs and CDRs, so we'd need an infinitely +deep tree. + +So the second idea we need is a way to attack the mystery function one +component at a time. We'd like the first CAR or CDR applied to our argument +(that's the rightmost one, don't forget) to be the only one that affects the +result; once that first choice has been made, any CARs or CDRs applied to the +result shouldn't matter. The clever idea is to make a pair whose CAR and CDR +both point to itself! So any composition of CARs and CDRs of this pair will +still just be the same pair. + +Actually we'll make two of these pairs, one for the CAR of our argument pair +and one for the CDR: + +(define car-pair (cons '() '())) +(set-car! car-pair car-pair) +(set-cdr! car-pair car-pair) + +(define cdr-pair (cons '() '())) +(set-car! cdr-pair cdr-pair) +(set-cdr! cdr-pair cdr-pair) + +(define magic-argument (cons car-pair cdr-pair)) + +(define (rightmost-part fn) + (if (eq? (fn magic-argument) car-pair) + 'car + 'cdr)) + +It's crucial that we're using EQ? rather than EQUAL? here, since car-pair +and cdr-pair are infinite (circular) lists. + +Okay, we know the rightmost component. How do we get all but the rightmost +component? (Given that, we can recursively find the rightmost part of that, +etc.) Our third clever idea is a more-magic argument that will give us +magic-argument whether we take its car or its cdr: + +(define more-magic-arg (cons magic-argument magic-argument)) + +(define (next-to-rightmost-part fn) + (if (eq? (fn more-magic-arg) car-pair) + 'car + 'cdr)) + +We're going to end up constructing a ladder of pairs whose car and cdr are +both the next pair down the ladder. We also need a base case; if we apply +fn to magic-argument and get magic-argument itself, rather than car-pair +or cdr-pair, we've run out of composed CAR/CDR functions. + +Here's how it all fits together: + +(define (cxr-name fn) + (word 'c (cxr-name-help fn magic-argument) 'r)) + +(define (cxr-name-help fn arg) + (let ((result (fn arg))) + (cond ((eq? result car-pair) + (word (cxr-name-help fn (cons arg arg)) 'a)) + ((eq? result cdr-pair) + (word (cxr-name-help fn (cons arg arg)) 'd)) + (else "")))) ; empty word if result is magic-argument diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week12 b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week12 new file mode 100644 index 0000000..7b8c5a3 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week12 @@ -0,0 +1,1008 @@ +CS 61A Week 12 solutions + +LAB EXERCISES +============= + +3. Why doesn't make-procedure call eval? + +Because none of the arguments to lambda should be evaluated. +In particular, the expressions that make up the body of the procedure are +not evaluated until the procedure is *invoked*! + + +4.1, left-to-right + +(define (list-of-values exps env) ;; left to right + (if (no-operands? exps) + '() + (let ((left (eval (first-operand exps) env))) + (cons left (list-of-values (rest-operands exps) env))))) + +(define (list-of-values exps env) ;; right + (if (no-operands? exps) + '() + (let ((right (list-of-values (rest-operands exps) env))) + (cons (eval (first-operand exps) env) right)))) + + +4.2, Louis reordering + +(a) The trouble is that APPLICATION? cheats. The book has + +(define (application? exp) (pair? exp)) + +It really should be something like + +(define (application? exp) + (and (pair? exp) + (not (member (car exp) '(quote set! define if lambda begin cond))))) + +They get away with the shorter version precisely because EVAL doesn't +call APPLICATION? until after it's checked for all the possible special +forms. Louis (quite reasonably, I think) wants to rely on APPLICATION? +behaving correctly no matter when it's called. + +(b) All we are changing is the syntax of an application, so we +change the procedures that define the "application" abstract data type. +These are on page 372 of the text. The new versions are: + +(define (application? exp) + (tagged-list? exp 'call)) + +(define (operator exp) (cadr exp)) + +(define (operands exp) (cddr exp)) + + +4.4 AND and OR special forms + +The book suggests two solutions: make them primitive special forms +or make them derived expressions. We'll do both. + +As primitive special forms: + +Change the COND clause in EVAL by adding + + (cond ... + ((and? exp) (eval-and exp env)) + ((or? exp) (eval-or exp env)) + ...) + +(define (eval-and exp env) + (define (iter tests) + (cond ((null? tests) #t) + ((null? (cdr tests)) (eval (car tests) env)) + ((true? (eval (car tests) env)) (iter (cdr tests))) + (else #f))) + (iter (cdr exp))) + +(define (eval-or exp env) + (define (iter tests) + (if (null? tests) + #f + (let ((result (eval (car tests) env))) + (if (true? result) + result + (iter (cdr tests)))))) + (iter (cdr exp))) + +Now for the derived expression technique. Modify the COND clause +in EVAL this way instead: + + (cond ... + ((and? exp) (eval (and->if (cdr exp)) env)) + ((or? exp) (eval (or->if (cdr exp)) env)) + ...) + +(define (and->if exps) + (cond ((null? exps) #t) + ((null? (cdr exps)) (car exps)) + (else (make-if (car exps) + (and->if (cdr exps)) + #f)))) + +(define (or->if exps) + (if (null? exps) + #f + (make-if (car exps) + (car exps) + (or->if (cdr exps))))) + +This version is elegant but has the disadvantage that you end up +computing the first true value twice. + + +4.5 Cond => notation + +(define (expand-clauses clauses) + (if (null? clauses) + 'false + (let ((first (car clauses)) + (rest (cdr clauses))) + (if (cond-else-clause? first) + (if (null? rest) + (sequence->exp (cond-actions first)) + (error "...")) + (IF (COND-ARROW-CLAUSE? FIRST) + (LIST (MAKE-LAMBDA '(COND-FOO) + (MAKE-IF 'COND-FOO + (LIST (COND-ARROW-DOER FIRST) + 'COND-FOO) + (EXPAND-CLAUSES REST))) + (COND-PREDICATE FIRST)) + (make-if (cond-predicate first) + (sequence->exp (cond-actions first)) + (expand-clauses rest))))))) + +(define (cond-arrow-clause? clause) + (and (pair? clause) + (= (length clause) 3) + (eq? (cadr clause) '=>))) + +(define (cond-arrow-doer clause) + (caddr clause)) + +This may be a little confusing. What it does is to turn a clause like + + (test => recipient) + +into + + ((lambda (cond-foo) + (if cond-foo + (recipient cond-foo) + <expanded-rest-of-clauses>)) + test) + +Using the name cond-foo here is a kludge, because what if the user +has used the same name for some other purpose within the clause? +The right thing would be to generate an otherwise-untypable symbol +each time. But this is complicated enough already. + +By the way, this is really trying to do + + (let ((cond-foo test)) + (if ...)) + +but we don't yet have LET in the metacircular Scheme. + +It might be easier to do this by abandoning the whole idea of +cond->if and just implementing cond directly. + + +5b. In Logo there are no internal definitions; all procedures are global. +So we need a situation with two procedures, one of which calls the other: + +to outer :var +inner +end + +to inner +print :var +end + +? outer 23 +23 + +To see that this result is different from what would happen with lexical +scope, try the same example in Scheme: + +(define (outer var) + (inner)) + +(define (inner) + (print var)) + +> (outer 23) +Error -- unbound variable: var + +(Or you could define a global variable var whose value is something other +than 23, and then (outer 23) would print that other value. + + +5c. + +Logo " is like Scheme ' -- it's the quoting symbol. But in Logo it is used +only with words, not with lists, and there is no QUOTE special form which the +quotation character abbreviates. + +Logo [ ] are like '( ) in Scheme -- the brackets both delimit and quote a +list. But within a list, brackets are used to delimit sublists, and don't +imply an extra level of quotation, so Logo [a [b c] d] means '(a (b c) d), +not '(a '(b c) d). So, how do you get the effect of Scheme's ( ) without +quotation? In Scheme that means to call a procedure; in Logo you don't +need any punctuation to call a procedure! You just give the procedure name +and its arguments. But in Logo you *can* use parentheses around a procedure +call just as you would in Scheme. + +Logo : means that you want the value of the variable whose name follows the +colon. In Scheme the name by itself means this -- if you want the value of +variable X, you just say X. The reason this doesn't work in Logo is that +in Logo procedures aren't just another data type, and a procedure name isn't +just the name of a variable whose value happens to be a procedure. (In other +words, Logo procedures are not first-class.) In Logo there can be a procedure +and a variable with the same name, so FOO means the procedure and :FOO means +the variable. + + +HOMEWORK +======== + +4.3 data-directed eval + +The table itself could be done in several ways; perhaps the easiest +is to use the built-in table from chapter 2. So we say: + +(put 'quote 'eval text-of-quotation) +(put 'define 'eval eval-definition) +(put 'set! 'eval eval-assignment) + +Where the original eval does something other than (foo exp env) we +have to write an interface procedure. For example: + +(define (eval-lambda exp env) + (make-procedure (lambda-parameters exp) (lambda-body exp) env)) + +(put 'lambda 'eval eval-lambda) + + +(define (eval exp env) + (cond ((self-evaluating? exp) exp) + ((variable? exp) (lookup-variable-value exp env)) + (else (let ((form (get (operator exp) 'eval))) + (if form ;; IT'S A SPECIAL FORM + (form exp env) ;; SO form IS THE PROCEDURE TO CALL + (apply (eval (operator exp) env) + (list-of-values (operands exp) env) )))))) + +The first two COND clauses deal with atomic expressions: numbers (which +are self-evaluating) and symbols (which represent variables). If the +expression is neither of those, then it's a list, and we look at its +CAR. We look that up in the table; if we find it, the expression is a +special form, and we invoke the particular procedure that knows about +that special form. Otherwise, it's a regular procedure. +We're neglecting various kinds of errors that might occur with mal-formed +input. + +We also have to rewrite text-of-quotation so that it accepts an extra +input, the environment, even though it doesn't need it: + +(define (text-of-quotation exp env) + (cadr exp)) + +And we have to write a new "front end" to cond->if: + +(define (eval-cond exp env) + (eval (cond->if exp) env)) + +and put that in the table. + +It would also be possible to include the atomic expressions in the +general data-directed mechanism by assigning them implicit types just as +we assigned Scheme numbers an implicit type in exercise 2.78, page 193: + +(define (expression-type exp) + (cond ((self-evaluating? exp) '(() SELF-EVALUATING)) + ((symbol? exp) '(() SYMBOL)) + ((pair? exp) (car exp)) + (else (error "Unknown expression type" exp)))) + +(define (eval exp env) + (let ((handler (get (expression-type exp) 'eval))) + (if handler + (handler exp env) + (apply (eval (operator exp) env) + (list-of-values (operands exp) env))))) + +(put '(() self-evaluating) 'eval (lambda (exp env) exp)) +(put '(() symbol) 'eval lookup-variable-value) + +The reason for using (() SYMBOL) instead of just SYMBOL as the type tag +is that otherwise we'd get in trouble if an expression tried to call a +procedure named SYMBOL. These type tags aren't valid Scheme expressions, +so they shouldn't get us in trouble. + + +4.6 Implementing LET + +;; In eval's big cond we put + + ((let? exp) (eval (let->combination exp) env)) + +;; Now for the guts of the problem: + +(define (let->combination exp) + (cons (make-lambda (let-formals exp) + (let-body exp)) + (let-actuals exp))) + +;; And now for the data abstraction stuff: + +(define (let? exp) + (tagged-list? exp 'let)) + +(define (let-formals exp) + (map car (cadr exp))) + +(define (let-actuals exp) + (map cadr (cadr exp))) + +(define (let-body exp) + (cddr exp)) + + +Please note that this problem becomes MUCH easier if you ruthlessly separate +the semantics (let->combination) from the mickey mouse work of extracting +the syntactic components. I actually wrote this in the order in which it +appears here; in essence I solved the problem completely before I thought at +all about syntactic issues. + + +4.7 Implementing Let* + +(define (let*->nested-lets exp) + (if (null? (let-bindings exp)) + (make-let '() (let-body exp)) + (make-let (list (car (let-bindings exp))) + (list (make-let* (cdr (let-bindings exp)) + (let-body exp)))))) + +(define (let-bindings exp) + (cadr exp)) + +(define (make-let bindings body) + (cons 'let (cons bindings body))) + +(define (make-let* bindings body) + (cons 'let* (cons bindings body))) + +I'm cheating slightly by using LET-BODY for a LET* expression instead +of inventing a whole new abstract data type. In principle someone +might want to change Scheme so that the syntax of LET* looks different +from the syntax of LET. + + +4.10 new syntax + +Okay, let's make the syntax of IF look like it does in those other bad +languages. (After all, any change we make to Scheme's syntax *has* to make +it worse!) The new syntax will be (if ... then ... else ...). + +(define (if? exp) + (and (tagged-list? exp 'if) + (eq? (caddr exp) 'then) + (or (= (length exp) 4) + (eq? (list-ref exp 4) 'else)))) + +(define (if-predicate exp) (cadr exp)) + +(define (if-consequent exp) (cadddr exp)) + +(define (if-alternative exp) (list-ref exp 5)) + +Of course you can do lots of other changes too, so if you're copying +last semester's answers next semester, the reader will be suspicious +if you come up with this choice! :-) + + +4.11 changed frame representation + +(define (make-frame variables values) + (attach-tag 'frame (map cons variables values))) + +(define (frame-variables frame) + (map car (contents frame))) + +(define (frame-values frame) + (map cdr (contents frame))) + +(define (add-binding-to-frame! var val frame) + (set-cdr! frame (cons (cons var val) (contents frame)))) + +As explained in footnote 14 on page 378, the procedures lookup-variable-value, +set-variable-value!, and define-variable! aren't just above-the-line users of +the frame ADT, because the latter two use SET-CAR! to modify frames. +Lookup-variable-value could actually work exactly as written, but the others +have to be changed, and that one should also be changed, to use ASSOC in +their SCAN internal procedures. Basically these will look like the table +procedures from chapter 3: + +(define (lookup-variable-value var env) + (define (env-loop env) + (DEFINE (SCAN ALIST) + (LET ((RESULT (ASSOC VAR ALIST))) + (IF RESULT + (CDR RESULT) + (ENV-LOOP (ENCLOSING-ENVIRONMENT ENV))))) + (if (eq? env the-empty-environment) + (error "Unbound variable" var) + (let ((frame (first-frame env))) + (SCAN (CONTENTS FRAME))))) + (env-loop env)) + +(define (set-variable-value! var val env) + (define (env-loop env) + (DEFINE (SCAN ALIST) + (LET ((RESULT (ASSOC VAR ALIST))) + (IF RESULT + (SET-CDR! RESULT VAL) + (ENV-LOOP (ENCLOSING-ENVIRONMENT ENV))))) + (if (eq? env the-empty-environment) + (error "Unbound variable -- SET!" var) + (let ((frame (first-frame env))) + (SCAN (CONTENTS FRAME))))) + (env-loop env)) + +(define (define-variable! var val env) + (let ((frame (first-frame env))) + (DEFINE (SCAN ALIST) + (LET ((RESULT (ASSOC VAR ALIST))) + (IF RESULT + (SET-CDR! RESULT VAL) + (ADD-BINDING-TO-FRAME! VAR VAL FRAME)))) + (SCAN (CONTENTS FRAME)))) + +If I hadn't attached a tag to the frames, this would be harder. +I wouldn't be able to have an add-binding-to-frame! procedure +because there wouldn't be anything in an empty frame to mutate. +Instead, define-variable! would have to get more complicated. + + +4.13 make-unbound + +First, about the design issues: I see three possibilities. You can +require that the symbol be bound in the current environment and remove +that binding only; you can remove the nearest single binding; or you can +remove all bindings of that symbol. Perhaps the best solution in any case +where it's not obvious what the right semantics is would be to provide +all three versions: unbind-this-frame, unbind-nearest, and unbind-all. +That way the user can decide for herself what best suits the application +at hand. Failing that, I vote for the second choice: removing the nearest +binding. Here's why. First of all, the third version can be written in +terms of the second: + +(define (unbind-all sym) + (cond ((bound? sym) + (unbind-nearest sym) + (unbind-all sym)) + (else '()))) + +(This assumes we have a predicate bound? that returns true if there is +an accesible binding for the symbol. If we provide any form of unbinding +we should probably provide that too.) But the second can't be written in +terms of the third. So if we're only having one we should have the more +flexible one. I rule out the first (current frame only) because I can +easily imagine wanting to write a procedure like + +(define (cleanup) + (make-unbound 'a) + (make-unbound 'b) + (make-unbound 'c)) + +that removes global variables at the end of a computation, but this +wouldn't be possible under the first option. (Why not?) + +I have also implicitly decided another design question: should this be +a special form that requires an unevaluated symbol, like set!, or should +it be an ordinary procedure whose actual parameter is evaluated? In +order to make things like unbind-all (above) work, it should be an ordinary +procedure. (What I want to get unbound is the actual argument to +unbind-all, not the symbol "sym" itself.) Then again, I think set! should +be an ordinary procedure, too, so perhaps you're asking the wrong person. + +Trouble is, we can't REALLY make make-unbound an ordinary procedure +because it has to have access to the environment. If Scheme were +dynamically scoped, any procedure in the evaluator could just make a +free reference to "env" to get the current user environment, but as it +is we have to have eval treat make-unbound specially. So we'll make +it a special form but still have it evaluate everything. + +(define (eval-make-unbound exp env) + (define (unbind-in-frame sym frame) + (define (remove-not-first-binding vars vals) + (if (eq? sym (cadr vars)) + (begin (set-cdr! vars (cddr vars)) + (set-cdr! vals (cddr vals))) + (remove-not-first-binding (cdr vars) (cdr vals)))) + (if (eq? sym (car (frame-variables frame))) + (begin (set-car! frame (cdr (frame-variables frame))) + (set-cdr! frame (cdr (frame-values frame)))) + (remove-not-first-binding (frame-variables frame) + (frame-values frame)))) + (define (env-iter sym env) + (cond ((eq? env the-empty-environment) 'okay) + ((memq sym (frame-variables (first-frame env))) + (unbind-in-frame sym (first-frame env))) + (else (env-iter sym (enclosing-environment env))))) + (env-iter (eval (cadr exp) env) env)) + +This is rather messier than one might wish, because if the binding in +question is the first one in a frame, we have to remove it differently from +if it's not the first in a frame. In the first case we mutate the header +pair of the frame; in the second case we splice elements out of two lists. +Had this evaluator been written with unbinding in mind, they might have +picked a different data structure. Env-iter looks for the first frame in +which the symbol is bound, then unbinds it in that frame. Unbind-in-frame +first checks the first binding specially, then uses remove-not-first-binding +to check the other bindings. + +Strictly speaking, I should have made mutators for the frame +abstraction. The obvious choice would be set-frame-variables! and +set-frame-values!, but actually that only makes sense if we know that +the frame is represented as two parallel lists. If the frame is +represented as an a-list, as in exercise 4.11, then a better choice +would be set-frame-bindings!. So the really right thing, to keep +the abstraction barrier solid, is to have a mutator frame-remove-binding! +that would be like the unbind-in-frame part of the code above. It would +be different for different representations, but would have the same +effect above the abstraction barrier. + +Finally, we have to modify eval, adding + + ((make-unbound? exp) (eval-make-unbound exp env)) + +to the big cond. + +(define (make-unbound? exp) + (tagged-list? exp 'make-unbound)) + + + +4.14 why doesn't map work? + +This question is about level confusion. Let's talk about meta-Scheme, +the one implemented by the metacircular evaluator, and under-Scheme, the +regular Scheme in which the MCE is written. + +Eva defines MAP in meta-Scheme. In particular, when MAP tries to invoke +a meta-Scheme procedure for each element of the list, it's doing a +meta-Scheme invocation. + +Louis uses the MAP that's defined in under-Scheme. When he calls MAP, +he is giving it a meta-Scheme procedure as its first argument, but it's +expecting an under-Scheme procedure. From the point of view of under-Scheme, +a meta-Scheme procedure isn't a procedure at all -- it's a list whose car +is the word PROCEDURE. + + +4.15 the halting problem + +This is the most famous problem in automata theory, the most elegant proof that +some things can't be done no matter how sophisticated our computers become. +The proof was first given using the "Turing machine," an abstract machine +that's used only for proving theorems. But the same idea works in any +formal system that's capable of representing a procedure as data; the key +element of the proof is the fact that the hypothetical HALTS? is a +higher-order function. + +Suppose that (HALTS? TRY TRY) returns #T. Then when we call (TRY TRY) +it says, after argument substitution, + + (if (halts? try try) + (run-forever) + 'halted) + +But this will run forever, and so (TRY TRY) runs forever, and so +(HALTS? TRY TRY) should have returned #F. + +Similarly, suppose that (HALTS? TRY TRY) returns #F. Then (TRY TRY) +turns into the same IF expression shown above, but this time the +value of that expression is the word HALTED -- that is, it halts. +So (HALTS? TRY TRY) should have returned #T. + + +4.22 LET in analyzing evaluator + +This is easy, given the hint about 4.6. We don't have to change the +procedure LET->COMBINATION we wrote for that exercise; since it deals +entirely with the expression, and not with the values of variables, +all of its work can be done in the analysis phase. All we do is +change this COND clause in EVAL: + + ((let? exp) (eval (let->combination exp) env)) + +to this COND clause in ANALYZE: + + ((let? exp) (analyze (let->combination exp))) + + +4.23 Efficiency of analyze-sequence + +For a sequence with just one expression, the book's version does the +following analysis: First, the body of analyze-sequence is the LET. +Suppose that the result of analyzing the one expression is PROC. +Then the variable PROCS will have as its value a list whose only +element is PROC. That's not null, so (still in the analysis part) +we call (LOOP PROC '()). In LOOP, since (in this case) REST-PROCS +is null, LOOP just returns PROC. So if the analysis of EXP gives +PROC, then the analysis of (BEGIN EXP) also gives PROC. + +In the same one-expression case, Alyssa's version returns + (lambda (env) (execute-sequence (list PROC) env)) +So every time this execution procedure is called, execute-sequence +will check that (cdr procs) is empty, which it is, and then +calls PROC with the environment as its argument. This test of +(null? (cdr procs)) is done for every execution, whereas in the +book's version it was done just once. + +How about the two-expression case. Suppose that the analysis of +EXP1 gives PROC1, and the anaylsis of EXP2 gives PROC2. The book's +version will call, in effect, (loop PROC1 (list PROC2)). This +in turn calls (sequentially PROC1 PROC2), which returns + (lambda (env) (PROC1 env) (PROC2 env)) +as the execution procedure. (There is a recursive call to LOOP, +but it doesn't change the result, because this time the second +argument is null.) + +Alyssa's version makes the execution procedure be + (lambda (env) (execute-sequence (list PROC1 PROC2) env))) +which in effect means + (lambda (env) + (cond ((null? (list PROC2)) ...) + (else (PROC1 env) + (cond ((null? '()) (PROC2 env)) ...)))) +Each time this is executed, we do two unnecessary checks for +the nullness of a list -- unnecessary because we already knew +while doing the analysis how many expressions are in the sequence. + + +4.24 How fast? + +Hint: You'll get the most dramatic results when an expression +is evaluated over and over, i.e., with a recursive procedure. + + + +2. Type checking + +When we define a procedure, we don't even look at the parameter +list; it's just stored as part of the procedure. That doesn't +need to be changed. When do we have to check the type? We do it +when we're invoking a procedure, as part of the process of +binding names to values. This happens in extend-environment +and make-frame. The only change to extend-environment is that it +has to supply the environment that we're extending to make-frame, +because make-frame will have to look up the type predicates: + +(define (extend-environment vars vals base-env) + (if (= (length vars) (length vals)) + (cons (make-frame vars vals BASE-ENV) base-env) + (if (< (length vars) (length vals)) + (error "Too many arguments supplied" vars vals) + (error "Too few arguments supplied" vars vals)))) + +Make-frame, which was trivial before this change, now has some +real work to do: + +(define (make-frame variables values BASE-ENV) + (DEFINE (TYPE-CHECK VAR VAL) + (IF (AND (PAIR? VAR) + (NOT (APPLY (EVAL (CAR VAR) BASE-ENV) + (LIST VAL)))) + (ERROR "WRONG ARGUMENT TYPE" VAL))) + (DEFINE (SCAN VARS VALS) + (COND ((NULL? VARS) #T) + (ELSE (TYPE-CHECK (CAR VARS) (CAR VALS)) + (SCAN (CDR VARS) (CDR VALS))))) + (SCAN VARIABLES VALUES) + (cons (JUST-NAMES variables) values)) + +(DEFINE (JUST-NAMES VARS) + (COND ((NULL? VARS) '()) + ((PAIR? (CAR VARS)) + (CONS (CADAR VARS) (JUST-NAMES (CDR VARS)))) + (ELSE (CONS (CAR VARS) (JUST-NAMES (CDR VARS)))))) + +Another approach would be to try to modify the procedure as it's being +created (therefore, in make-procedure, called from eval) so that the type +checks become part of the procedure's body. This can be done, but it's +quite tricky to get it right. For example, in what environment should the +names of the type predicates be looked up? + +It's a real misunderstanding of the problem to write a solution in which +specific type predicates such as INTEGER? are built into the evaluator. +If there's a type checking system, it should work for user-defined types +as well as for primitive types. For example, I should be able to say +that an argument must be a prime number, or must be a three-letter word. + + + +Extra for Experts +================= + +4.16 + +(a) + +(define (lookup-variable-value var env) + (define (env-loop env) + (define (scan vars vals) + (cond ((null? vars) + (env-loop (enclosing-environment env))) + ((eq? var (car vars)) + (LET ((RESULT (car vals))) ;; *** + (IF (EQ? RESULT '*UNASSIGNED*) ;; *** + (ERROR "UNBOUND VARIABLE" (CAR VARS)) ;; *** + RESULT))) ;; *** + (else (scan (cdr vars) (cdr vals))))) + (if (eq? env the-empty-environment) + (error "Unbound variable" var) + (let ((frame (first-frame env))) + (scan (frame-variables frame) + (frame-values frame))))) + (env-loop env)) + + +(b) + +(define (scan-out-defines body) + (cond ((null? body) '()) + ((definition? (car body)) + (list ; body is a list of expressions, we make one-element list + (cons 'let + (cons (make-let-variables (definitions body)) + (append (make-setbangs (definitions body)) + (non-definitions body)))))) + (else body))) + +(define (definitions body) + (cond ((null? body) '()) + ((definition? (car body)) + (cons (car body) (definitions (cdr body)))) + (else '()))) + +(define (non-definitions body) + (cond ((null? body) '()) + ((definition? (car body)) + (non-definitions (cdr body))) + (else body))) + +(define (make-let-variables definitions) + (map (lambda (def) + (list (definition-variable def) '(quote *unassigned*))) + definitions)) + +(define (make-setbangs definitions) + (map (lambda (def) + (list 'set! (definition-variable def) (definition-value def))) + definitions)) + + +(c) It should be in make-procedure, because then the scanning is done only +once, when the procedure is created, rather than every time the procedure +is called. (On the other hand, if Scheme printed procedures in a way that +showed the body, the user might wonder why the body isn't what s/he wrote.) + +(define (make-procedure parameters body env) + (list 'procedure parameters (scan-out-defines body) env)) + + +4.17 + +The extra frame is created by the LET we introduced into the procedure body. +The frame itself would matter only if some expressions were evaluated in the +outer frame rather than the inner one. But there are no such expressions, +except for the (QUOTE *UNASSIGNED*) ones we put in the LET, and those don't +depend on the environment for their values. + +We could do it without the extra frame by scanning + +(lambda (args...) + (define u e1) + (define v e2) + ...) + +into + +(lambda (args) + (define u '*unassigned*) + (define v '*unassigned*) + (set! u e1) + (set! v e2) + ...) + +and continuing to use the sequential version of internal DEFINE already in the +metacircular evaluator. (This may seem to have no benefit at all, but it does, +because the local variables U and V are bound before the expressions E1 and E2 +are evaluated, so we can be sure they won't refer to global variables.) + + +4.18 + +You can't actually experiment with this question unless you define DELAY +and CONS-STREAM as special forms in the metacircular evaluator. + +The SOLVE procedure would work using the scan-out approach of 4.16, but not +using the version proposed in this exercise. The body of SOLVE would be + + (let ((y '*unassigned*) (dy '*unassigned*)) + (let ((gensym1 (integral (delay dy) y0 dt)) + (GENSYM2 (STREAM-MAP F Y))) + (set! y gensym1) + (set! dy gensym2) + y) + +In the line in capital letters, stream-map is an ordinary procedure, so its +argument expressions are evaluated before stream-map is called. One of the +arguments is Y, whose value at this point is *unassigned*, so an error will +result. This is consistent with the definition of LETREC in the Scheme +standard. (Internal DEFINE is defined by the standard to be equivalent to +LETREC. See page 16 of the standard, in the course reader, section 5.5.2. +Then see pages 11-12 for the discussion of LETREC, especially the last +paragraph of that section.) + + +4.19 + +This is answered in the footnote: the authors support Alyssa. + +One possible way to get what Eva wants is to use the approach of exercise +4.16, but instead of giving an error if one of the SET! expressions fails, +move it to the end of the line, so you keep trying until every variable has a +value or until no further progress can be made. So in this example it'd be + + (let ((b '*unassigned*) (a '*unassigned*)) + (set!-ignoring-errors b (+ a x)) + (set!-ignoring-errors a 5) + (if (unassigned? b) (set! b (+ a x))) + (if (unassigned? a) (set! a 5)) + (+ a b)) + +using pseudo-special-forms SET!-IGNORING-ERRORS and UNASSIGNED? that aren't +defined but whose meanings should be obvious. You'd have to repeat the IF +expressions as many times as you have variables, to be sure that any +dependency order would work. + +Even so, an expression such as + + (define (f x) + (define a (+ b 3)) + (define b (+ a 4)) + (+ a b)) + +won't work no matter how many times you try the assignments. + + +4.20 + +(a) + +(define (letrec? exp) + (tagged-list? exp 'letrec)) + +(define (letrec->let exp) + (cons 'let + (cons (map (lambda (var) (list var '(quote *unassigned*))) + (let-formals exp)) + (append (map (lambda (var val) (list 'set! var val)) + (let-formals exp) + (let-actuals exp)) + (let-body exp))))) + +Then add a cond clause to EVAL: + + ((letrec? exp) (eval (letrec->let exp) env)) + + +(b) In the correct version, after transforming the LETREC as on page 389, +we have + +(define (f x) + (let ((even? '*unassigned*) (odd? '*unassigned*)) + (set! even? (lambda (n) (if (= n 0) true (odd? (- n 1))))) + (set! odd? (lambda (n) (if (= n 0) false (even? (- n 1))))) + <rest of body of F>)) + +Evaluating that gives + + global env: F -> procedure P1 + + procedure P1: params (x), body (let ...), global env + +When evaluating (F 5), we add + + E1: X -> 5, extends G + +The LET expands to a LAMBDA and an invocation: + + procedure P2: params (even? odd?), body (set! ...)..., env E1 + + E2: EVEN? -> *unassigned*, ODD? -> *unassigned*, extends E1 + +With E2 as the current environment we evaluate the two SET! expressions, +which create procedures (because of the LAMBDA expressions inside them) and +change the bindings in E2: + + procedure P3: params (n), body (if (= n 0) true (odd? ...)), env E2 + procedure P4: params (n), body (if (= n 0) false (even? ...)), env E2 + + E2: EVEN? -> procedure P3, ODD? -> procedure P4, extends E1 + +Note that P3 and P4 are created in E2, so they have access to the bindings +for EVEN? and ODD?. + +Then we evaluate the remaining expression in the body of F, which can use +EVEN? and ODD? successfully. + +By contrast, Louis wants us to evaluate + +(define (f x) + (let ((even? + (lambda (n) + (if (= n 0) + true + (odd? (- n 1))))) + (odd? + (lambda (n) + (if (= n 0) + false + (even? (- n 1)))))) + <rest of body of F>)) + +This time, when evaluating (F 5), we still add + + E1: X -> 5, extends G + +The LET expands to a LAMBDA and an invocation with procedures as arguments: + + ((lambda (even? odd?) <rest of body>) + (lambda (n) (if (= n 0) true (odd? (- n 1)))) + (lambda (n) (if (= n 0) false (even? (- n 1))))) + +The three LAMBDA expressions give us + + procedure P2: params (even? odd?), body <rest of body>, env E1 + procedure P3: params (n), body (if (= n 0) true (odd? ...)), env E1 + procedure P4: params (n), body (if (= n 0) false (even? ...)), env E1 + +We can then invoke P2 with P3 and P4 as its arguments: + + E2: EVEN? -> procedure P3, ODD? -> procedure P4, extends E1 + +In this environment we evaluate <rest of body>. Suppose it's a simple +expression: (EVEN? X). First we evaluate the subexpressions. In E2 we +find the binding EVEN? -> P3. There's no binding for X in frame E2, but +it extends E1, where we find X -> 5. Now we invoke P3 by making a new +environment: + + E3: N -> 5, extends E1 + +Note that E3 extends E1, not E2, because E1 is where P3 was created. + +With E3 as the current environment we evaluate the body of P3, which is + + (if (= n 0) true (odd? (- n 1))) + +We easily evaluate (= N 0) and get the answer #F. We then try to evaluate + + (odd? (- n 1)) + +But there is no binding for ODD? in E3, including the frames it extends. +That's why LET instead of LETREC isn't sufficient. + + +4.21 + +We've actually seen this idea before, in the Extra for Experts in week 2. + +(a) FIB without DEFINE/LETREC + +((lambda (n) + ((lambda (fib) (fib fib n)) + (lambda (fb k) + (if (< k 2) + k + (+ (fb fb (- k 1)) + (fb fb (- k 2))))))) + 10) + + +(b) EVEN?/ODD? ditto + +(define (f x) + ((lambda (even? odd?) + (even? even? odd? x)) + (lambda (ev? od? n) ; This is EVEN? + (if (= n 0) true (OD? EV? OD? (- N 1)))) + (lambda (ev? od? n) ; This is ODD? + (if (= n 0) false (EV? EV? OD? (- N 1)))))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week14 b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week14 new file mode 100644 index 0000000..53486bd --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week14 @@ -0,0 +1,1404 @@ +CS61A Week 11 solutions + +LAB: +---- + +4.27 Lazy vs. mutation + +The first time you type COUNT you get 1; the second time you get 2. +Why? When you say + (define w (id (id 10))) +the DEFINE special form handler eval-definition EVALs its second +argument (id (id 10)). Given an application, EVAL calls APPLY +to invoke ID for the outer invocation, but the inner invocation +is providing an argument to a compound procedure, so it's delayed. +That's why COUNT is 1 -- the outer call to ID has actually happened, +but not the inner one. + +The value of W is therefore a promise to compute (id 10), since +ID returns its argument. When you ask the evaluator to print W, +that promise is fulfilled, and so COUNT becomes 2. + + +4.29 Memoizing or not + +You'd expect a program that uses the same argument repeatedly to +be most strongly affected. For example, I wrote + +(define (n-copies n stuff) + (if (= n 0) + '() + (cons stuff (n-copies (- n 1) stuff)))) + +Then if you use n-copies with something requiring a fair amount +of computation, such as + +(n-copies 6 (factorial 7)) + +you can see a dramatic difference. + +About their square/id example, remember to (set! count 0) before +each experiment. Then the memoizing version leaves count at 1, +whereas the non-memoizing version sets count to 2. + + + +4.35 an-integer-between + +(define (an-integer-between low high) + (if (> low high) + (amb) + (amb low (an-integer-between (+ low 1) high)))) + + +4.38 adjacent floors + +Remove the line (require (not (= (abs (- smith fletcher)) 1))) + + +[The continuation part of the lab was just try-this.] + + + +HOMEWORK: +--------- + + +4.25 UNLESS in normal vs. applicative order + +In ordinary (applicative order) Scheme, this version of FACTORIAL +will be an infinite loop, because the argument subexpression +(* n (factorial (- n 1))) is evaluated before UNLESS is called, +whether or not n is 1. + +In normal order Scheme it'll work fine, because the argument +subexpressions aren't evaluated until they're needed. What +will actually happen is that each use of the special form IF +within UNLESS will force the computation of (= n 1), but +no multiplications will happen until the evaluator tries to +print the result. In effect, (factorial 5) returns the thunk + (lambda () (* 5 (* 4 (* 3 (* 2 (* 1 1)))))) +and that gets evaluated just in time to print the answer. + + +4.26 Normal order vs. special forms + +For Ben's side of the argument we must implement UNLESS as a +derived expression: + +(define (unless->if exp) + (make-if (unless-predicate exp) + (unless-consequent exp) + (unless-alternative exp))) + +(define unless-predicate cadr) +(define unless-alternative caddr) +(define unless-consequent cadddr) + +Notice that we reversed the order of the last two subexpressions in +the call to make-if. + +Then we just add a clause + ((unless? exp) (eval (unless->if exp) env)) +to the ordinary metacircular evaluator, or + ((unless? exp) (analyze (unless->if exp))) +to the analyzing evaluator. + +For Alyssa's side of the argument, we need a case in which it's useful to +have a Scheme special form available as an ordinary procedure. The only +thing we can do with ordinary procedures but not with special forms is use +them as arguments to higher-order procedures. An example using UNLESS will +be a little strained, so first we'll look at a more common situation +involving a different special form, namely AND. We'd like to be able to say + +(define (all-true? tf-list) + (accumulate and tf-list)) + +Now, here's the strained example using UNLESS: Suppose we have a list of +true-false values and we'd like to add up the number of true ones. Here's a +somewhat strange way to do it: + +(define zero-list (cons 0 '())) +(set-cdr! zero-list zero-list) + +(define one-list (cons 1 '())) +(set-cdr! one-list one-list) + +(define (howmany-true tf-list) + (apply + (map unless tf-list zero-list one-list))) + +Zero-list is an infinite list of zeros; one-list is an infinite list +of ones. We make use of the fact that MAP's end test is that its +first argument is empty, so MAP will return a list the same size as +the argument tf-list. For example, if tf-list is + (#t #t #f #t) +then map will return + (1 1 0 1) +created, in effect, this way: + (list (unless #t 0 1) + (unless #t 0 1) + (unless #f 0 1) + (unless #t 0 1)) +And so + will return 3, the number of trues in the list. + + +4.28 Why force the operator of a combination? + +Thunks are made by APPLY, representing arguments to defined procedures. +So we need a case in which the operator of an expression is the returned +argument of a defined procedure. Here's an example: + +(((lambda (a b) a) + -) 2 3) + + +4.30 Side effects vs. lazy evaluation + +(a) Why is Ben right about for-each? + +For-each includes the expression (proc (car items)). As we +discussed in ex. 4.28, the lazy evaluator will force the +operator of that expression, i.e., PROC. The resulting +procedure has two invocations of primitives, NEWLINE and +DISPLAY. Evaluating those invocations will actually call +the procedures, and the argument X to DISPLAY will be +evaluated because DISPLAY is primitive. + +(b) What happens in Cy's example? + +First of all, in ordinary Scheme both (p1 1) and (p2 1) give +the result (1 2). + +With the book's version of eval-sequence, (p1 1) is still (1 2) +but (p2 1) is 1, because the SET! will never happen. The +subprocedure P has a two-expression sequence as its body, and +the first expression will never be evaluated. + +With Cy's version both (p1 1) and (p2 1) are (1 2), as in +ordinary Scheme. + +(c) Why doesn't Cy's version change part (a)? + +The change isn't as dramatic as it may seem. Don't think that +the original eval-sequence calls delay-it! It calls EVAL, and +most of the time EVAL does return a value, not a thunk. In +particular, a procedure call is carried out right away; it's +only the *arguments* to the procedure that are delayed. That's +why Cy had to use a weird example in which a SET! expression +is used as an argument to a procedure in order to get the wrong +result. + +(d) What's the right thing to do? + +The combination of lazy evaluation and mutation in the same language +is so confusing that programmers would be surprised no matter which +choice we made. That's why, in the real world, the languages that +use normal order evaluation are *functional* languages in which +there is no mutation or other side effects. In such a language, +there are no sequences (if there are no side effects, what would +be the point?) and the problem doesn't arise. + +But if we really wanted to have a normal-order Scheme, we'd +probably want to change the semantics of the language as little +as possible -- programs that work in ordinary Scheme should work +in lazy Scheme too. So I think Cy is right. + + +4.32 Lazy trees + +One possibility is to use doubly-lazy lists as an alternative to +interleaving, when dealing with a naturally two-dimensional problem. +For example, to get pairs of integers, we could say + +(define (pairs a b) + (cons (map (lambda (x) (cons (car a) x)) b) + (pairs (cdr a) b))) + +Then we could use this data structure with two-dimensional versions +of the usual higher order procedures. For example: + +(define (2dfilter pred s) + (if (null? s) + '() + (cons (filter pred (car s)) + (2dfilter pred (cdr s))))) + + +4.33 Quoted lazy lists + +Instead of + ((quoted? exp) (text-of-quotation exp)) +we need a more complicated treatment to turn the ordinary lists +of the underlying Scheme into lazy lists. + + ((quoted? exp) (process-quotation (text-of-quotation exp) env)) + +(define (process-quotation quoted env) + (if (pair? quoted) + (lazy-cons (process-quotation (car quoted) env) + (process-quotation (cdr quoted) env) + env) + quoted)) + +(define (lazy-cons x y env) + (make-procedure '(m) (list (list 'm x y)) env)) + +or alternatively + +(define (lazy-cons x y env) + (apply (lookup-variable-value 'cons env) + (list x y))) + +This lazy-cons is the below-the-line equivalent of the above-the-line +CONS on page 409. + + + +4.36 all Pythagorean triples + +Replacing an-integer-between with an-integer-starting-from won't +work because the AMB that provides the value for K will never fail, +and so I and J will always be 1 forever. + +To make this work, we note that K must always be larger than I or J, +so I and J can be restricted to finite ranges if we choose a value +for K first: + +(define (a-pythgorean-triple) + (let ((k (an-integer-starting-from 1))) + (let ((i (an-integer-between 1 (- k 1)))) + (let ((j (an-integer-between i (- k 1)))) + (require (= (+ (* i i) (* j j)) (* k k))) + (list i j k))))) + + +4.42 liars + +(define (liars) + (define (onetrue? x y) + (if x (if y #f #t) y)) + (let ((betty (amb 1 2 3 4 5)) + (ethel (amb 1 2 3 4 5)) + (joan (amb 1 2 3 4 5)) + (kitty (amb 1 2 3 4 5)) + (mary (amb 1 2 3 4 5))) + (require (distinct? (list betty ethel joan kitty mary))) + (require (onetrue? (= kitty 2) (= betty 3))) + (require (onetrue? (= ethel 1) (= joan 2))) + (require (onetrue? (= joan 3) (= ethel 5))) + (require (onetrue? (= kitty 2) (= mary 4))) + (require (onetrue? (= mary 4) (= betty 1))) + (list (list 'betty betty) (list 'ethel ethel) (list 'joan joan) + (list 'kitty kitty) (list 'mary mary)))) + +As in the multiple dwelling puzzle, this program can be made much more +efficient by checking for distinct values as we go along instead of +after all values have been assigned: + +(let ((betty (amb 1 2 3 4 5)) + (ethel (amb 1 2 3 4 5))) + (require (distinct? (list betty ethel))) + (let ((joan (amb 1 2 3 4 5))) + (require (distinct? (list betty ethel joan))) + ... + + +4.45 ambiguous sentence + +(sentence + (simple-noun-phrase (article the) (noun professor)) + (verb-phrase + (verb lectures) + (prep-phrase (prep to) + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase (prep in) + (noun-phrase + (simple-noun-phrase (article the) (noun class)) + (prep-phrase (prep with) + (simple-noun-phrase (article the) + (noun cat))))))))) + +This version means that a cat is a student in the class, and the professor +lectures to another student in the class. + +(sentence + (simple-noun-phrase (article the) (noun professor)) + (verb-phrase + (verb lectures) + (prep-phrase (prep to) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase (prep in) + (simple-noun-phrase (article the) (noun class)))) + (prep-phrase (prep with) + (simple-noun-phrase (article the) + (noun cat))))))) + +This version means that the professor lectures to a student, and that that +student is in the class and has a cat, which may or may not be present. + +(sentence + (simple-noun-phrase (article the) (noun professor)) + (verb-phrase + (verb-phrase + (verb lectures) + (prep-phrase (prep to) + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase (prep in) + (simple-noun-phrase (article the) (noun class)))))) + (prep-phrase (prep with) + (simple-noun-phrase (article the) + (noun cat))))) + +This version means that the professor brings a cat along while lecturing +to the student who is in the class. + +(sentence + (simple-noun-phrase (article the) (noun professor)) + (verb-phrase + (verb-phrase + (verb-phrase + (verb lectures) + (prep-phrase (prep to) + (noun-phrase + (simple-noun-phrase (article the) (noun student))))) + (prep-phrase (prep in) + (simple-noun-phrase (article the) (noun class)))) + (prep-phrase (prep with) + (simple-noun-phrase (article the) + (noun cat))))) + +This version means that the professor does the lecturing in the class, +bringing a cat along, to some student about whom we know nothing. + +(sentence + (simple-noun-phrase (article the) (noun professor)) + (verb-phrase + (verb-phrase + (verb lectures) + (prep-phrase (prep to) + (noun-phrase + (simple-noun-phrase (article the) (noun student))))) + (prep-phrase (prep in) + (noun-phrase + (simple-noun-phrase (article the) (noun class)) + (prep-phrase (prep with) + (simple-noun-phrase (article the) + (noun cat))))))) + +This version means that the professor does the lecturing in a class +that includes a cat as a member, to a student about whom we know nothing. + + +4.47 left-recursive grammar + +As Louis' programs go, this one is pretty successful! It does generate +the two correct parsings for "The professor lectures to the student +with the cat," in the opposite order from what's shown in the book. +But if you say try-again again, instead of reporting that there are +no more values, the parser gets in an infinite loop. + +What happens is this: (parse-word verbs) fails, so parse-verb-phrase +is called recursively. In that recursive call, (parse-word verbs) fails, +so parse-verb-phrase is called recursively. In that recursive call... +and so on. + +Interchanging the order of expressions in the AMB just makes things +worse; this infinite recursion happens the *first* time, so you don't +even see the correct parsings before it loops. + + +4.48 grammar extensions + +For compound sentences, first rename parse-sentence as parse-simple-sentence: + +(define (parse-simple-sentence) + (list 'simple-sentence + (parse-noun-phrase) + (parse-verb-phrase))) + +(define (parse-sentence) + (define (maybe-extend sentence) + (amb sentence + (maybe-extend (list 'sentence + sentence + (parse-word connectors) + (parse-simple-sentence))))) + (maybe-extend (parse-simple-sentence))) + +(define connectors '(connector and or but)) + +For adjectives, we have to provide for the possibility of them +between the article and the noun: + +(define (parse-simple-noun-phrase) + (cons 'simple-noun-phrase + (append (list (parse-word articles)) + (maybe-some adjectives) + (list (parse-word nouns))))) + +(define adjectives '(adjective big tiny silly robust enthusiastic)) + +(define (maybe-some words) + (amb (cons (parse-word words) + (maybe-some words)) + '())) + +Note that unlike most of the parsing procedures, maybe-some doesn't fail if +it can't find what it wants. If it can't find any adjectives it just +returns an empty list. That's why parse-simple-noun-phrase has to use +append, to avoid seeing + + (simple-noun-phrase (article the) () (noun cat)) + +Adverbs are similar except that they go into parse-verb-phrase. + + +4.49 generating sentences + +(define (parse-word word-list) + (define (iter words) + (if (null? words) + (amb) + (amb (car words) (iter (cdr words))))) + (list (car word-list) (iter (cdr word-list)))) + +Here are the first several sentences it creates: +(sentence (noun-phrase (article the) (noun student)) (verb studies)) +(sentence (noun-phrase (article the) (noun student)) (verb lectures)) +(sentence (noun-phrase (article the) (noun student)) (verb eats)) +(sentence (noun-phrase (article the) (noun student)) (verb sleeps)) +(sentence (noun-phrase (article the) (noun professor)) (verb studies)) +(sentence (noun-phrase (article the) (noun professor)) (verb lectures)) +(sentence (noun-phrase (article the) (noun professor)) (verb eats)) +(sentence (noun-phrase (article the) (noun professor)) (verb sleeps)) +(sentence (noun-phrase (article the) (noun cat)) (verb studies)) + + +4.50 random choice + +We must write ANALYZE-RAMB, a variant on the ANALYZE-AMB of p. 434: + +(define (analyze-ramb exp) + (let ((cprocs (map analyze (amb-choices exp)))) + (lambda (env succeed fail) + (define (try-next choices) + (if (null? choices) + (fail) + (let ((random-order (rotate choices (random (length choices))))) + ((car random-order) env + succeed + (lambda () + (try-next (cdr random-order))))))) + (try-next cprocs)))) + +(define (rotate seq num) + (if (= num 0) + seq + (rotate (append (cdr seq) (list (car seq))) + (- num 1))) + +Then we must add a clause to ANALYZE to check for and handle RAMB, +similar to the one for AMB. + + +It's not actually so easy to use RAMB to get good sentences. The problem +is that we really don't want a more complicated choice to be just as likely +as a simple choice, or our sentences will be too long. If we change +every AMB in the parser to RAMB, I get these results: + +[Note: The second one is really long! I suggest reading this in emacs +and using control-meta-F to skip over it.] + +(sentence + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase (prep with) + (noun-phrase + (simple-noun-phrase (article a) (noun cat)) + (prep-phrase (prep for) + (simple-noun-phrase (article a) (noun student)))))) + (verb studies)) + +(sentence + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase (prep with) + (noun-phrase + (simple-noun-phrase (article a) (noun cat)) + (prep-phrase (prep for) + (simple-noun-phrase (article a) + (noun student)))))) + (verb-phrase + (verb-phrase + (verb studies) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep in) + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep by) + (noun-phrase + (simple-noun-phrase (article a) (noun class)) + (prep-phrase + (prep with) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep to) + (simple-noun-phrase (article the) (noun student)))) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun class)) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep with) + (simple-noun-phrase (article the) (noun professor)))))) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun student)))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article the) (noun class)) + (prep-phrase + (prep to) + (simple-noun-phrase (article a) (noun professor)))))) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article a) (noun professor)) + (prep-phrase + (prep for) + (simple-noun-phrase (article a) + (noun student)))))))))))))))) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun student)))) + (prep-phrase + (prep with) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep in) + (simple-noun-phrase (article the) (noun cat)))) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep with) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) (noun professor)) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) (noun professor)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) + (noun student)))) + (prep-phrase + (prep with) + (simple-noun-phrase (article a) + (noun professor)))))) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep with) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep to) + (simple-noun-phrase (article the) + (noun class)))))) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) + (noun student)))))))))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article a) (noun professor)) + (prep-phrase + (prep with) + (noun-phrase + (simple-noun-phrase (article a) (noun professor)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun student)))))))) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun class)))))) + (prep-phrase + (prep to) + (simple-noun-phrase (article the) (noun class)))) + (prep-phrase + (prep in) + (simple-noun-phrase (article a) (noun student)))))))))) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep in) + (simple-noun-phrase (article a) (noun student)))) + (prep-phrase + (prep with) + (noun-phrase + (simple-noun-phrase (article a) (noun class)) + (prep-phrase + (prep to) + (simple-noun-phrase (article a) (noun professor)))))))) + (prep-phrase + (prep in) + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun student)))) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep for) + (simple-noun-phrase (article a) (noun student)))))))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep for) + (simple-noun-phrase (article a) (noun professor)))))) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article a) (noun professor)) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep in) + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep in) + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article the) (noun class)) + (prep-phrase + (prep in) + (noun-phrase + (simple-noun-phrase (article the) + (noun professor)) + (prep-phrase + (prep to) + (simple-noun-phrase + (article a) + (noun class)))))))))))))))))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article a) (noun cat)) + (prep-phrase + (prep to) + (simple-noun-phrase (article a) (noun student)))))) + (prep-phrase + (prep to) + (simple-noun-phrase (article a) (noun class)))))))) + (prep-phrase + (prep for) + (simple-noun-phrase (article a) (noun professor)))))) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun class)) + (prep-phrase + (prep by) + (noun-phrase + (noun-phrase + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep to) + (simple-noun-phrase (article the) (noun student)))) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun professor)))) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun student)))) + (prep-phrase + (prep in) + (simple-noun-phrase (article the) (noun professor)))) + (prep-phrase + (prep for) + (simple-noun-phrase (article a) (noun student)))))) + (prep-phrase + (prep to) + (simple-noun-phrase (article a) (noun student)))) + (prep-phrase + (prep in) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep with) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) (noun class)) + (prep-phrase + (prep for) + (simple-noun-phrase (article a) (noun professor)))) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun cat)) + (prep-phrase + (prep for) + (simple-noun-phrase (article a) (noun professor)))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article the) (noun class)) + (prep-phrase + (prep with) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep with) + (simple-noun-phrase (article a) (noun student)))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep to) + (simple-noun-phrase (article a) (noun student)))) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) + (noun student)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) + (noun student)))) + (prep-phrase + (prep to) + (simple-noun-phrase (article a) + (noun class)))) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) + (noun class)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) + (noun class)))) + (prep-phrase + (prep in) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) + (noun professor)) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article a) + (noun student)) + (prep-phrase + (prep for) + (simple-noun-phrase + (article the) + (noun student)))))) + (prep-phrase + (prep by) + (simple-noun-phrase (article a) + (noun class)))))))) + (prep-phrase + (prep in) + (noun-phrase + (simple-noun-phrase (article the) + (noun professor)) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article the) + (noun professor)) + (prep-phrase + (prep for) + (simple-noun-phrase + (article the) + (noun student)))))))))))) + (prep-phrase + (prep with) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep by) + (simple-noun-phrase (article a) + (noun student)))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article the) (noun class)) + (prep-phrase + (prep to) + (simple-noun-phrase + (article the) + (noun professor)))))))))))))))))) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep for) + (simple-noun-phrase (article a) (noun class)))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun student)))))) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) + (noun student)))) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) + (noun professor)) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep by) + (noun-phrase + (simple-noun-phrase (article a) + (noun student)) + (prep-phrase + (prep in) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) + (noun student)) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article the) + (noun student)) + (prep-phrase + (prep for) + (simple-noun-phrase + (article a) + (noun professor)))))) + (prep-phrase + (prep to) + (simple-noun-phrase (article a) + (noun cat)))))))))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article a) + (noun professor)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) + (noun student)))))))) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article a) (noun cat)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) + (noun professor)))) + (prep-phrase + (prep by) + (simple-noun-phrase (article a) + (noun professor)))))))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article the) (noun cat)) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article a) (noun professor)) + (prep-phrase + (prep with) + (simple-noun-phrase (article the) (noun cat)))))))) + (prep-phrase + (prep in) + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep for) + (simple-noun-phrase (article a) (noun cat)))))) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun student)))))) + (prep-phrase + (prep in) + (noun-phrase + (simple-noun-phrase (article the) (noun class)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun professor)))))))) + (prep-phrase + (prep to) + (noun-phrase + (simple-noun-phrase (article a) (noun student)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun student)))))))))))) + (prep-phrase + (prep with) + (simple-noun-phrase (article a) (noun student)))))) + (prep-phrase + (prep for) + (noun-phrase + (simple-noun-phrase (article the) (noun professor)) + (prep-phrase + (prep in) + (noun-phrase + (simple-noun-phrase (article the) (noun class)) + (prep-phrase + (prep to) + (simple-noun-phrase (article a) (noun student)))))))))) + (prep-phrase + (prep to) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun cat)) + (prep-phrase + (prep for) + (noun-phrase + (noun-phrase + (simple-noun-phrase (article the) (noun student)) + (prep-phrase + (prep for) + (simple-noun-phrase (article the) (noun professor)))) + (prep-phrase + (prep for) + (simple-noun-phrase (article a) (noun student)))))) + (prep-phrase + (prep in) + (simple-noun-phrase (article a) (noun student))))))) + +We can improve on this by making the addition of a prepositional +phrase less likely. For example, we could rewrite PARSE-NOUN-PHRASE +and PARSE-VERB-PHRASE this way: + +(define (parse-noun-phrase) + (define (maybe-extend noun-phrase) + (ramb noun-phrase + noun-phrase + noun-phrase + noun-phrase + noun-phrase + (maybe-extend (list 'noun-phrase + noun-phrase + (parse-prepositional-phrase))))) + (maybe-extend (parse-simple-noun-phrase))) + +(define (parse-verb-phrase) + (define (maybe-extend verb-phrase) + (ramb verb-phrase + verb-phrase + verb-phrase + verb-phrase + verb-phrase + (maybe-extend (list 'verb-phrase + verb-phrase + (parse-prepositional-phrase))))) + (maybe-extend (parse-word verbs))) + +With these changes, here are the first few sentences I get: + +(sentence (simple-noun-phrase (article a) (noun professor)) (verb sleeps)) + +(sentence (simple-noun-phrase (article a) (noun professor)) (verb sleeps)) + +(sentence (simple-noun-phrase (article a) (noun professor)) + (verb-phrase + (verb sleeps) + (prep-phrase (prep for) + (simple-noun-phrase (article a) (noun student))))) + +(sentence + (simple-noun-phrase (article a) (noun professor)) + (verb-phrase (verb sleeps) + (prep-phrase (prep for) + (simple-noun-phrase (article a) (noun student))))) + +This is still not quite what we want, but with more fine tuning we can +probably get to a reasonable sentence generator. + + +4.52 if-fail + +To add a new special form we add a clause to ANALYZE, which should call +this new procedure: + +(define (analyze-if-fail exp) + (let ((trial (analyze (if-fail-trial exp))) + (failure (analyze (if-fail-failure exp)))) + (lambda (env succeed fail) + (trial env + succeed + (lambda () (failure env succeed fail)))))) + +(define if-fail-trial cadr) +(define if-fail-failure caddr) + +Here's a version to go with vambeval, the ambeval without analysis: + +(define (eval-if-fail exp env succeed fail) + (vambeval (if-fail-trial exp) + env + succeed + (lambda () (vambeval (if-fail-failure exp) + env + succeed + fail)))) + + +Extra for Experts +================= + +4.31 + +Despite what the exercise says, there's no need to change the procedures that +determine the DEFINE syntax, because it doesn't check that the formal +parameters are symbols. Even MAKE-PROCEDURE doesn't check. + +The hard part is in procedure invocation. The original metacircular evaluator +has this in the big COND in EVAL: + + ((application? exp) + (mc-apply (MC-EVAL (operator exp) env) + (LIST-OF-VALUES (operands exp) env))) + +The lazy evaluator in the book changes that to + + ((application? exp) + (mc-apply (ACTUAL-VALUE (operator exp) env) + (operands exp) ; no LIST-OF-VALUES + ENV)) ; added argument + +(For this exercise, it's easier to work with the book's version than with +the slightly different alternative shown in the lecture notes.) + +So now we're giving APPLY expressions rather than values, and we're also +giving APPLY an environment in which to evaluate or thunkify the values. +We don't have to make any change to the book's EVAL; the hard part is in +APPLY, in which we have to decide whether to evaluate or thunkify. + +Here's the book's lazy APPLY: + +(define (mc-apply procedure arguments env) + (cond ((primitive-procedure? procedure) + (apply-primitive-procedure + procedure + (LIST-OF-ARG-VALUES ARGUMENTS ENV))) ; *** + ((compound-procedure? procedure) + (eval-sequence + (procedure-body procedure) + (extend-environment + (procedure-parameters procedure) + (LIST-OF-DELAYED-ARGS ARGUMENTS ENV) ; *** + (procedure-environment procedure)))) + (else + (error + "Unknown procedure type -- APPLY" procedure)))) + +The two commented lines handle evaluation, for primitive procedures, and +thunking, for non-primitive procedures. It's the latter we have to change; +the args may be evaluated, thunked with memoization, or thunked without +memoization. To make this decision, we have to look at the formal parameters +of the procedure we're calling. So the second commented line above will +change to + + (PROCESS-ARGS arguments (PROCEDURE-PARAMETERS PROCEDURE) env) + +Two things have changed; we're calling a not-yet-written procedure +PROCESS-ARGS instead of LIST-OF-DELAYED-ARGS, and we're giving that procedure +the formal parameters as well as the actual argument expressions. + +One more thing has to change in APPLY: Since the list returned by +PROCEDURE-PARAMETERS is no longer a list of symbols, but can now include +sublists such as (B LAZY), we have to extract the real formal parameter +names from it. So the final version of APPLY is this: + +(define (mc-apply procedure arguments env) + (cond ((primitive-procedure? procedure) + (apply-primitive-procedure + procedure + (list-of-arg-values arguments env))) + ((compound-procedure? procedure) + (eval-sequence + (procedure-body procedure) + (extend-environment + (EXTRACT-NAMES (procedure-parameters procedure)) ; *** + (PROCESS-ARGS arguments (PROCEDURE-PARAMETERS PROCEDURE) env) ; *** + (procedure-environment procedure)))) + (else + (error + "Unknown procedure type -- APPLY" procedure)))) + +Now comes the actual work, in EXTRACT-NAMES and in PROCESS-ARGS. + +EXTRACT-NAMES takes as its argument a list such as + (A (B LAZY) C (D LAZY-MEMO)) +and returns a list with just the variable names: + (A B C D) + +(define (extract-names formals) + (cond ((null? formals) '()) + ((pair? (car formals)) ; CAR is (VAR TYPE), so keep CAAR in result + (cons (caar formals) (extract-names (cdr formals)))) + (else (cons (car formals) (extract-names (cdr formals)))))) + +PROCESS-ARGS takes an argument list, let's say + ((+ 2 3) (- 4 5) (* 6 7) (/ 8 9)) +and a parameter list, such as + (A (B LAZY) C (D LAZY-MEMO)) +and matches them up. It pays no attention to the variable names in the +parameter list; it's only looking for LAZY or LAZY-MEMO type tags. It returns +a list of argument values-and-thunks: + (5 (THUNK-NOMEMO (- 4 5) <env>) 42 (THUNK-MEMO (/ 8 9) <env>)) +where <env> represents an actual environment, not the word ENV. The argument +expressions (+ 2 3) and (* 6 7) correspond to non-lazy parameters A and C, +so they've been evaluated; the other arguments have been turned into thunks +by combining them with a type-tag (THUNK-NOMEMO or THUNK-MEMO as appropriate) +and an environment. Instead of the book's DELAY-IT procedure we have to use +two different procedures, DELAY-NOMEMO and DELAY-MEMO, to construct the thunks. + +(define (process-args args formals env) + (cond ((null? args) '()) + ((null? formals) + (error "Too many arguments")) + ((pair? (car formals)) + (cond ((eq? (cadar formals) 'lazy) + (cons (delay-nomemo (car args) env) + (process-args (cdr args) (cdr formals) env))) + ((eq? (cadar formals) 'lazy-memo) + (cons (delay-memo (car args) env) + (process-args (cdr args) (cdr formals) env))) + (else (error "Unrecognized parameter type" (cadar formals))))) + (else (cons (EVAL (car args)) + (process-args (cdr args) (cdr formals) env))))) + +Note the call to EVAL in capital letters two lines up. Should that be EVAL +or ACTUAL-VALUE? The issue is what behavior we want when a procedure with a +non-lazy parameter is called with a thunk (created by calling some other +non-primitive procedure) as the argument: + + (define (foo x) + x) + + (define (baz (lazy x)) + x) + + (define p (foo (baz (/ 1 0)))) + +What should happen? FOO's argument is non-lazy, so we evaluate the argument +expression (BAZ (/ 1 0)). BAZ's argument is lazy, so we make a thunk that +promises to compute (/ 1 0) later, and that becomes the argument to FOO. +If we use EVAL up there, as written, then FOO will get a thunk as its +argument, and will return the thunk, which will become the value of P. If +we make it ACTUAL-VALUE, then the thunk will be forced, and we'll get an +error dividing by zero, and P won't get a value. + +I think the procedure FOO probably doesn't care whether or not its argument is +a thunk, and therefore the argument shouldn't be forced. If the return value +from FOO is used in some context where a real value is needed (for example, +if we said + (foo (baz (/ 1 0))) +at the Scheme prompt instead of inside a DEFINE, then the value will be +forced.) But you'd like to be able to write something like + + (define (cadr seq) (car (cdr seq))) + +and if this is applied to a list of thunks, the result should be a +thunk, not the value promised by the thunk. + +Perhaps there should be a third parameter type tag, so you could say + + (define (f a (b lazy) c (d lazy-memo) (e forced)) + ...) + +allowing the user to choose between EVAL and ACTUAL-VALUE here. This would +add a COND clause in APPLY: + + ((eq? (cadar formals) 'forced) + (cons (actual-value (car args) env) + (process-args (cdr args) (cdr formals) env))) + + +Now we have to do a little data abstraction: + +(define (delay-nomemo exp env) + (list 'THUNK-NOMEMO exp env)) + +(define (delay-memo exp env) + (list 'THUNK-MEMO exp env)) + +Note that the thunk constructors don't have to do any real memoization or +non-memoization work; they just construct thunks that "know" which kind they +are. It's when the thunks are forced that we have to take the difference +into account: + +(define (force-it obj) + (cond ((THUNK-MEMO? obj) ; two kinds of thunk testers + (let ((result (actual-value + (thunk-exp obj) + (thunk-env obj)))) + (set-car! obj 'evaluated-thunk) + (set-car! (cdr obj) result) ; replace exp with its value + (set-cdr! (cdr obj) '()) ; for memoized thunk + result)) + ((THUNK-NOMEMO? OBJ) ; nomemo thunk is EVALed each time it's forced + (ACTUAL-VALUE (THUNK-EXP OBJ) (THUNK-ENV OBJ))) + ((evaluated-thunk? obj) + (thunk-value obj)) + (else obj))) + +(define (thunk-memo? exp) + (tagged-list? exp 'thunk-memo)) + +(define (thunk-nomemo? exp) + (tagged-list exp 'thunk-nomemo)) + +Note that for both kinds of thunks we call ACTUAL-VALUE to cash in the promise; +the difference is that for a memoized thunk we remember the result, whereas for +a non-memoized thunk we don't. + + + +Handle-infix: See proj4b solutions. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week15 b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week15 new file mode 100644 index 0000000..4d67123 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week15 @@ -0,0 +1,325 @@ +CS 61A Week 15 Solutions + +LAB +=== + +4.55 + +(supervisor ?x (Bitdiddle Ben)) + +(job ?x (accounting . ?y)) + +(address ?x (Slumerville . ?y)) + +The dots are needed because (accounting ?y), for example, would match +only entries in which there was a single element after the word "accounting." +That is, (accounting ?y) would match (accounting scrivener) but not +(accounting chief accountant). + + +4.62 +The base case here involves a 1-element list, not the empty list. + +(rule (last-pair (?x) (?x))) + +(rule (last-pair (?y . ?z) ?x) + (last-pair ?z ?x)) + + +HOMEWORK +======== + +4.56 + +(and (supervisor ?x (Bitdiddle Ben)) + (address ?x ?y)) + +(and (salary ?x ?s1) + (salary (Bitdiddle Ben) ?s2) + (lisp-value < ?s1 ?s2)) + +(and (supervisor ?who ?boss) + (not (job ?boss (computer . ?y))) + (job ?boss ?z)) + +The key point here is that we use the same variable name twice if we want +it to match the same item both times. + + +4.57 + +(rule (same ?x ?x)) ;; Don't use (lisp-value eq? ....) + +(rule (replace ?p1 ?p2) + (and (or (and (job ?p1 ?x) (job ?p2 ?x)) + (and (job ?p1 ?x) (job ?p2 ?y) (can-do-job ?x ?y))) + (not (same ?p1 ?p2)))) + +(replace ?x (Fect Cy D)) + +(and (replace ?x ?y) + (salary ?x ?s1) + (salary ?y ?s2) + (lisp-value < ?s1 ?s2)) + + +4.58 +Note the definition of a sub-rule to make things more manageable. + +(rule (sup-in-div ?p ?x) + (and (supervisor ?p ?boss) + (job ?boss (?x . ?z)))) + +(rule (big-shot ?person ?division) + (and (job ?person (?division . ?x)) + (not (sup-in-div ?person ?division)))) + + +4.65 +This problem requires understanding the basic idea of how the +query system works (read Section 4.4.3). +To respond to a query, the query system generates +a stream of frames which are then used to "instantiate" the query. +In this case, the stream will include frames containing all bindings of +?middle-manager, ?person and ?x satisfying the body of the rule, +and also with ?who bound to ?person. +Since Warbucks supervises Bitdiddle and Scrooge, each of who manages +other people, there will be more than one of these frames. +Hence Warbucks appears more than once in the output. + + +Extra for Experts +================= + +Here's the REVERSE from lecture: + + (assert! (rule (reverse (?a . ?x) ?y) + (and (reverse ?x ?z) + (append ?z (?a) ?y) ))) + + (assert! (reverse () ())) + +Why won't this run backwards? It's important to understand this, in order to +solve the problem. Unfortunately there are a lot of details, so here's a +preview of the punch line: It'll turn out that the query system tries to use +the recursive rule over and over, in effect constructing longer and longer +lists whose elements aren't known, and never realizing that they can't +possibly be the reverse of the given list. + +Let's try to work out what happens if we give the simplest possible +backwards query: + + (reverse ?b (3)) + +The answer we want is (reverse (3) (3)). QEVAL starts with the stream of +frames containing one empty frame: + + {[]} + +it matches the query against everything in the database. Only two are +relevant -- the ones about REVERSE. Starting with the base case assertion + + (reverse () ()) + +we see that this doesn't match the query, because (3) in the third element of +the query is not () and neither of them is a variable. That leaves the +recursive rule. We unify the query against the conclusion of the rule, +after renaming the variables in the rule: + + (reverse ?b (3)) + (reverse (?1a . ?1x) ?1y) + +This succeeds, and the empty frame is extended with new bindings: + + [?b = (?1a . ?1x), ?1y = (3)] + +Now we use this frame as the starting point for a new query, the rule's body: + + (and (reverse ?1x ?1z) (append ?1z (?1a) ?1y)) + +Now it gets a little complicated. QEVAL of an AND query starts by +evaluating the first part in the current frame. We match + + (reverse ?1x ?1z) + +against all rules and assertions. Again, let's start with the base case, +so we are matching + + (reverse ?1x ?1z) + (reverse () ()) + +This extends the frame with new bindings for ?1X and ?1Z: + + [?b = (?1a . ?1x), ?1y = (3), ?1x = (), ?1z = ()] + +With these bindings we have to evaluate the second part of the AND: + + (append ?1z (?1a) ?1y) + +Substituting values from the frame, this is equivalent to + + (append () (?1a) (3)) + +which will work fine (leaving out the details about APPEND), giving a +final extended frame of + + [?b = (?1a . ?1x), ?1y = (3), ?1x = (), ?1z = (), ?1a = 3] + +So ?b = (?1a . ?1x) = (3 . ()) = (3). + +This is a fine solution, and if the query system looks at assertions +before rules, it may even be printed before the evaluator gets into an +infinite loop. The problem is with the recursive REVERSE rule. + +Remember that we are trying to evaluate the query + + (and (reverse ?1x ?1z) (append ?1z (?1a) ?1y)) + +and that the first step is to evaluate + + (reverse ?1x ?1z) + +in the frame + + [?b = (?1a . ?1x), ?1y = (3)] + +We've matched the query against the base case for REVERSE, and now we are +trying the recursive rule. Here are the query and the conclusion (with +variables again renamed) of the rule: + + (reverse ?1x ?1z) + (reverse (?2a . ?2x) ?2y) + +This succeeds; the resulting frame is + + [?b = (?1a . ?1x), ?1y = (3), ?1x = (?2a . ?2x), ?1z = ?2y] + +In this frame we must evaluate the body of the rule, namely + + (and (reverse ?2x ?2z) (append ?2z (?2a) ?2y)) + +Match the REVERSE part against the conclusion of the REVERSE rule +with variables renamed: + + (reverse ?2x ?2z) + (reverse (?3a . ?3x) ?3y) + +This extends the frame some more: + + [?b = (?1a . ?1x), ?1y = (3), ?1x = (?2a . ?2x), ?1z = ?2y, + ?2x = (?3a . ?3x), ?2z = ?3y] + +We human beings can see that this is all nonsense. Combining some of the +bindings we see that + + ?b = (?1a . (?2a . (?3a . ?3x))) + +which is a list of at least three elements. So if we ever got to the +APPEND part of the rule, it wouldn't match -- the result of reversing (3) +can't be more than one element long! But QEVAL will never get around to +the second half of the AND query, because it keeps finding longer and +longer lists to try to reverse. + +Why isn't this a problem when running the REVERSE rules forward? Let's +take the query + + (reverse (35) ?d) + +This doesn't match the base case, so we try the recursive case renamed: + + (reverse (35) ?d) + (reverse (?4a . ?4x) ?4y) + +We can see a difference right away: It's the known list, (35), that we +divide into its car and its cdr, giving determined values for some of +the variables in the new frame: + + [?4a = 35, ?4x = (), ?d = ?4y] + +We must now evaluate the body of the rule: + + (and (reverse ?4x ?4z) (append ?4z (?4a) ?4y)) + +I'll skip the part about matching the new REVERSE query against the base +case, which again gives a correct result. Instead let's see what happens +when we try to use the recursive rule again: + + (reverse ?4x ?4z) + (reverse (?5a . ?5x) ?5y) + +This unification fails! We want ?4x = (?5a . ?5x), but the frame tells us +that ?4x is empty. + +This is why forward reverse doesn't get into an infinite loop: QEVAL notices +that the recursive rule can't apply when we get past the number of elements +in the original list. + +---------- + +That's the end of the analysis of what's wrong. The recursive rule is +supposed to say "the reverse of my known length-N list (?a . ?x) can be +computed if we first take the reverse of a list of length N-1, namely ?x." +But when run backwards it instead says "the reverse of my known list ?y +consists of a (first) element ?1a followed by a list consisting of an +element ?2a followed by a list consisting of an element ?3a followed ..." + +We don't have this problem running the rules forwards because the rule +takes our known list and divides it into car and cdr, so we find out as +soon as we run out of list elements. The algorithm doesn't require us +to divide the second list, ?y, into pieces, and the cdr of ?y isn't useful +in doing the recursion -- we need all of ?y. So we'll add an extra +variable whose only purpose is to count down the length of ?y: + +(assert! (rule (reverse ?x ?y) + (reverse-help ?x ?y ?y))) + +(assert! (rule (reverse-help (?a . ?x) ?y (?ignore . ?counter)) + (and (reverse-help ?x ?z ?counter) + (append ?z (?a) ?y)))) + +(assert! (rule (reverse-help () () ()))) + +On each recursive invocation of the REVERSE-HELP rule, ?COUNTER gets +smaller. When it's empty, no more recursions are possible, because an +empty list can't match (?ignore . ?counter). + +For forwards queries, the whole counter mechanism is unhelpful, but it +doesn't hurt. It's the (?a . ?x) that prevents infinite recursion for +forwards queries; the ?counter situation is just like the ?x situation +we saw before for backwards queries -- in effect we get + + ?1counter = (?2ignore . (?3ignore . (?4ignore . ?4counter))) + +after three invocations of the rule. That could keep going on forever, +but the values of ?1x, ?2x, etc., are *known* and therefore eventually +one of them is empty and won't match the recursive rule. + +---------- + +This solution, like the partial solution in the lecture notes, is based on +the recursive-process Scheme procedure + + (define (reverse seq) + (if (null? seq) + '() + (append (reverse (cdr seq)) (list (car seq))))) + +What if we start instead with the iterative-process version: + + (define (reverse seq) + (define (iter seq result) + (if (null? seq) + result + (iter (cdr seq) (cons (car seq) result))))) + +We still have to add an extra counter variable to make this work as a +both-ways logic program, in addition to the Scheme program's extra +result variable: + + (assert! (rule (reverse ?x ?y) + (reverse-iter ?x () ?y ?y))) + + (assert! (rule (reverse-iter (?a . ?x) ?result ?y (?b . ?counter)) + (reverse-iter ?x (?a . ?result) ?y ?counter))) + + (assert! (rule (reverse-iter () ?y ?y ()))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week2 b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week2 new file mode 100644 index 0000000..6cd2999 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week2 @@ -0,0 +1,509 @@ +CS 61A Week 2 Lab and Homework Solutions + +FIRST LAB: + +Problem 1: + +f Any definition at all will do: + (define f 'hello) f is hello + (define f (+ 2 3)) f is 5 + (define (f x) (+ x 7)) f is #<procedure f> + +(f) This expression says to invoke f as a procedure with no + arguments. For that to work, we must DEFINE f as a procedure + with no arguments: + (define (f) 'hello) (f) is hello + (define (f) (+ 2 3)) (f) is 5 + Each of these is shorthand for an explicit use of lambda: + (define f (lambda () 'hello)) + (define f (lambda () (+ 2 3)) + +(f 3) This expression says to invoke f as a procedure with an + argument, so we have to define it that way: + (define (f x) (+ x 5)) (f 3) is 8 + (define (f x) 'hello) (f 3) is hello + (define (f x) (word x x)) (f 3) is 33 + Again, these definitions are shorthand for lambda expressions: + (define f (lambda (x) (+ x 5))) + (define f (lambda (x) 'hello)) + (define f (lambda (x) (word x x))) + +((f)) This expression says, first of all, to compute the subexpression + (f), which invokes f as a procedure with no arguments. Then, the + result of that invocation must be another procedure, which is + also invoked with no arguments. So, we have to define f as a + procedure that returns a procedure: + (define (f) (lambda () 'hello)) ((f)) is hello + (define (f) (lambda () (+ 2 3))) ((f)) is 5 + Or without the shorthand, + (define f (lambda () (lambda () 'hello))) + (define f (lambda () (lambda () (+ 2 3)))) + Alternatively, we can let the procedure f return some procedure + we already know about, supposing that that procedure can be + invoked with no arguments: + (define (f) +) ((f)) is 0 + (define f (lambda () +)) + As a super tricky solution, for hotshots only, try this: + (define (f) f) ((f)) is #<procedure f> + (((f))) is.... ? + +(((f)) 3) Sheesh! F has to be a function. When we invoke it with no + arguments, we should get another function (let's call it G). + When we invoke G with no arguments, we get a third function + (call it H). We have to be able to call H with the argument 3 + and get some value. We could spell this out as a sequence of + definitions like this: + (define (h x) (* x x)) + (define (g) h) + (define (f) g) (((f)) 3) is 9 + Alternatively, we can do this all in one: + (define (f) (lambda () (lambda (x) (* x x)))) + or without the abbreviation: + (define f (lambda () (lambda () (lambda (x) (* x x))))) + +By the way, you haven't yet learned the notation for functions that accept +any number of arguments, but if you did know it, you could use + (define (f . args) f) +as the answer to *all* of these problems! + + +Problem 2: + +This is a "do something to every word of a sentence" problem, like +PL-SENT or SQUARES, but with two extra arguments. But it +also has a decision to make for each word (is this word equal to the +one we're replacing), like the filtering procedures EVENS, ENDS-E, etc., +so it takes the form of a three-branch COND: + +(define (substitute sent old new) + (cond ((empty? sent) '()) + ((equal? (first sent) old) + (se new (substitute (butfirst sent) old new))) + (else (se (first sent) (substitute (butfirst sent) old new))))) + + +Problem 3: + +Of course you could just try this on the computer, but you should understand +the results. + +(t 1+) means that we should substitute the actual argument, which is the +function named 1+, for t's formal parameter, which is f, in t's body, +which is (lambda (x) (f (f (f x)))). The result of the substitution is + + (lambda (x) (1+ (1+ (1+ x)))) + +Evaluating this produces a function that adds three to its argument, so +((t 1+) 0) is 3. + +(t (t 1+)) means to substitute (t 1+) for f in t's body. If we actually +substituted the lambda expression above for f three times, we'd get a +horrible mess: + + (lambda (x) ((lambda (x) (1+ (1+ (1+ x)))) + ((lambda (x) (1+ (1+ (1+ x)))) + ((lambda (x) (1+ (1+ (1+ x)))) + 0)))) + +but what's important is the function, not the expression that produced +the function, so we can just mentally give (t 1+) the name 3+ and then +the result we want is + + (lambda (x) (3+ (3+ (3+ x)))) + +and if we apply that function to 0 we'll get 9. + +For the final piece of the problem, we have to begin by computing (t t), which +is what we get when we substitute t for f in t's body: + + (lambda (x) (t (t (t x)))) + +Don't be confused! Even though this lambda expression has x as its formal +parameter, not f, the argument has to be a function, because we're going to +end up invoking t on that argument. In other words, (t t) returns as its +value a function that takes a function as argument. + +Now, ((t t) 1+) means to apply the function just above to the argument 1+ +which, in turn, means to substitute 1+ for x in the body: + + (t (t (t 1+))) + +Well, this isn't so hard; we've really already done it. (t 1+) turned +out to be 3+, and (t (t 1+)) turned out to be 9+. By the same reasoning, +this will turn out to be 27+ (that is, 9+ three times), so when we apply +this to 0 we get 27. + +Problem 4: + +This is actually the same as problem 2! The function S is identical to +1+, so the answers have to be the same. It's more work if you actually +substitute values into the body of s, but you can avoid all that if you +realize that these problems are identical in meaning. + +Problem 5: + +If (g) is a legal expression, then g takes ZERO arguments. +If ((g) 1) has the value 3, then (g) has a PROCEDURE as its value. +(If we'd asked for more than one word, you could say "a procedure +of one numeric argument that returns a number" or something.) + + +Problem 6: + +(define (make-tester who) + (lambda (x) (equal? x who))) + + + +HOMEWORK: + +Exercise 1.31(a): + +;; you only needed to hand in one version +;; but by now you're ready to understand both: + +;; recursive version: + +(define (product term a next b) + (if (> a b) + 1 ;; Note multiplicative identity is 1 not 0 + (* (term a) + (product term (next a) next b)))) + +;; iterative version: + +(define (product term a next b) + (define (iter a result) + (if (> a b) + result + (iter (next a) (* result (term a))))) + (iter a 1)) + +;; factorial + +(define (! n) (product (lambda (x) x) 1 1+ n)) + +;; pi +;; You have to run a few hundred terms to get a good approximation. +;; There are several possible ways to arrange the terms. Here is one +;; way, in which the first term is 2/3, the second is 4/3, etc. + +(define (pi terms) (* 4 (product + (lambda (x) (/ (* 2 (1+ (floor (/ x 2)))) + (1+ (* 2 (ceiling (/ x 2)))))) + 1 1+ terms))) + +;; Here is another way, in which the first term is (2/3)*(4/3), the +;; second is (4/5)*(6/5), etc. Notice that the value of a starts at +;; 3 and is increased by 2 for each new term. + +(define (pi terms) (* 4 (product + (lambda (x) (/ (* (-1+ x) (1+ x)) + (* x x) )) + 3 + (lambda (x) (+ x 2)) + terms ))) + +;; If you try to make it 2 * (4/3) * (4/3) * (6/5) * (6/5) * ... you'll +;; get the wrong answer, because you'll have one more number in the +;; numerator than in the denominator. + + + +Exercise 1.32(a): + +;; you only needed to hand in one version + +;; recursive form + +(define (accumulate combiner null-value term a next b) + (if (> a b) + null-value + (combiner (term a) + (accumulate combiner null-value term (next a) next b)))) + +;; iterative form + +(define (accumulate combiner null-value term a next b) + (define (iter a result) + (if (> a b) + result + (iter (next a) (combiner (term a) result)))) + (iter a null-value)) + +;; sum and product + +(define (sum term a next b) (accumulate + 0 term a next b)) + +(define (product term a next b) (accumulate * 1 term a next b)) + + + +Exercise 1.33: + +;; The problem only requires one version but this too can be +;; recursive or iterative. Recursive version: + +(define (filtered-accumulate combiner null-value term a next b predicate) + (cond ((> a b) null-value) + ((predicate a) + (combiner (term a) + (filtered-accumulate combiner + null-value + term + (next a) + next + b + predicate))) + (else (filtered-accumulate combiner + null-value + term + (next a) + next + b + predicate)))) + +;; Iterative version: + +(define (filtered-accumulate combiner null-value term a next b predicate) + (define (iter a result) + (cond ((> a b) result) + ((predicate a) (iter (next a) (combiner (term a) result))) + (else (iter (next a) result)))) + (iter a null-value)) + +;; (a) sum of squares of primes + +(define (sum-sq-prime a b) + (define (square x) (* x x)) + (filtered-accumulate + 0 square a 1+ b prime?)) + +;; (b) product of blah blah, using gcd from page 49 + +(define (prod-of-some-numbers n) + (filtered-accumulate * + 1 + (lambda (x) x) + 1 + 1+ + n + (lambda (x) (= 1 (gcd x n))))) + + +Exercise 1.40: + +(define (cubic a b c) + (lambda (x) (+ (* x x x) (* a x x) (* b x) c))) + + +Exercise 1.41: + +(define (double f) + (lambda (x) (f (f x)))) + + +Why does (((double (double double)) inc) 5) return 21 and not 13? +The crucial point is that DOUBLE is not associative. + +> (((double (double double)) inc) 5) +21 +> ((double (double (double inc))) 5) +13 + +DOUBLE turns a function into one that applies the function twice. +(DOUBLE DOUBLE) turns a function into one that applies the function +four times. +(DOUBLE (DOUBLE DOUBLE)) makes a function that applies (DOUBLE DOUBLE) +twice -- that is, make a function that applies the argument function +four times four times! + + + +Exercise 1.43: + +(define (repeated f n) + (lambda (x) + (if (= n 0) + x + (f ((repeated f (- n 1)) x))))) + +or + +(define (repeated f n) + (lambda (x) + (if (= n 0) + x + ((repeated f (- n 1)) (f x))))) + +or + +(define (repeated f n) + (if (= n 0) + (lambda (x) x) + (lambda (x) (f ((repeated f (- n 1)) x))))) + + +We didn't assign 1.42, but if you followd the hint about it in 1.43, +you'd end up with this: + +(define (repeated f n) + (if (= n 0) + (lambda (x) x) + (compose f (repeated f (- n 1))))) + + +1.46 + +This problem is a little complicated in its details because there are so +many different procedures involved, with different domains and ranges. +But don't let that keep you from seeing the beauty of this extremely +general method! + +(define (iterative-improve good-enough? improve) + (define (iterate guess) + (if (good-enough? guess) + guess + (iterate (improve guess)))) + iterate) + +(define (sqrt x) ;; compare to bottom of page 30 of SICP + ((iterative-improve (lambda (guess) (< (abs (- (square guess) x)) 0.001)) + (lambda (guess) (average guess (/ x guess)))) + 1.0)) + +Some people were confused about sqrt because the original good-enough? takes +two arguments, and iterative-improve only allows for one. But we are using +lexical scope so that the lambda expressions used as arguments to +iterative-improve have access to the starting value x. + +(define (fixed-point f first-guess) ;; compare to page 69 + ((iterative-improve (lambda (guess) (< (abs (- guess (f guess))) tolerance)) + f) + first-guess)) + +Here the structure is a little different from what's in the book, because +there is no variable NEXT to hold the next guess. The solution above computes +(f guess) twice for each guess. If you don't like that, you could use a more +complicated solution in which the argument to the good-enough procedure is a +sentence containing both old and new guesses: + +(define (fixed-point f first-guess) + ((iterative-improve (lambda (guesses) + (< (abs (- (first guesses) (last guesses))) tolerance)) + (lambda (guesses) + (sentence (last guesses) (f (last guesses))))) + (sentence first-guess (f first-guess)))) + +but I don't think the constant-factor efficiency improvement is worth the +added complexity of the code. + + +-------- + +2. EVERY: + +(define (every f sent) + (if (empty? sent) + '() + (se (f (first sent)) + (every f (butfirst sent)) ))) + + +-------- + +Extra for experts: + +This is a really hard problem! But its solution comes up enough in the +literature that it has a name: the Y combinator. First here's the +combinator alone: + +(lambda (f) (lambda (n) (f f n))) + +And here's the factorial function using it: + +( (lambda (f) (lambda (n) (f f n))) + (lambda (fun x) + (if (= x 0) + 1 + (* x (fun fun (- x 1))))) ) + +And now here's (fact 5): + +( ( (lambda (f) (lambda (n) (f f n))) + (lambda (fun x) + (if (= x 0) + 1 + (* x (fun fun (- x 1))))) ) + 5) + +The trick is that instead of the factorial function taking a number as an +argument, it takes TWO arguments, a function (which will really be itself when +called) and a number. The recursive call is done using the function provided +as argument. + +The job of the Y combinator is to provide the function with itself as an +argument. + +If that seems like a rabbit out of a hat, here's a longer explanation: + +The problem we're trying to solve is that factorial wants to be able to call +itself recursively, and to do that it has to have a name for itself. We have +two ways to give something a name, and one of them, DEFINE, is ruled out in +this problem. That leaves procedure invocation, which associates formal +parameters (the names) with actual arguments (the values). So we could +do this: + +((lambda (f n) (if (= n 0) 1 (* n (f f (- n 1))))) + (lambda (f n) (if (= n 0) 1 (* n (f f (- n 1))))) + 5) + +to get the factorial of 5. Ordinarily we think of factorial as a function +of one argument (N); here we've added a formal parameter F whose value is +another copy of the same function. If you work through this expression, +you'll see that the first copy is called only for N=5; the other calls for +all smaller values of N use the second copy, because (unlike the first) it +is called with *itself* (the very same lambda-created procedure) as its +argument. + +Now, it's a little ugly having to type the procedure twice. Also, I sort of +half lied when I said there are only two ways to give something a name. +There's a kind of third way, LET, although that's really the same as creating +and calling a procedure; and LET is good at avoiding having to type something +twice. So you might be tempted to say + +(let ((fact (lambda (n) (if (= n 0) 1 (* n (fact (- n 1))))))) + (fact 5)) + +But this doesn't work, because the name "fact" doesn't mean that lambda- +created procedure when the lambda expression is evaluated; that association +holds only in the body of the let. If that isn't clear, we can expand it: + +((lambda (fact) (FACT 5)) + (lambda (n) (if (= n 0) 1 (* n (fact (- n 1)))))) + +The capitalized FACT above is inside the lambda of which fact is the formal +parameter, so the (lambda (n) ...) procedure is substituted for it. But the +name "fact" also appears on the second line of the expression, in the actual +argument expression, and *that* isn't inside the (lambda (fact) ...), so +there is no substitution; it will look for a global name fact. Thus we have +to have F (in the original solution above) take *itself* as an argument, so +that the substitution happens in the right place. We could do that with a +LET form equivalent to the original solution: + +(let ((f (lambda (f n) (if (= n 0) 1 (* n (f f (- n 1))))))) + (f f 5)) + +This one does work. Notice that the body of the let, (f f 5), is almost +like the Y combinator's body, except that the latter generalizes to a +function of N instead of having 5 built in, like this LET expression: + +(let ((f (lambda (f n) (if (= n 0) 1 (* n (f f (- n 1))))))) + (lambda (n) (f f n))) + +Now just rearrange this to eliminate the LET abbreviation: + +((LAMBDA (F) (LAMBDA (N) (F F N))) + (lambda (f n) (if (= n 0) 1 (* n (f f (- n 1)))))) + +This returns a function of N, the factorial function. And the capitalized +part is the Y combinator. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week4 b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week4 new file mode 100644 index 0000000..996c4ab --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week4 @@ -0,0 +1,152 @@ +CS 61A Week 4 solutions + +LAB EXERCISES: + +1. Error message hunt + ++: not a number: foo +unbound variable: zot +eval: bad function in : (3) +too many arguments to: (bf 3 5) +random: bad number: -7 +sqrt: number is negative: -6 +Invalid argument to FIRST: () +Argument to SENTENCE not a word or sentence:#f +define: bad variable name: 5 + +2. Tracing + +In a base-case call, the return value comes right after the call: + +STk> (fib 5) +.. -> fib with n = 5 +.... -> fib with n = 4 +...... -> fib with n = 3 +........ -> fib with n = 2 +.......... -> fib with n = 1 <=== Here's a base case +.......... <- fib returns 1 <=== with its return value +.......... -> fib with n = 0 +.......... <- fib returns 0 +........ <- fib returns 1 +........ -> fib with n = 1 +........ <- fib returns 1 +...... <- fib returns 2 +...... -> fib with n = 2 +........ -> fib with n = 1 +........ <- fib returns 1 +........ -> fib with n = 0 +........ <- fib returns 0 +...... <- fib returns 1 +.... <- fib returns 3 +.... -> fib with n = 3 +...... -> fib with n = 2 +........ -> fib with n = 1 +........ <- fib returns 1 +........ -> fib with n = 0 +........ <- fib returns 0 +...... <- fib returns 1 +...... -> fib with n = 1 +...... <- fib returns 1 +.... <- fib returns 2 +.. <- fib returns 5 +5 + +I count eight base-case calls. + + +HOMEWORK: +--------- + +1. Start by tracing it out (mentally or online): + +(fact 5) +(iter 1 1) +(iter 1 2) +(iter 2 3) +(iter 6 4) +(iter 24 5) +(iter 120 6) + +What jumps out is that the first argument to ITER is always the factorial +of something. Of what? One less than the second argument. So the +invariant is + + product = (counter-1)! + +2. Tracing again: + +(fact 5) +(helper 1 5) +(helper 5 4) +(helper 20 3) +(helper 60 2) +(helper 120 1) +(helper 120 0) + +This time, RESULT isn't the factorial of anything until the end. The +invariant is a little harder to find, but at each step, the work still +undone is the factorial of COUNTER, so the invariant turns out to be + + n! = result * counter! + +3. Trace: + +(pigl 'scheme) +(pighelp 'scheme) +(pighelp 'chemes) +(pighelp 'hemesc) +(pighelp 'emesch) + +What's invariant is that all of these words have the same translation +into Pig Latin: + + (pigl wd) = (pigl wrd) + +4. In question 3, we had the name WD for our original argument, and the +name WRD for the current argument to the helper. In the simpler procedure, +there is no helper, and there's only one formal parameter, WD, to talk +about. So we have to say something like + + (pigl of currnt wd) = (pigl of original wd) + + +5. The domain of pigl is words that contain a vowel. + + +6. Here's something else we can say about each iteration: + + The number of initial non-vowels in WD is reduced by one. + +For words in the domain, the number of initial non-vowels is a nonnegative +integer, and there is always a vowel following them. If the number of +initial non-vowels is N, then after N iterations, the first letter is a +vowel. So the process reaches the base case. + +But, by the invariant, we know that the value returned in the base case +is equal to the Pig Latin translation of the original WD. + + +7. REST-OF-DECK is of type HAND; it's a sentence of cards. + +There are two approaches to documenting this. One is to say, in the initial +listing of data types, that the names HAND and DECK are equivalent, and both +refer to a sentence of cards. Then the name REST-OF-DECK is self-documenting. +The other is to put a comment in the procedure saying that REST-OF-DECK is +a hand. + + +Extra for experts: +------------------ + +; SORT carries out a bubble sort algorithm. +; SENT is a sentence of numbers. +; +; Subprocedure BUBBLE returns a sentence of the same numbers as in its +; argument, but reordered so that the largest number is at the end. +; There is no guarantee about the order of other numbers in the sentence. +; +; SORT calls BUBBLE repeatedly. Each time one number bubbles to the end, +; and then SORT recursively bubble-sorts the remaining numbers. + +I didn't use any invariants, etc., although that could be done. I just +found it more helpful to explain the algorithm in general terms. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week6 b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week6 new file mode 100644 index 0000000..61b274c --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week6 @@ -0,0 +1,1008 @@ +CS 61A Week 6 solutions + +LAB EXERCISES: + +2.25. Extract 7 + +(cadr (caddr '(1 3 (5 7) 9))) + +I did that one by knowing that "cadr" means "the second element" and +"caddr" means "the third element," and the seven is the second element +of the third element of the overall list. + +(car (car '((7))) + +(cadr (cadr (cadr (cadr (cadr (cadr '(1 (2 (3 (4 (5 (6 7)))))))))))) + + + +2.53. Finger exercises. +Note that it matters how many parentheses are printed! + +> (list 'a 'b 'c) +(a b c) + +> (list (list 'george)) +((george)) + +> (cdr '((x1 x2) (y1 y2))) +((y1 y2)) + +> (cadr '((x1 x2) (y1 y2))) +(y1 y2) + +> (pair? (car '(a short list))) +#f + +> (memq 'red '((red shoes) (blue socks))) +#f + +> (memq 'red '(red shoes blue socks)) +(red shoes blue socks) + + + +2.55 (car ''abracadabra) + +When you write + + 'foo + +it's just an abbreviation for + + (quote foo) + +no matter what foo is, and no matter what the context is. So + + ''foo + +is an abbreviation for + + (quote (quote foo)) + +If you enter the expression + + (car ''abracadabra) + +you are really saying + + (car (quote (quote abracadabra))) + +Using the usual evaluation rules, we start by evaluating the subexpressions. +The symbol car evaluates to a function. The expression + + (quote (quote abracadabra)) + +evaluates to the unevaluated argument to (the outer) quote, namely + + (quote abracadabra) + +That latter list is the actual argument to car, and so car returns the first +element of that list, i.e., the word quote. + + +Another example: + + (cdddr '(this list contains '(a quote))) + +is the same as + + (cdddr '(this list contains (quote (a quote)))) + +which comes out to + + ((quote (a quote))) + + +P.S.: Don't think that (car ''foo) is a quotation mark! First of all, +the quotation mark has already been turned into the list for which it +is an abbreviation before we evaluate the CAR; secondly, even if the +quotation mark weren't an abbreviation, CAR isn't FIRST, so it doesn't +take the first character of a quoted word! + + + +2.27. Deep-reverse. + +This is a tough problem to think about, although you can write a really +simple program once you understand how. One trick is to deep-reverse a +list yourself, by hand, without thinking about it too hard, and THEN ask +yourself how you did it. It's pretty easy for you to take a list like + +((1 2 3) (4 5 6) (7 8 9)) + +and instantly write down + +((9 8 7) (6 5 4) (3 2 1)) + +How'd you do it? The answer probably is, "I reversed the list and then I +deep-reversed each of the sublists." So: + +(define (deep-reverse lst) ;; Almost working version + (map deep-reverse (reverse lst))) + +But this doesn't QUITE work, because eventually you get down to the level +of atoms (symbols or numbers) and you can't map over an atom. So: + +(define (deep-reverse lst) + (if (pair? lst) + (map deep-reverse (reverse lst)) + lst)) + +If you tried to define deep-reverse without using map, you'll appreciate +the intellectual power it gives you. You probably got completely lost in +cars and cdrs, none of which are used in this program. + +Now that you understand the algorithm, it's possible to do what the problem +asked us to do, namely "modify your reverse procedure": + +(define (deep-reverse lst) + (define (iter old new) + (cond ((null? old) new) + ((not (pair? old)) old) + (else (iter (cdr old) (cons (deep-reverse (car old)) new))))) + (iter lst '())) + +This program will repay careful study, especially if you've fallen into the +trap of thinking that there is an iterative form and a recursive form in which +any problem can be expressed. Deep-reverse combines two subproblems. The +top-level reversal is one that can naturally be expressed iteratively, and +in this procedure the invocation of iter within itself does express an +iteration. But the deep-reversal of the sublists is an inherently recursive +problem; there is no way to do it without saving a lot of state information +at each level of the tree. So the call to deep-reverse within iter is truly +recursive, and necessarily so. Can you express the time and space requirements +of this procedure in Theta(...) notation? + + +5. Scheme-1 AND form. + +Special forms are handled by clauses in the COND inside EVAL-1, so we +start by adding one for this new form: + +(define (eval-1 exp) + (cond ((constant? exp) exp) + ((symbol? exp) (error "Free variable: " exp)) + ((quote-exp? exp) (cadr exp)) + ((if-exp? exp) + (if (eval-1 (cadr exp)) + (eval-1 (caddr exp)) + (eval-1 (cadddr exp)))) + ((lambda-exp? exp) exp) + ((AND-EXP? EXP) (EVAL-AND (CDR EXP))) ;; added + ((pair? exp) (apply-1 (car exp) + (map eval-1 (cdr exp)))) + (else (error "bad expr: " exp)))) + +Note that the new clause has to come before the PAIR? test, because special +forms are also pairs, and must be caught before we try to interpret them as +ordinary procedure calls. + +We also need the helper that checks for a list starting with the word AND: + +(define and-exp? (exp-checker 'and)) + +That was the easy part. Now we have to do the actual work, in the +procedure EVAL-AND. I chose to give it (CDR EXP) as its argument because +I'm envisioning a recursive loop through the subexpressions, and we want +to leave out the word AND itself, which isn't to be evaluated. + +What AND is supposed to do is to go through the subexpressions from left +to right, evaluating each in turn until either some expression's value is +#F (in which case we return #F) or we run out (in which case we return, +to get exactly Scheme's behavior, the value of the last expression, which +might be some true value other than #T). + +(define (eval-and subexps) + (if (null? subexps) ; Trivial case: (AND) + #T ; returns #T + (let ((result (eval-1 (car subexps)))) ; else eval first one. + (cond ((null? (cdr subexps)) result) ; Last one, return its value. + ((equal? result #F) #F) ; False, end early. + (else (eval-and (cdr subexps))))))) ; else do the next one. + +The LET here is used so that there is only one recursive call to EVAL-1, +but the program can be written without it, and turns out only to call +EVAL-1 once anyway, even though the call appears in two different places +in the code, because only one of them will be carried out (per invocation +of EVAL-AND, of course). + +(define (eval-and subexps) + (cond ((null? subexps) #T) + ((null? (cdr subexps)) (eval-1 (car subexps))) + ((equal? (eval-1 (car subexps)) #F) #F) + (else (eval-and (cdr subexps))))) + +Note that the first NULL? test is not really a base case; unless the +entire expression given to us was exactly (AND), the second NULL? test +will always become true before the first one does. It's that second +one that's the base case. + +(If we wanted AND always to return either #T or #F, rather than return +the value of the last expression, then we'd leave out the second NULL? +test, and the first one *would* be the base case of the recursion.) + + + +HOMEWORK: + +2.24. (list 1 (list 2 (list 3 4))) + +The printed result is (1 (2 (3 4))). + +The box and pointer diagram (in which XX represents a pair, and +X/ represents a pair whose cdr is the empty list): + +--->XX--->X/ + | | + | | + V V + 1 XX--->X/ + | | + | | + V V + 2 XX--->X/ + | | + | | + V V + 3 4 + + +[NOTE: The use of XX to represent pairs, as above, is a less-readable +form of box-and-pointer diagram, leaving out the boxes, because there's +no "box" character in the ASCII character set. This is okay for +diagrams done on a computer, but when you are asked to *draw* a diagram, +on a midterm exam for example, you should use actual boxes, as in the +text and the reader.] + + +The tree diagram: + + + + / \ + / \ + 1 + + / \ + / \ + 2 + + / \ + / \ + 3 4 + + + +2.26. Finger exercises. Given + +(define x (list 1 2 3)) +(define y (list 4 5 6)) + +> (append x y) +(1 2 3 4 5 6) + +> (cons x y) +((1 2 3) 4 5 6) ;; Equivalent to ((1 2 3) . (4 5 6)) but that's not how + ;; it prints! + +> (list x y) +((1 2 3) (4 5 6)) + + + +2.29 Mobiles. + +Many people find this exercise very difficult. As you'll see, the solutions +are quite small and elegant when you approach the problem properly. The key +is to believe in data abstraction; in this problem some procedures take a +MOBILE as an argument, while others take a BRANCH as an argument. Even though +both mobiles and branches are represented "below the line" as two-element +lists, you won't get confused if you use the selectors consistently instead +of trying to have one procedure that works for both data types. + +(a) Selectors. They give us the constructor + +(define (make-mobile left right) + (list left right)) + +The corresponding selectors have to extract the left and right components +from the constructed list: + +(define (left-branch mobile) + (car mobile)) + +(define (right-branch mobile) + (cadr mobile)) + +Note that the second element of a list is its CADR, not its CDR! +Similarly, the other selectors are + +(define (branch-length branch) + (car branch)) + +(define (branch-structure branch) + (cadr branch)) + + +(b) Total weight: The total weight is the sum of the weights of the +two branches. The weight of a branch may be given explicitly, as a +number, or may be the total-weight of a smaller mobile. + +(define (total-weight mobile) + (+ (branch-weight (left-branch mobile)) + (branch-weight (right-branch mobile)) )) + +(define (branch-weight branch) + (let ((struct (branch-structure branch))) + (if (number? struct) + struct + (total-weight struct) ))) + +The LET isn't entirely necessary, of course; we could just say +(branch-structure branch) three times inside the IF. + + +(c) Predicate for balance. It looks like we're going to need a function +to compute the torque of a branch: + +(define (torque branch) + (* (branch-length branch) + (branch-weight branch) )) + +Here we have used the BRANCH-WEIGHT procedure from part (b) above. Now, +they say a mobile is balanced if two conditions are met: The torques of +its branches must be equal, and its submobiles must be balanced. (If a +branch contains a weight, rather than a submobile, we don't have to check +if it's balanced. This is the base case of the recursion.) + +(define (balanced? mobile) + (and (= (torque (left-branch mobile)) + (torque (right-branch mobile)) ) + (balanced-branch? (left-branch mobile)) + (balanced-branch? (right-branch mobile)) )) + +(define (balanced-branch? branch) + (let ((struct (branch-structure branch))) + (if (number? struct) + #t + (balanced? struct) ))) + +If you find yourself wondering why we aren't checking the sub-sub-mobiles, +the ones two levels down from the one we were asked about originally, then +you're missing the central point of this exercise: We are doing a tree +recursion, and these procedures will check the balance of all the smaller +mobiles no matter how far down in the tree structure. + + +(d) Changing representation. We change the two constructors to use +CONS instead of LIST. The only other required change is in two of +the selectors: + +(define (right-branch mobile) + (cdr mobile)) + +(define (branch-structure branch) + (cdr branch)) + +We're now using CDR instead of CADR because the second component of each +of these data types is stored in the cdr of a pair, rather than in the +second element of a list. Nothing else changes! The procedures we wrote +in parts (b) and (c) don't include any invocations of CDR or CADR or +anything like that; we respected the abstraction barrier, and so nothing +has to change "above the line." + + +2.30 square-tree + +The non-MAP way: + +(define (square-tree tree) + (cond ((null? tree) '()) + ((number? tree) (* tree tree)) + (else (cons (square-tree (car tree)) + (square-tree (cdr tree)))))) + +The MAP way: + +(define (square-tree tree) + (if (number? tree) + (* tree tree) + (map square-tree tree))) + +I'm not saying more about this because we talked about these programs in +lecture. See the lecture notes! But NOTE that what the book calls a "tree" +in this section is what I've called a "deep list," reserving the name "tree" +for an abstract data type. + + +2.31 tree-map + +This, too, can be done both ways: + +(define (tree-map fn tree) + (cond ((null? tree) '()) + ((not (pair? tree)) (fn tree)) + (else (cons (tree-map fn (car tree)) + (tree-map fn (cdr tree)))))) + +(define (tree-map fn tree) + (if (not (pair? tree)) + (fn tree) + (map (lambda (subtree) (tree-map fn subtree)) tree))) + +In both cases I've replaced NUMBER? with (NOT (PAIR? ...)) so that +the leaves of the tree can be symbols as well as numbers. (Obviously +if the underlying function is squaring, then only numbers are +appropriate.) + + +2.32 subsets + +(define (subsets s) + (if (null? s) + (list nil) + (let ((rest (subsets (cdr s)))) + (append rest (map (LAMBDA (SET) (CONS (CAR S) SET)) rest))))) + +Explanation: The subsets of a set can be divided into two categories: +those that include the first element and those that don't. Each of the +former (including the first element) consists of one of the latter +(without the first element) with the first element added. For example, +the subsets of (1 2 3) are + +not including 1: () (2) (3) (2 3) +including 1: (1) (1 2) (1 3) (1 2 3) + +But the "not including 1" ones are exactly the subsets of (2 3), +which is the cdr of the original set. So the LET uses a recursive +call to find those subsets, and we append to them the result of +sticking 1 (the car of the original set) in front of each. + +Note: It's really important to put the recursive call in a LET +argument rather than use two recursive calls, as in + + (append (subsets (cdr s)) + (map (lambda (set) (cons (car s) set)) + (subsets (cdr s)))) + +because that would take Theta(3^n) time, whereas the original version +takes Theta(2^n) time. Both are slow, but that's a big difference. + + +2.36 accumulate-n + +(define (accumulate-n op init seqs) + (if (null? (car seqs)) + nil + (cons + (accumulate op init (MAP CAR SEQS)) + (accumulate-n op init (MAP CDR SEQS))))) + + +2.37 matrices + +(define (matrix-*-vector m v) + (map (LAMBDA (ROW) (DOT-PRODUCT ROW V)) m)) + +(define (transpose mat) + (accumulate-n CONS NIL mat)) + +(define (matrix-*-matrix m n) + (let ((cols (transpose n))) + (map (LAMBDA (ROW) (MATRIX-*-VECTOR COLS ROW)) m))) + +Take a minute and try to appreciate the aesthetic beauty in these vector +and matrix programs. In a conventional approach, matrix multiplication +would involve three nested loops with index variables. These procedures +seem closer to the mathematical idea that a matrix is a first-class +thing in itself, not just an array of numbers. + + +2.38 fold-right vs. fold-left + +> (fold-right / 1 (list 1 2 3)) +1.5 + +This is 1/(2/3). + +> (fold-left / 1 (list 1 2 3)) +166.666666666667e-3 + +This is (1/2)/3, or 1/6. + +> (fold-right list nil (list 1 2 3)) +(1 (2 (3 ()))) + +This is (list 1 (list 2 (list 3 nil))). + +> (fold-left list nil (list 1 2 3)) +(((() 1) 2) 3) + +This is (list (list (list nil 1) 2) 3). + +In each example, notice that the values 1, 2, and 3 occur in left-to-right +order whether we use fold-left or fold-right. What changes is the grouping: + +fold-right: f(1, f(2, f(3, initial))) + +fold-left: f(f(f(initial, 1), 2), 3) + +So the kind of function that will give the same answer with fold-right and +fold-left is an ASSOCIATIVE operator, i.e., one for which + + (a op b) op c = a op (b op c) + + +2.54 Equal? + +(define (equal? a b) + (cond ((and (symbol? a) (symbol? b)) (eq? a b)) + ((or (symbol? a) (symbol? b)) #f) + ((and (number? a) (number? b)) (= a b)) ;; not required but + ((or (number? a) (number? b)) #f) ;; suggested in footnote + ((and (null? a) (null? b)) #t) + ((or (null? a) (null? b)) #f) + ((equal? (car a) (car b)) (equal? (cdr a) (cdr b))) + (else #f))) + +Note: I think this is the cleanest way to write it--the way that's easiest +to read. It's possible to bum a few procedure calls here and there. For +example, the first two cond clauses could be + + ((symbol? a) (eq? a b)) + ((symbol? b) #f) + +on the theory that eq? always returns #f if one argument is a symbol +and the other isn't. Similarly, one could write + + ((null? a) (null? b)) + ((null? b) #f) + +but I'm not sure the saving is worth the potential confusion. + + +Scheme-1 LET: + +I always like to start with the easy parts: + +(define let-exp? (exp-checker 'let)) + +(define (let-parameters exp) (map car (cadr exp))) + +(define (let-value-exps exp) (map cadr (cadr exp))) + +(define (let-body exp) (cddr exp)) + +Now, one way to evaluate a LET expression is to covert it into the +expression it abbreviates, namely an invocation of a lambda-generated +procedure: + +(define (let-to-lambda exp) + (cons (cons 'lambda + (cons (let-parameters exp) + (let-body exp))) + (let-value-exps exp))) + +(define (eval-1 exp) + (cond ... + ((LET-EXP? EXP) (EVAL-1 (LET-TO-LAMBDA EXP))) + ... + (else (error "bad expr: " exp)))) + +Here's an example of how let-to-lambda works: + +STk> (let-to-lambda '(let ((x (+ 2 3)) + (y (* 2 5))) + (+ x y))) +((lambda (x y) (+ x y)) (+ 2 3) (* 2 5)) + + +The other solution would be to evaluate the LET expression directly, +without first translating it: + +(define (eval-1 exp) + (cond ... + ((LET-EXP? EXP) + (EVAL-1 (SUBSTITUTE (LET-BODY EXP) + (LET-PARAMETERS EXP) + (MAP EVAL-1 (LET-VALUE-EXPS EXP)) + '()))) + ... + (else (error "bad expr: " exp)))) + +This is basically stolen from APPLY of a lambda-defined procedure, but +using the selectors for the pieces of a LET expressions, and evaluating +the let value expressions using MAP, as specified in the hint. + + + +Extra for experts: +------------------ + +Huffman coding exercises: + +None of this is particularly hard; it was assigned to illustrate an +interesting application of trees to a real-world problem (compression). + +2.67 + +Here's what SAMPLE-TREE looks like: + +((leaf a 4) + ((leaf b 2) ((leaf d 1) (leaf c 1) (d c) 2) (b d c) 4) + (a b d c) + 8) + +The corresponding codes are + A 0 + B 10 + D 110 + C 111 + +So the sample message (0 1 1 0 0 1 0 1 0 1 1 1 0) is grouped as + + 0 110 0 10 10 111 0 + +which is decoded as (a d a b b c a). + + +2.68 + +Since every node of the tree knows all the symbols in all its children, +we don't have to do a complete tree search; we can look only in the branch +that contains the symbol we want. (This is why the tree was designed with +a SYMBOLS field.) + +(define (encode-symbol symbol tree) + (if (leaf? tree) + (if (equal? symbol (symbol-leaf tree)) + '() + (error "Symbol not in tree:" symbol)) + (if (member symbol (symbols (left-branch tree))) + (cons 0 (encode-symbol symbol (left-branch tree))) + (cons 1 (encode-symbol symbol (right-branch tree)))))) + + +2.69 + +We are given a list of leaves in increasing order of weight. Each leaf +is a tree, so this can also be thought of as a list of trees. We'll +maintain a list of trees in order of weight, but including some non-leaf +trees, until there's only one tree in the list. + +(define (successive-merge set) + (if (null? (cdr set)) ;set is of length 1 + (car set) ;so return the one tree. + (successive-merge + (adjoin-set ;else make a new set + (make-code-tree (car set) (cadr set)) ;making two smallest into one + (cddr set))))) ;leaving out the individuals + + +2.70 + +STk> (define job-tree + (generate-huffman-tree '((a 2) (boom 1) (get 2) (job 2) + (na 16) (sha 3) (yip 9) (wah 1)))) +okay +STk> job-tree +((leaf na 16) + ((leaf yip 9) + (((leaf a 2) + ((leaf wah 1) (leaf boom 1) (wah boom) 2) + (a wah boom) 4) + ((leaf sha 3) ((leaf job 2) (leaf get 2) (job get) 4) (sha job get) 7) + (a wah boom sha job get) 11) + (yip a wah boom sha job get) 20) + (na yip a wah boom sha job get) 36) + +The corresponding encoding is + + NA 0 JOB 11110 + YIP 10 GET 11111 + A 1100 WAH 11010 + SHA 1110 BOOM 11011 + +STk> (encode '(get a job + sha na na na na na na na na + get a job + sha na na na na na na na na + wah yip yip yip yip yip yip yip yip yip + sha boom) + job-tree) +(1 1 1 1 1 1 1 0 0 1 1 1 1 0 + 1 1 1 0 0 0 0 0 0 0 0 0 + 1 1 1 1 1 1 1 0 0 1 1 1 1 0 + 1 1 1 0 0 0 0 0 0 0 0 0 + 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 + 1 1 1 0 1 1 0 1 1) + +There are 84 bits in this encoding. + +A fixed-length encoding would use three bits for each of the eight symbols. +For example: + + NA 000 JOB 100 + YIP 001 GET 101 + A 010 WAH 110 + SHA 011 BOOM 111 + +With this encoding, the 36 words of the song would take 36*3 = 108 bits. +We saved 24 bits, which is 22% of the fixed-length size. This is a decent +but not amazing compression ratio, considering that the example was chosen +to work well with Huffman compression. + +(Bear in mind, though, that in practice we'd have to include some +representation of the coding tree when we send the message to someone, to +allow the receiver to decode it! That's why compression in general isn't +worth it for short messages; there's generally some overhead space required +that's negligible for long messages but important for short ones.) + +For this example, even the three-bit fixed-length encoding is pretty good. +The song lyric is 125 characters (including spaces and newlines), ordinarily +represented in the ASCII code using one eight-bit byte per character, for +a total of 125*8 = 1000 bits. GZIP, the general-purpose compression +program from the Free Software Foundation, compresses this to 62 bytes, +or 496 bits (50% compression). The three-bit and Huffman encodings both do +much better than this, although of course they wouldn't work at all for +data containing anything other than those eight words. + + +2.71 + +If the weights are powers of two, then at each step of the SUCCESSIVE-MERGE +all of the symbols merged so far will weigh less than the next unmerged +symbol. That is, given ((A 1) (B 2) (C 4) (D 8) (E 16)) we get + + ((A 1) (B 2) (C 4) (D 8) (E 16)) + ((AB 3) (C 4) (D 8) (E 16)) + ((ABC 7) (D 8) (E 16)) + ((ABCD 15) (E 16)) + +(leaving out the details of the non-leaf trees to show the big picture). +Therefore, the tree will look like the very imbalanced one in figure 2.17 +on page 158: + + (ABCDE) 31 + / \ + / \ + (ABCD) 15 E 16 + / \ + / \ + (ABC) 7 D 8 + / \ + / \ + (AB) 3 C 4 + / \ + / \ + A 1 B 2 + +The encodings are + + A 0000 B 0001 C 001 D 01 E 1 + +In general, for N symbols, the most frequent takes 1 bit, and the least +frequent takes N-1 bits. + +But don't think that this is a failure of the algorithm, in the way that +the unbalanced binary search tree of figure 2.17 is a worst case! If the +frequencies of use of the symbols really are a sequence of powers of two, +then this encoding will be efficient, since more than half of the symbols +in the text to be encoded are represented with one bit. Altogether +there will be 2^(N-1) one-bit codes, 2^(N-2) two-bit codes, etc., in +this message of length (2^N)-1 symbols. This requires [2^(N+1)]-(N+2) bits +altogether. A fixed-length encoding would take (lg N)*[(2^N)-1] bits. +The exact formulas are complicated, so here are simple approximations: + fixed-length: 2^N * (lg N) + Huffman: 2^N * 2 +On average, each symbol requires (just under) two bits with Huffman coding, +regardless of the value of N. With fixed-length encoding, the number of +bits grows as N grows. And of course the (lg N) has to be rounded up to +the next higher integer, so for N=5, we need three bits per symbol for +fixed-length vs. two per symbol for Huffman. + +(The notation "lg n" means the logarithm to the base 2.) + + +2.72 + +Since only one branch is followed at each step of the encoding, the +number of steps is at worst the depth of the tree. And the time per +step, as the exercise points out, is determined by the call to MEMBER +to check whether the symbol is in the left branch. If there are N +symbols, it's easy to see that the worst case is N^2 time, supposing +the tree is very unbalanced [in 2.71 I said that an unbalanced tree isn't +a problem, but that's in determining the size of the encoded message, not +the time required for the encoding] so its depth is N, and we have to +check at most N symbols at each level. + +In reality, though, it's never that bad. The whole idea of Huffman coding +is that the most often used symbols are near the top of the tree. For the +power-of-two weights of exercise 2.71, the average number of steps to +encode each symbol is 2, so the time is 2N rather than N^2. (The worst-case +time is for the least frequently used symbol, which still takes N^2 time, +but that symbol only occurs once in the entire message!) We could make +a small additional optimization by rewriting ENCODE-SYMBOL to make sure +that at each branch node in the tree it creates, the left branch has fewer +symbols than the right branch. + + +Programming by example: + +Of course many approaches are possible; here's mine: + +(define (regroup pattern) + + ;; my feeble attempt at data abstraction: + ;; regroup0 returns two values in a pair + + (define reg-result cons) + (define reg-function car) + (define reg-minsize cdr) + + ;; Assorted trivial utility routines + + (define (firstn num ls) + (if (= num 0) + '() + (cons (car ls) (firstn (- num 1) (cdr ls))) )) + + (define (too-short? num ls) + (cond ((= num 0) #f) + ((null? ls) #t) + (else (too-short? (- num 1) (cdr ls))) )) + + (define (safe-bfn num ls) + (cond ((null? ls) '()) + ((= num 0) ls) + (else (safe-bfn (- num 1) (cdr ls))) )) + + (define (firstnum pattern) + (if (symbol? pattern) + pattern + (firstnum (car pattern)) )) + + (define (and-all preds) + (cond ((null? preds) #t) + ((car preds) (and-all (cdr preds))) + (else #f) )) + + ;; Okay, here's the real thing: + + ;; There are three kinds of patterns: 1, (1 2), and (1 2 ...). + ;; Regroup0 picks one of three subprocedures for them. + ;; In each case, the return value is a pair (function . min-size) + ;; where "function" is the function that implements the pattern + ;; and "min-size" is the minimum length of a list that can be + ;; given as argument to that function. + + (define (regroup0 pattern) + (cond ((number? pattern) (select pattern)) + ((eq? (last pattern) '...) (infinite (bl pattern))) + (else (finite pattern)) )) + + + ;; If the pattern is a number, the function just selects the NTH element + ;; of its argument. The min-size is N. + + (define (select num) + (reg-result + (cond ((= num 1) car) ; slight optimization + ((= num 2) cadr) + (else (lambda (ls) (list-ref ls (- num 1)))) ) + num)) + +;; If the pattern is a list of patterns without ..., the function + ;; concatenates into a list the results of calling the functions + ;; that we recursively derive from the subpatterns. The min-size + ;; is the largest min-size required for any subpattern. + + (define (finite pattern) + (let ((subgroups (map regroup0 pattern))) + (reg-result + (lambda (ls) (map (lambda (subg) ((reg-function subg) ls)) subgroups)) + (apply max (map reg-minsize subgroups)) ) )) + + ;; Now for the fun part. If the pattern is a list ending with ... then + ;; we have to build a map-like recursive function that sticks the result + ;; of computing a subfunction on the front of a recursive call for some + ;; tail portion of the argument list. There are a few complications: + + ;; The pattern is allowed to give any number of examples of its subpattern. + ;; For instance, ((1 2) ...), ((1 2) (3 4) ...), and ((1 2) (3 4) (5 6) ...) + ;; all specify the same function. But ((1 2) (3 4 5) ...) is different from + ;; those. So we must find the smallest leading sublist of the pattern such + ;; that the rest of the pattern consists of equivalent-but-shifted copies, + ;; where "shifted" means that each number of the copy differs from the + ;; corresponding number of the original by the same amount. (3 4) is a + ;; shifted copy of (1 2) but (3 5) isn't. Once we've found the smallest + ;; appropriate leading sublist, the rest of the pattern is unused, except + ;; as explained in the following paragraph. + + ;; Once we have the pattern for the repeated subfunction, we need to know + ;; how many elements of the argument to chop off for the recursive call. + ;; If the pattern contains only one example of the subfunction, the "cutsize" + ;; is taken to be the same as the min-size for the subfunction. For example, + ;; in the pattern ((1 2) ...) the cutsize is 2 because 2 is the highest + ;; number used. But if there are two or more examples, the cutsize is the + ;; amount of shift between examples (which must be constant if there are + ;; more than two examples), so in ((1 2) (3 4) ...) the cutsize is 2 but in + ;; ((1 2) (2 3) ...) it's 1. In ((1 2) (2 3) (5 6) ...) the shift isn't + ;; constant, so this is taken as one example of a long subpattern rather + ;; than as three examples of a short one. + + ;; Finally, if the subpattern is a single number or list, as in (1 3 ...) + ;; (that's two examples of a one-number pattern) or ((1 2) ...), then we + ;; can cons the result of the subfunction onto the recursive call. But if + ;; the subpattern has more than one element, as in (1 2 4 ...) or + ;; ((1 2) (3 4 5) ...), then we must append the result of the subfunction + ;; onto the recursive call. + + ;; INFINITE does all of this. FINDSIZE returns a pair containing two + ;; values: the number of elements in the smallest-appropriate-leading-sublist + ;; and, if more than one example is given, the shift between them, i.e., the + ;; cutsize. (If only one example is given, #T is returned + ;; in the pair instead of the cutsize.) PARALLEL? checks to see if a + ;; candidate smallest-appropriate-leading-sublist is really appropriate, + ;; i.e., the rest of the pattern consists of equivalent-but-shifted copies. + ;; The return value from PARALLEL? is the amount of shift (the cutsize). + + (define (infinite pattern) + + (define (findsize size len) + + (define (parallel? subpat rest) + (let ((cutsize (- (firstnum rest) + (firstnum subpat) ))) + + (define (par1 togo rest delta) + + (define (par2 this that) + (cond ((and (eq? this '...) (eq? that '...)) #t) + ((or (eq? this '...) (eq? that '...)) #f) + ((and (number? this) (number? that)) + (= delta (- that this))) + ((or (number? this) (number? that)) #f) + ((not (= (length this) (length that))) #f) + (else (and-all (map par2 this that))) )) + + (cond ((null? rest) cutsize) + ((null? togo) (par1 subpat rest (+ delta cutsize))) + ((not (par2 (car togo) (car rest))) #f) + (else (par1 (cdr togo) (cdr rest) delta)) )) + + (par1 subpat rest cutsize) )) + + ;; This is the body of findsize. + (cond ((= size len) (cons size #t)) + ((not (= (remainder len size) 0)) + (findsize (+ size 1) len)) + (else (let ((par (parallel? (firstn size pattern) + (safe-bfn size pattern) ))) + (if par + (cons size par) + (findsize (+ size 1) len) ))) )) + + ;; This is the body of infinite. + (let* ((len (length pattern)) + (fs-val (findsize 1 len)) + (patsize (car fs-val)) + (cutsize (cdr fs-val))) + + (define (make-recursion subpat combiner) + (let ((subgroup (regroup0 subpat))) + (letrec + ((f (lambda (ls) + (if (too-short? (reg-minsize subgroup) ls) + '() + (combiner ((reg-function subgroup) ls) + (f (safe-bfn + (if (number? cutsize) + cutsize + (reg-minsize subgroup)) + ls)) )) ))) + (reg-result f (reg-minsize subgroup)) ))) + + (if (= patsize 1) + (make-recursion (car pattern) cons) + (make-recursion (firstn patsize pattern) append) ) )) + + (reg-function (regroup0 pattern)) ) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week7 b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week7 new file mode 100644 index 0000000..912b506 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week7 @@ -0,0 +1,663 @@ +CS 61A Week 7 solutions + +LAB ASSIGNMENT: + +2.62. Union-set in Theta(n) time. + +The key is to realize the differences between union-set and +intersection-set. The null case for union-set will be different, because if +one of the sets is empty, the result must be the other set. In the element +comparisons, one element will always be added to the result set. So the +expressions with the element will be the same as intersection-set, only with +a cons added. Here's the solution: + +(define (union-set set1 set2) + (cond ((null? set1) set2) + ((null? set2) set1) + (else (let ((x1 (car set1)) (x2 (car set2))) + (cond ((= x1 x2) + (cons x1 (union-set (cdr set1) (cdr set2)))) + ((< x1 x2) + (cons x1 (union-set (cdr set1) set2))) + ((< x2 x1) + (cons x2 (union-set set1 (cdr set2))))))))) + + +Trees on page 156: + +(define tree1 + (adjoin-set 1 + (adjoin-set 5 + (adjoin-set 11 + (adjoin-set 3 + (adjoin-set 9 + (adjoin-set 7 '()))))))) + +(define tree2 + (adjoin-set 11 + (adjoin-set 5 + (adjoin-set 9 + (adjoin-set 1 + (adjoin-set 7 + (adjoin-set 3 '()))))))) + +(define tree3 + (adjoin-set 1 + (adjoin-set 7 + (adjoin-set 11 + (adjoin-set 3 + (adjoin-set 9 + (adjoin-set 5 '()))))))) + +Other orders are possible; the constraint is that each node must be +added before any node below it. So in each case we first adjoin the +root node, then adjoin the children of the root, etc. To make sure +this is clear, here's an alternative way to create tree1: + +(define tree1 + (adjoin-set 11 + (adjoin-set 9 + (adjoin-set 5 + (adjoin-set 1 + (adjoin-set 3 + (adjoin-set 7 '()))))))) + + +2.74 (Insatiable Enterprises): + +(a) Each division will have a private get-record operation, so each +division's package will look like this: + +(define (install-research-division) + ... + (define (get-record employee file) + ...) + ... + (put 'get-record 'research get-record) + ...) + +Then we can write a global get-record procedure like this: + +(define (get-record employee division-file) + ((get 'get-record (type-tag division-file)) + employee + (contents division-file))) + +It'll be invoked, for example, like this: + (get-record '(Alan Perlis) research-personnel-list) + +For this to work, each division's file must include a type tag +specifying which division it is. + +If, for example, a particular division file is a sequence of +records, one per employee, and if the employee name is the CAR of +each record, then that division can use ASSOC as its get-record +procedure, by saying + + (put 'get-record 'manufacturing assoc) + +in its package-installation procedure. + + +(b) The salary field might be in a different place in each +division's files, so we have to use the right selector based +on the division tag. + +(define (get-salary record) + (apply-generic 'salary record)) + +Each division's package must include a salary selector, comparable +to the magnitude selectors in the complex number example. + +Why did I use GET directly in (a) but apply-generic in (b)? In the +case of get-salary, the argument is a type-tagged datum. But in the +case of get-record, there are two arguments, only one of which (the +division file) has a type tag. The employee name, I'm assuming, +is not tagged. + + +(c) Find an employee in any division + +(define (find-employee-record employee divisions) + (cond ((null? divisions) (error "No such employee")) + ((get-record employee (car divisions))) + (else (find-employee-record employee (cdr divisions))))) + +This uses the feature that a cond clause with only one expression +returns the value of that expression if it's not false. + + +(d) To add a new division, you must create a package for the division, +make sure the division's personnel file is tagged with the division name, +and add the division's file to the list of files used as argument to +find-employee-record. + + +4. Scheme-1 stuff. + +(a) ((lambda (x) (+ x 3)) 5) + +Here's how Scheme-1 handles procedure calls (this is a COND clause +inside EVAL-1): + + ((pair? exp) (apply-1 (eval-1 (car exp)) ; eval the operator + (map eval-1 (cdr exp)))); eval the args + +The expression we're given is a procedure call, in which the procedure +(lambda (x) (+ x 3)) is called with the argument 5. + +So the COND clause ends up, in effect, doing this: + + (apply-1 (eval-1 '(lambda (x) (+ x 3))) (map eval-1 '(5))) + +Both lambda expressions and numbers are self-evaluating in Scheme-1, +so after the calls to EVAL-1, we are effectively saying + + (apply-1 '(lambda (x) (+ x 3)) '(5)) + +APPLY-1 will substitute 5 for X in the body of the +lambda, giving the expression (+ 5 3), and calls EVAL-1 +with that expression as argument. This, too, is a procedure call. +EVAL-1 calls itself recursively to evaluate +the symbol + and the numbers 5 and 3. The numbers are self-evaluating; +EVAL-1 evaluates symbols by using STk's EVAL, so it gets the primitive +addition procedure. Then it calls APPLY-1 with that procedure and +the list (5 3) as its arguments. APPLY-1 recognizes that the addition +procedure is primitive, so it calls STk's APPLY, which does the +actual addition. + + +(b) As another example, here's FILTER: + +((lambda (f seq) + ((lambda (filter) (filter filter pred seq)) + (lambda (filter pred seq) + (if (null? seq) + '() + (if (pred (car seq)) + (cons (car seq) (filter filter pred (cdr seq))) + (filter filter pred (cdr seq))))))) + even? + '(5 77 86 42 9 15 8)) + + +(c) Why doesn't STk's map work in Scheme-1? It works for primitives: + + Scheme-1: (map first '(the rain in spain)) + (t r i s) + +but not for lambda-defined procedures: + + Scheme-1: (map (lambda (x) (first x)) '(the rain in spain)) + Error: bad procedure: (lambda (x) (first x)) + +This problem illustrates the complexity of having two Scheme interpreters +coexisting, STk and Scheme-1. In Scheme-1, lambda expressions are +self-evaluating: + + Scheme-1: (lambda (x) (first x)) + (lambda (x) (first x)) + +But in STk, lambda expressions evaluate to procedures, which are a different +kind of thing: + + STk> (lambda (x) (first x)) + #[closure arglist=(x) 40179938] + +STk's MAP function requires an *STk* procedure as its argument, not a Scheme-1 +procedure! Scheme-1 uses STk's primitives as its primitives, so MAP is happy +with them. But a Scheme-1 lambda-defined procedure just isn't the same thing +as an STk lambda-defined procedure. + + +HOMEWORK: + +2.75 Message-passing version of make-from-mag-ang : + + (define (make-from-mag-ang r a) + (lambda (mesg) + (cond ((eq? mesg 'real-part) (* r (cos a))) + ((eq? mesg 'imag-part) (* r (sin a))) + ((eq? mesg 'magnitude) r) + ((eq? mesg 'angle) a) + (else + (error "Unknown op -- Polar form number" mesg)) )) ) + +Note that the formal parameter names X and Y that the book uses in +make-from-real-imag (p. 186) are relatively sensible because they are +indeed the x and y coordinates of a point in the plane. X and Y +are confusing as names for polar coordinates! I used R and A, for +Radius and Angle, but MAGNITUDE and ANGLE would be okay, too. + +I could have used an internal definition, as they do, instead of +lambda; the two forms are equivalent. + + +2.76 Compare conventional, data-directed, and message-passing. + +To add a new operator: + +First we must write a low-level procedure for that operator for each type, +like (magnitude-rectangular) and (magnitude-polar) if we're adding the +operator magnitude. (If we're using a package system, we can add a +local definition of MAGNITUDE to each package.) Then... + +For conventional style, we write a generic operator procedure +(magnitude) that invokes the appropriate lower-level procedure +depending on the type of its operand. + +For data-directed style, we use PUT to insert entries in the +procedure matrix for each low-level procedure; there is no new +high-level procedure required. + +For message-passing style, we modify each of the type dispatch +procedures to accept a new message corresponding to the new +operator, dispatching to the appropriate low-level procedure. + +To add a new type: + +First we must write a low-level procedure for that type for each +operator, like (real-part-polar), (imag-part-polar), +(magnitude-polar), and (angle-polar) if we're inventing the +polar type. (If we're using a package system, we can create +a new POLAR package with local definitions of REAL-PART, etc.) +Then... + +For conventional style, we modify each of the generic operator +procedures (real-part), (imaginary-part), etc. to know about the +new type, dispatching to the appropriate lower-level procedures. + +For data-directed style, we use PUT to insert entries, as for +a new operator. + +For message-passing style, we write a new type dispatch procedure +that accepts messages 'real-part, 'imag-part, etc. and dispatches +to the appropriate lower-level procedure. + +Which is most appropriate: + +Conventional style is certainly INappropriate when many new types +will be invented, because lots of existing procedures need to be +modified. + +Similarly, message-passing is INappropriate when many new operators +will be invented and applied to existing types. + +Data-directed programming is a possible solution in either case, and is +probably the best choice if both new types and new operators are likely. +It's also a good choice if the number of types or operators is large in +the first place, whether or not new ones will be invented, because it +minimizes the total number of procedures needed (leaving out the generic +dispatch procedures for each type or operator) and thereby reduces the +chances for error. + +As you'll see in chapter 3, message-passing style takes on new importance +when a data object needs to keep track of local state. But you'll see +later in the chapter (mutable data) that there are other solutions to +the local state problem, too. + +Message-passing is also sometimes sensible when there are lots of types, +each of which has its own separate set of operators with unique names, so +that a data-directed array would be mostly empty. + + +2.77 + +Starting with + + (magnitude '(complex rectangular 3 . 4)) + +we call MAGNITUDE giving + + (apply-generic 'magnitude '(complex rectangular 3 . 4)) + +The apply-generic function (see pg. 184) just uses GET to find the +entry corresponding to 'magnitude and '(complex), and gets the same +function MAGNITUDE that we invoked in the first place. This +time, however, the argument to MAGNITUDE is (CONTENTS OBJ) +so that the first type flag (COMPLEX) is removed. In other +words, we end up calling + + (magnitude '(rectangular 3 . 4)) + +Calling the function MAGNITUDE again, this becomes : + + (apply-generic 'magnitude '(rectangular 3 . 4)) + +The apply-generic function now looks up the entry for 'magnitude and +'(rectangular) and finds the MAGNITUDE function from the RECTANGULAR +package; that function is called with '(3 . 4) as its argument, which +yields the final answer... (sqrt (square 3) (square 4)) ==> 5 + + +2.79 equ? + +(define (equ? a b) + (apply-generic 'equ? a b)) + +In the scheme-number package: + + (put 'equ? '(scheme-number scheme-number) =) + +In the rational package: + + (define (equ-rat? x y) + (and (= (numer x) (numer y)) + (= (denom x) (denom y)))) + ... + (put 'equ? '(rational rational) equ-rat?) + +In the complex package: + + (define (equ-complex? x y) + (and (= (real-part x) (real-part y)) + (= (imag-part x) (imag-part y)))) + ... + (put 'equ? '(complex complex) equ-complex?) + +This technique has the advantage that you can compare for equality +a complex number in rectangular form with a complex number in polar +form, since the latter is implicitly converted to rectangular by +equ-complex?. But it has the disadvantage that when comparing +two complex numbers in polar form, it needlessly does the arithmetic +to convert them both to rectangular coordinates. (On the other +hand, if you want a polar-specific version of equ?, you have to +remember that the angles can differ by a multiple of 2*pi and the +numbers are still equal!) + + +2.80 =zero? + +(define (=zero? num) + (apply-generic '=zero? num)) + +In the scheme-number package: + + (put '=zero? '(scheme-number) zero?) + +In the rational package: + + (put '=zero? '(rational) + (lambda (n) (equ? n (make-rational 0 1)))) + +In the complex package: + + (put '=zero? '(complex) + (lambda (n) (equ? n (make-complex-from-real-imag 0 0)))) + +Of course I could have used internal defines instead of lambda +here. And of course once we invent raising it gets even easier; +I can just say + +(define (=zero? num) + (equ? num (make-scheme-number 0))) + +because then mixed-type equ? calls will be okay. + + +2.81 Louis messes up again + +(a) This will result in an infinite loop. Suppose we have two +complex numbers c1 and c2, and we try (exp c1 c2). Apply-generic +will end up trying to compute + + (apply-generic 'exp (complex->complex c1) c2) + +but this is the same as + + (apply-generic 'exp c1 c2) + +which is what we started with. + + +(b) Louis is wrong. If we have a complex exponentiation procedure +and we PUT it into the table, then apply-generic won't try to convert +the complex arguments. And if we don't have a complex exponentiation +procedure, then apply-generic correctly gives an error message; there's +nothing better it can do. + +(Once we invent the idea of raising, it would be possible to modify +apply-generic so that if it can't find a function for the given +type(s), it tries raising the operand(s) just in case the operation +is implemented for a more general type. For instance, if we try to +apply EXP to two rational numbers, apply-generic could raise them to +real and then the version of EXP for the scheme-number type will work. +But it's tricky to get this right, especially when there are two +operands -- should we raise one of them, or both?) + +(c) Nevertheless, here's how it could be done: + + (let ((type1 (car type-tags)) + (type2 (cadr type-tags)) + (a1 (car args)) + (a2 (cadr args))) + (IF (EQ? TYPE1 TYPE2) + (ERROR "CAN'T COERCE SAME TYPES" TYPE1) + (let ((t1->t2 (get-coercion type1 type2)) + (t2->t1 (get-coercion type2 type1))) + ...))) + + +2.83 Implementation of "raise" operators taking numbers to the next +level "up" in the hierarchy -- i.e. the next more general type: + + integer -> rational -> real -> complex + +The package system as presented in the text has to be modified a little, +because now instead of having a scheme-number type we want two separate +types integer and real. So start by imagining we have two separate +packages, one for integer and one for real. + +In each package we need an operation to raise that kind of number +to the next type up: + +In the integer package: + + (define (integer->rational int) + (make-rational int 1)) + (put 'raise '(integer) integer->rational) + +In the rational package: + + (define (rational->real rat) + (make-real (/ (numer rat) (denom rat)))) + (put 'raise '(rational) rational->real) + +In the real package: + + (define (real->complex Real) + (make-complex-from-real-imag real 0)) + (put 'raise '(real) real->complex) + +And then we can make this global definition: + +(define (raise num) (apply-generic 'raise num)) + +If you want to keep the Scheme-number package, you need a raise method +that distinguishes integers from non-integers internally, which sort of +goes against the whole idea of centralizing the type checking: + + (define (scheme-number->something num) + (if (integer? num) + (make-rational num 1) + (make-complex-from-real-imag num 0))) + + (put 'raise '(scheme-number) scheme-number->something) + + + +Scheme-1 MAP: + +We're writing a defined procedure in STk that will be a primitive +procedure for Scheme-1. So we get to use all the features of STk, +but we have to be sure to handle Scheme-1's defined procedures. +(See this week's lab, above, problem 4c.) + +(define (map-1 fn seq) + (if (null? seq) + '() + (cons (APPLY-1 FN (LIST (CAR SEQ))) + (map-1 fn (cdr seq))))) + +The part in capital letters is the only difference between map-1 and the +ordinary definition of map. We can't just say (FN (CAR SEQ)) the way map +does, because FN might not fit STk's idea of a function, and our procedure is +running in STk, even though it provides a primitive for Scheme-1. + +You could make this more complicated by testing for primitive vs. defined +Scheme-1 procedures. For primitives you could say (FN (CAR SEQ)). But +since APPLY-1 is happy to accept either a primitive or a lambda expression, +there's no reason not to use it for both. + + +SCHEME-1 LET: + +Here's what a LET expression looks like: + + (LET ((name1 value1) (name2 value2) ...) body) + +A good starting point is to write selectors to extract the pieces. + +(define let-exp? (exp-checker 'let)) + +(define (let-names exp) + (map car (cadr exp)) + +(define (let-values exp) + (map cadr (cadr exp)) + +(define let-body caddr) + +As in last week's lab exercise, we have to add a clause to the COND in EVAL-1: + +(define (eval-1 exp) + (cond ((constant? exp) exp) + ((symbol? exp) (error "Free variable: " exp)) + ((quote-exp? exp) (cadr exp)) + ((if-exp? exp) + (if (eval-1 (cadr exp)) + (eval-1 (caddr exp)) + (eval-1 (cadddr exp)))) + ((lambda-exp? exp) exp) + ((and-exp? exp) (eval-and (cdr exp))) ;; added in lab + ((LET-EXP? EXP) (EVAL-LET EXP)) ;; ADDED + ((pair? exp) (apply-1 (car exp) + (map eval-1 (cdr exp)))) + (else (error "bad expr: " exp)))) + +We learned in week 2 that a LET is really a lambda combined with a +procedure call, and one way we can handle LET expressions is just to +rearrange the text to get + + ( (LAMBDA (name1 name2 ...) body) value1 value2 ... ) + +(define (eval-let exp) + (eval-1 (cons (list 'lambda (let-names exp) (let-body exp)) + (let-values exp)))) + +Isn't that elegant? It's certainly not much code. You might not like +the idea of constructing an expression just so we can tear it back down +into its pieces for evaluation, so instead you might want to do the +evaluation directly in terms of the meaning, which is to APPLY an +implicit procedure to arguments: + +(define (eval-let exp) + (apply-1 (list 'lambda (let-names exp) (let-body exp)) + (map eval-1 (let-values exp)))) + +We still end up constructing the lambda expression, because in this +interpreter, a procedure is represented as the expression that created +it. (We'll see later that real Scheme interpreters have to represent +procedures a little differently.) But we don't construct the procedure +invocation as an expression; instead we call apply-1, and we also +call eval-1 for each argument subexpression. + + + +Extra for experts: + +First of all, there's no reason this shouldn't work for anonymous +procedures too... + +(define (inferred-types def) + (cond ((eq? (car def) 'define) + (inf-typ (cdadr def) (caddr def))) + ((eq? (car def) 'lambda) + (inf-typ (cadr def) (caddr def))) + (else (error "not a definition")))) + +Then the key point is that this is a tree recursion. For an expression +such as (append (a b) c '(b c)) we have to note that C is a list, but +we also have to process the subexpression (a b) to discover that A is +a procedure. + +All of the procedures in this program return an association list as +their result. We start by creating a list of the form + + ((a ?) (b ?) (c ?) (d ?) (e ?) (f ?)) + +and then create modified versions as we learn more about the types. + +(define (inf-typ params body) + (inf-typ-helper (map (lambda (name) (list name '?)) params) body)) + +(define (inf-typ-helper alist body) + (cond ((not (pair? body)) alist) + ((assoc (car body) alist) + (inf-typ-seq (typ-subst (car body) 'procedure alist) (cdr body))) + ((eq? (car body) 'map) (inf-map alist body 'list)) + ((eq? (car body) 'every) (inf-map alist body 'sentence-or-word)) + ((eq? (car body) 'member) (typ-subst (caddr body) 'list alist)) + ((memq (car body) '(+ - max min)) (seq-subst (cdr body) 'number alist)) + ((memq (car body) '(append car cdr)) (seq-subst (cdr body) 'list alist)) + ((memq (car body) '(first butfirst bf sentence se member?)) + (seq-subst (cdr body) 'sentence-or-word alist)) + ((eq? (car body) 'quote) alist) + ((eq? (car body) 'lambda) (inf-lambda alist body)) + (else (inf-typ-seq alist (cdr body))))) + +(define (typ-subst name type alist) + (cond ((null? alist) '()) + ((eq? (caar alist) name) + (cons (list name + (if (or (eq? (cadar alist) '?) + (eq? (cadar alist) type)) + type + 'x)) + (cdr alist))) + (else (cons (car alist) (typ-subst name type (cdr alist)))))) + +(define (inf-typ-seq alist seq) + (if (null? seq) + alist + (inf-typ-seq (inf-typ-helper alist (car seq)) (cdr seq)))) + +(define (inf-map alist body type) + (if (pair? (cadr body)) + (inf-typ-helper (typ-subst (caddr body) type alist) + (cadr body)) + (typ-subst (cadr body) 'procedure (typ-subst (caddr body) type alist)))) + +(define (seq-subst seq type alist) + (cond ((null? seq) alist) + ((pair? (car seq)) + (seq-subst (cdr seq) type (inf-typ-helper alist (car seq)))) + (else (seq-subst (cdr seq) type (typ-subst (car seq) type alist))))) + +(define (inf-lambda alist exp) + ((repeated cdr (length (cadr exp))) + (inf-typ-helper (append (map (lambda (name) (list name '?)) (cadr exp)) + alist) + (caddr exp)))) + + + +Note -- the check for lambda in inf-typ-helper is meant to handle cases +like the following: + +> (inferred-types + '(lambda (a b) (map (lambda (a) (append a a)) b))) +((a ?) (b list)) + +The (append a a) inside the inner lambda does NOT tell us anything +about the parameter A of the outer lambda! diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week9 b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week9 new file mode 100644 index 0000000..f5489e8 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Solutions/week9 @@ -0,0 +1,570 @@ +CS 61A -- Week 9 solutions + +LAB ACTIVITIES: + +1. Use a LET to keep both initial and current balance + +(define (make-account init-amount) + (let ((BALANCE INIT-AMOUNT)) ;;; This is the change. + (define (withdraw amount) + (set! balance (- balance amount)) balance) + (define (deposit amount) + (set! balance (+ balance amount)) balance) + (define (dispatch msg) + (cond + ((eq? msg 'withdraw) withdraw) + ((eq? msg 'deposit) deposit))) + dispatch)) + + +2. Add messages to read those variables. + +(define (make-account init-amount) + (let ((balance init-amount)) + (define (withdraw amount) + (set! balance (- balance amount)) balance) + (define (deposit amount) + (set! balance (+ balance amount)) balance) + (define (dispatch msg) + (cond + ((eq? msg 'withdraw) withdraw) + ((eq? msg 'deposit) deposit) + ((EQ? MSG 'BALANCE) BALANCE) ;; two lines added here + ((EQ? MSG 'INIT-BALANCE) INIT-AMOUNT))) + dispatch)) + + +3. Add transaction history. + +(define (make-account init-amount) + (let ((balance init-amount) + (TRANSACTIONS '())) ;; add local state var + (define (withdraw amount) + (SET! TRANSACTIONS (APPEND TRANSACTIONS + (LIST (LIST 'WITHDRAW AMOUNT)))) ;; update + (set! balance (- balance amount)) balance) + (define (deposit amount) + (SET! TRANSACTIONS (APPEND TRANSACTIONS + (LIST (LIST 'DEPOSIT AMOUNT)))) ;; update + (set! balance (+ balance amount)) balance) + (define (dispatch msg) + (cond + ((eq? msg 'withdraw) withdraw) + ((eq? msg 'deposit) deposit) + ((eq? msg 'balance) balance) + ((eq? msg 'init-balance) init-amount) + ((EQ? MSG 'TRANSACTIONS) TRANSACTIONS))) ;; message to examine it + dispatch)) + + +4. Why substitution doesn't work. + +(plus1 5) becomes + +(set! 5 (+ 5 1)) +5 + +The first line (the SET!) is syntactically wrong; "5" isn't a variable +and it doesn't make sense to substitute into an unevaluated part of a +special form. + +The second line (returning the value 5) is syntactically okay but +gives the wrong answer; it ignores the fact that the SET! was supposed +to change the result. + + +HOMEWORK: + +3.3 Accounts with passwords + +(define (make-account balance password) + (define (withdraw amount) ; Starting here exactly as in p. 223 + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (define (dispatch pw m) ; Starting here different because of pw + (cond ((not (eq? pw password)) + (lambda (x) "Incorrect password")) + ((eq? m 'withdraw) withdraw) ; Now the same again + ((eq? m 'deposit) deposit) + (else (error "Unknown request -- MAKE-ACCOUNT" + m)))) + dispatch) + +The big question here is why withdraw can get away with returning + "Insufficient funds" +while dispatch has to return this complicated + (lambda (x) "Incorrect password") +The answer is that ordinarily the result returned by withdraw is supposed +to be a number, which is just printed. In case of an error, withdraw can +return a string instead, and that string will just get printed. But +dispatch is ordinarily supposed to return a PROCEDURE. In the example + ((acc 'some-other-password 'deposit) 50) +if dispatch just returned the string, it would be as if we'd typed + ("Incorrect password" 50) +which makes no sense. Instead this version is as if we typed + ((lambda (x) "Incorrect password") 50) +which does, as desired, print the string. + +A simpler solution would be to say (error "Incorrect password") because +the ERROR primitive stops the computation and returns to toplevel after +printing its argument(s). But you should understand the version above! + + +3.4 call-the-cops + +(define (make-account balance password) + (define error-count 0) ; THIS LINE ADDED + (define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (define (dispatch pw m) + (cond ((eq? pw password) ; REARRANGED STARTING HERE + (set! error-count 0) + (cond ((eq? m 'withdraw) withdraw) + ((eq? m 'deposit) deposit) + (else (error "Unknown request -- MAKE-ACCOUNT" + m)) )) + (else + (set! error-count (+ error-count 1)) + (if (> error-count 7) (call-the-cops)) + (lambda (x) "Incorrect password") ))) + dispatch) + +In this version, call-the-cops will be invoked before the dispatch procedure +goes on to return the nameless procedure that will, eventually, be invoked and +print the string "Incorrect password", so whatever call-the-cops prints will +appear before that message. If you'd like it to appear instead of the string, +change the last few lines to + + (lambda (x) + (if (> error-count 7) + (call-the-cops) + "Incorrect password")) + + +3.7 Joint accounts + +What we want here is a new dispatch procedure that has access to the same +environment frame containing the balance of the original account. You could +imagine a complicated scheme in which we teach make-account's dispatch +procedure a new message, make-joint, such that + ((acc 'old-password 'make-joint) 'new-password) +will return a new dispatch procedure in a new frame with its own password +binding but inheriting acc's balance binding. This can work, and we'll +do it later in this solution, but it's a little tricky because you have to +avoid the problem of needing to write a complete dispatch procedure within +a cond clause in the dispatch procedure! + +Instead, one thing to do is to create a new function that invokes f from +within a prepared frame. + +Here is a first, simple version that does almost what we want: + +(define (make-joint old-acc old-pw new-pw) + (lambda (pw m) + (if (eq? pw new-pw) + (old-acc old-pw m) + (lambda (x) "Incorrect password")))) + +It's important to understand how easy this is if we're willing to treat +the old account procedure as data usable in this new make-joint procedure. +This version works fine, with proper password protection, but it differs +in one small detail from what the problem asked us to do. I'd be very happy +with this version of the program, but for those of you who are sticklers for +detail, here's a discussion of the problem and a revised solution. + +Suppose you don't know the password of the old account but you try to make a +joint-account by guessing. Make-joint will return a procedure, without +complaining, and it isn't until you try to use that returned procedure that +the old account will complain about getting the wrong password. The problem +says, "The second argument must match the password with which the account +was defined in order for the make-joint operation to proceed." They want us +to catch a password error as soon as make-joint itself is invoked. To do +this, make-joint must be able to ask old-acc whether or not the given old-pw +is correct. So we'd like a verify-password message so that + +==> (peter-acc 'open-sesame 'verify-password) +#t +==> (peter-acc 'garply 'verify-password) +#f + +Given such a facility in make-account, we can write make-joint this way: + +(define (make-joint old-acc old-pw new-pw) + (if (old-acc old-pw 'verify-password) + (lambda (pw m) + (if (eq? pw new-pw) + (old-acc old-pw m) + (lambda (x) "Incorrect password"))) + (display "Incorrect password for old account"))) + +This approach only makes sense if we use (display ...) to signal the error. +We can't just return a string because the string won't be printed; it'll +be bound to a symbol like paul-acc as that symbol's value. Later, when we +try to invoke paul-acc as a procedure, we'll get a "Application of +non-procedure object" error message. We also can't just do the trick of +returning (lambda (x) "string"). That won't blow up our program, but again +the printing of the error message won't happen until paul-acc is applied to +something. If we wanted to wait until then to see the error message, we +could just use my first solution. So we're stuck with explicitly printing +the message. What gets returned is whatever print returns; if we ignore +the message and try to invoke paul-acc later, it'll blow up. + +To make this work we need to invent the verify-password message: + +(define (make-account balance password) + (define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (define (dispatch pw m) + (cond ((eq? m 'verify-password) ; This clause is new + (eq? pw password)) + ((not (eq? pw password)) + (lambda (x) "Incorrect password")) + ((eq? m 'withdraw) withdraw) + ((eq? m 'deposit) deposit) + (else (error "Unknown request -- MAKE-ACCOUNT" + m)))) + dispatch) + +Note the order of the cond clauses in dispatch. The verify-password message +is not considered an error even if the password doesn't match; it just returns +#f in that case. So we first check for that message, then if not we check +for an incorrect password, then if not we check for the other messages. + +By the way, we could avoid inventing the new verify-password method by using +the existing messages in an unusual way. Instead of + +(define (make-joint old-acc old-pw new-pw) + (if (old-acc old-pw 'verify-password) + ...)) + +we could say + +(define (make-joint old-acc old-pw new-pw) + (if (NUMBER? ((OLD-ACC OLD-PW 'DEPOSIT) 0)) + ...) + + +If you want to add a make-joint message to the account dispatch procedure, +the corresponding method has to return a new dispatch procedure. This is +the approach that I rejected earlier as too complicated, but it's not bad +once you understand how to do it: instead of having a + (define (dispatch pw m) ...) +so that there is one fixed dispatch procedure, you do the object-oriented +trick of allowing multiple dispatch procedure objects, so we have a +higher-order procedure that makes dispatch procedures. Every time a new +person is added to the account, we make a new dispatch procedure for that +person, with a new password. Even the first user of the account gets a +dispatch procedure through this mechanism, as you'll see below: + +(define (make-account balance password) + (define (withdraw amount) + (if (>= balance amount) + (begin (set! balance (- balance amount)) + balance) + "Insufficient funds")) + (define (deposit amount) + (set! balance (+ balance amount)) + balance) + (define (new-dispatch new-pw) ; This is new. We have a dispatch maker + (lambda (pw m) ; instead of just one dispatch procedure. + (cond ((not (eq? pw new-pw)) + (lambda (x) "Incorrect password")) + ((eq? m 'withdraw) withdraw) + ((eq? m 'deposit) deposit) + ((eq? m 'make-joint) new-dispatch) + (else (error "Unknown request -- MAKE-ACCOUNT" + m))))) + (new-dispatch password)) ; We have to make a dispatcher the first time too. + + +3.8 Procedure for which order of evaluation of args matters + +The procedure f will be invoked twice. We want the results to depend on the +past invocation history. That is, (f 1) should have a different value +depending on whether or not f has been invoked before. + +Given the particular values we're supposed to produce, I think the easiest +thing is if (f 0) is always 0, while (f 1) is 1 if (f 0) hasn't been invoked +or 0 if it has. + +(define f + (let ((history 1)) + (lambda (x) + (set! history (* history x)) + history))) + +If we evaluate (f 1) first, then history has the value 1, and the result (and +new value of history) is (* 1 1) which is 1. On the other hand, if we +evaluate (f 0) first, that sets history to 0, so a later (f 1) returns +(* 0 1) which is 0. + +The above solution only works the first time we try + (+ (f 0) (f 1)) +however. After the first time, (f x) always returns 0 for any x. Here's +another solution that doesn't have that defect: + +(define f + (let ((invocations 0)) + (lambda (x) + (set! invocations (+ invocations 1)) + (cond ((= x 0) 0) + ((even? invocations) 0) + (else 1))))) + +Many other possible solutions are equally good. + + +3.10 Let vs. parameter + + args: initial-amount + --> body: (let ...) +global env: | +|------------------------------| | +| make-withdraw: --------------------> (function) --> global env +| | +| W1: -- (this pointer added later) -> (function A below) +| | +| W2: -- (this one added later too) -> (function B below) +|------------------------------| + +The first invocation of make-withdraw creates a frame + +E1: +|--------------------| +|initial-amount: 100 |---> global env +|--------------------| + +and in that frame evaluates the let, which makes an unnamed function + + (function) --> E1 + | + | args: balance + ---> body: (lambda (amount) ...) + +then the same let applies the unnamed function to the argument expression +initial-amount. We are still in frame E1 so initial-amount has value 100. +To apply the function we make a new frame: + +E2: +|--------------------| +|balance: 100 |---> E1 +|--------------------| + +Then in that frame we evaluate the body, the lambda expression: + + (function A) --> E2 + | + | args: amount + ---> body: (if ...) + +Then the outer define makes global W1 point to this function. + +Now we do (W1 50). This creates a frame: + +E3: +|------------| +|amount: 50 |---> E2 +|------------| + +Frame E3 points to E2 because function A (i.e. W1) points to E2. +Within frame E3 we evaluate the body of function A, the (if ...). +During this evaluation the symbol AMOUNT is bound in E3, while +BALANCE is bound in E2. So the set! changes BALANCE in E2 from +100 to 50. + +Now we make W2, creating two new frames in the process: + +E4: +|--------------------| +|initial-amount: 100 |---> global env +|--------------------| + + (function) --> E4 + | + | args: balance + ---> body: (lambda (amount) ...) + +E5: +|--------------------| +|balance: 100 |---> E4 +|--------------------| + + (function B) --> E5 + | + | args: amount + ---> body: (if ...) + +Then the outer define makes global W2 point to this function. + +Summary: the two versions of make-withdraw create objects with the same +behavior because in each case the functions A and B are defined within +individual frames that bind BALANCE. The environment structures differ +because this new version has, for each account, an extra frame containing +the binding for initial-amount. + + + +================================================== + + + +3.11 Message-passing example + +global env: +|------------------------------| +| make-account: --------------------> (function) ---> global env +| | +| acc: --(pointer added later)------> (function A below) +|------------------------------| + +When we (define acc (make-account 50)), a new frame is created that +includes both make-account's parameters (balance) and its internal +definitions (withdraw, deposit, dispatch): + +E1: +|------------------------------| +| balance: 50 |----> global env +| | +| withdraw: -------------------------> (function W) ---> E1 +| | +| deposit: --------------------------> (function D) ---> E1 +| | +| dispatch: -------------------------> (function A) ---> E1 +|------------------------------| + +(The arrow I have in the top right corner has nothing to do with the +binding of BALANCE; it's the back pointer for this frame.) + +At this point the symbol ACC is bound, in the global environment, to +function A. + +Now we do ((acc 'deposit) 40). + +E2: +|--------------------| +| m: deposit |----> E1 +|--------------------| + +The above results from evaluating (acc 'deposit), whose returned value is +function D above. + +E3: +|--------------------| +| amount: 40 |----> E1 +|--------------------| + +The above frame results from (D 40) [so to speak]. Note that its back +pointer points to E1, not E2, because that's what D points to. Now we +evaluate the body of D, which includes (set! balance (+ balance amount)) +The value for AMOUNT comes from E3, and the value for BALANCE from E1. +The set! changes the value to which BALANCE is bound in E1, from 50 to 90. + +((acc 'withdraw) 60) + +similarly creates two new frames: + +E4: +|--------------------| +| m: withdraw |----> E1 +|--------------------| + +E5: +|--------------------| +| amount: 60 |----> E1 +|--------------------| + +Again BALANCE is changed in E1, which is where ACC's local state is kept. +If we define another account ACC2, we'll produce a new frame E6 that has +the same symbols bound that E1 does, but bound to different things. The +only shared environment frame between ACC1 and ACC2 is the global environment. +The functions in E6 are *not* the same as the functions D, W, and A in E1. +(They may, depending on the implementation, have the same list structure +as their bodies, but they don't have the same environment pointers.) + + +Extra for experts: + +First the easy part, generating unique symbols: + +(define gensym + (let ((number 0)) + (lambda () + (set! number (+ number 1)) + (word 'g number)))) + +Each call to GENSYM generates a new symbol of the form G1, G2, etc. +(This isn't a perfect solution; what if there is a global variable +named G1 that's used within the argument expression? But we won't worry +about that for now -- there are solutions, but they're pretty complicated.) + +The renaming procedure will need to keep an association list with +entries converting symbols in the argument expression to gensymmed symbols. + +The problem says that all *local* variables are to be renamed. Symbols +that aren't bound within this expression (such as names of primitive +procedures!) will remain unchanged in the result. + +(define (unique-rename exp) + (define (lookup sym alist) ; find replacement symbol + (let ((entry (assoc sym alist))) + (if entry + (cdr entry) + sym))) ; not in alist, keep original + + (define (make-newnames vars) ; make (old . new) pairs for lambda + (map (lambda (var) (cons var (gensym))) vars)) + + (define (help exp alist) + (cond ((symbol? exp) (lookup sym alist)) + ((atom? exp) exp) ; self-evaluating + ((equal? (car exp) 'lambda) + (let ((newnames (make-newnames (cadr exp)))) + (let ((newalist (append newnames alist))) + (cons 'lambda + (cons (map cdr newalist) + (map (lambda (subexp) (help subexp newalist)) + (cddr exp))))))) + (else (map (lambda (subexp) (help subexp alist)) exp)))) + (help exp '())) + +There are four cases in the COND: +1. A symbol is replaced by its gensym equivalent. +2. A non-symbol atom is returned unchanged (self-evaluating expression). +3. A lambda expression is processed by making a new gensym name for each + of its parameters (found in the cadr of the lambda expression), then + making a new association list with these new pairs in front (so that + the new ones will be seen first by assoc and will take preference over + the same name used in an outer lambda), then recursively rename all the + expressions in the body of the lambda expression. +4. A compound expression that isn't a lambda is processed by recursively + renaming all its subexpressions. + + +The way to use unique-rename to allow evaluation of Scheme programs +with only one frame is that on every procedure call, the evaluator +should call unique-rename on the procedure that the user is trying +to call, then call the resulting modified procedure. You can't just +call unique-rename when the procedure is created (by a lambda +expression), because of recursive procedures. Many recursive +invocations might be active at the same time, and each of them needs +a unique renaming. + +We'll see that something very similar to this is actually done +in the query-language evaluator in week 15. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume1/CS 61A Course Reader, Volume 1.html b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/CS 61A Course Reader, Volume 1.html new file mode 100644 index 0000000..0990f1a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/CS 61A Course Reader, Volume 1.html @@ -0,0 +1,79 @@ +<html><head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>CS 61A Course Reader, Volume 1</title><style type="text/css">@namespace url(http://www.w3.org/1999/xhtml); +@font-face { + font-family: 'EasyRead2'; + font-style: normal; + font-weight: 400; + src: local('EasyRead2'), url(https://cdn.rawgit.com/PullJosh/files/gh-pages/Arial-LargePeriod2.woff) format('woff'); +}input[type="text"], input[type="textarea"], textarea { + font-family: "EasyRead2" !important; + }</style></head> +<body> + +<center> +<h1> CS61A: Structure and Interpretation of Computer Programs </h1> +<h3> Course Reader, Volume 1: Semester Assignments </h3> +</center> + +<table frame="box" pixels="6"><tbody><tr><td> +<h2><b>Berkeley students: Do not print or use these pages! They do not have +the dates for the current semester, so they won't help you. They are here +for non-Berkeley people. ESPECIALLY DON'T LOOK HERE FOR THE PROGRAMMING +PROJECTS, WHICH ARE DIFFERENT HERE FROM THE CURRENT ONES!</b></h2> +</td></tr></tbody></table> + +<p>For many years I resisted the trend to putting course materials online, +but I've been convinced because of the increasing numbers of people who +aren't at Berkeley but use the +<a href="http://wla.berkeley.edu/main.php?course=cs61a">online lectures</a> +to study SICP. Welcome, visitors! Our course reader is divided into two +volumes, this small one with semester-varying material, and +<a href="https://inst.eecs.berkeley.edu/%7Ecs61a/reader/vol2.html">Volume 2</a>, with unchanging reference material, +so that our students can buy used copies of Volume 2, and only need new +copies of Volume 1. What's online has the dates removed. <b>Also, the +projects vary somewhat from semester to semester, so what you see here is +only approximately what's current -- I don't update the online version.</b> + +</p><ul> +<li><a href="hw.pdf"> +Homework assignments</a> +</li><li>Programming Projects: +<ul> +<li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume1/Project1/nodate-21.pdf">Project 1: Twenty-one +</a><ul><li><a href="Project1/twenty-one.scm">twenty-one.scm</a></li></ul> +</li><li><b>Project 2 is in the textbook!</b> +<a href="https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-15.html#%_sec_2.2.4"> +(Section 2.2.4)</a><br /> +You can't actually draw anything until you +finish the project!<br /><br />To begin, copy the file +<a href="../Lib/picture.scm">picture.scm</a> to your directory.<br /><br />To +draw pictures, once you've completed the exercises:<br /><br /> +> (cs)<br /> +> (ht)<br /> +> (===your-painter=== full-frame)<br /><br /> +For example:<br /><br /> +> (wave full-frame)<br /> +> ((square-limit wave 3) full-frame)<br /> +</li><li><a href="Project3/adv.txt">Project 3: Adventure Game +</a><ul><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume1/Project3/adv.scm">adv.scm</a></li></ul> +<ul><li><a href="Project3/adv-world.scm">adv-world.scm</a></li></ul> +<ul><li><a href="Project3/small-world.scm">small-world.scm</a></li></ul> +<ul><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume1/Project3/labyrinth.scm">labyrinth.scm</a></li></ul> +<ul><li><a href="Project3/obj.scm">obj.scm</a></li></ul> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume1/Project4/logo.txt">Project 4: Logo Interpreter +</a><ul><li><a href="Project4/logo.scm">logo.scm</a></li></ul> +<ul><li><a href="Project4/logo-meta.scm">logo-meta.scm</a></li></ul> +<ul><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume1/Project4/tables.scm">tables.scm</a></li></ul> +<ul><li><a href="Project4/obj.scm">obj.scm</a></li></ul> +</li></ul> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume1/labs.pdf"> +Lab assignments</a> +</li></ul> +<p> +</p><p> +</p><p> +</p><p><a href="../Volume2/CS 61A Course Reader, Volume 2.html">Volume 2</a> +</p><p><a href="../../61a-pages">Back to class web page</a> + + +</p></body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project1/twenty-one.scm b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project1/twenty-one.scm new file mode 100644 index 0000000..1c1c6bb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project1/twenty-one.scm @@ -0,0 +1,60 @@ + + +(define (twenty-one strategy) + (define (play-dealer customer-hand dealer-hand-so-far rest-of-deck) + (cond ((> (best-total dealer-hand-so-far) 21) 1) + ((< (best-total dealer-hand-so-far) 17) + (play-dealer customer-hand + (se dealer-hand-so-far (first rest-of-deck)) + (bf rest-of-deck))) + ((< (best-total customer-hand) (best-total dealer-hand-so-far)) -1) + ((= (best-total customer-hand) (best-total dealer-hand-so-far)) 0) + (else 1))) + + (define (play-customer customer-hand-so-far dealer-up-card rest-of-deck) + (cond ((> (best-total customer-hand-so-far) 21) -1) + ((strategy customer-hand-so-far dealer-up-card) + (play-customer (se customer-hand-so-far (first rest-of-deck)) + dealer-up-card + (bf rest-of-deck))) + (else + (play-dealer customer-hand-so-far + (se dealer-up-card (first rest-of-deck)) + (bf rest-of-deck))))) + + (let ((deck (make-deck))) + (play-customer (se (first deck) (first (bf deck))) + (first (bf (bf deck))) + (bf (bf (bf deck))))) ) + +(define (make-ordered-deck) + (define (make-suit s) + (every (lambda (rank) (word rank s)) '(A 2 3 4 5 6 7 8 9 10 J Q K)) ) + (se (make-suit 'H) (make-suit 'S) (make-suit 'D) (make-suit 'C)) ) + +(define (make-deck) + (define (shuffle deck size) + (define (move-card in out which) + (if (= which 0) + (se (first in) (shuffle (se (bf in) out) (- size 1))) + (move-card (bf in) (se (first in) out) (- which 1)) )) + (if (= size 0) + deck + (move-card deck '() (random size)) )) + (shuffle (make-ordered-deck) 52) ) + + + + + + + + + + + + + + + +; 32 diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/adv-world.scm b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/adv-world.scm new file mode 100644 index 0000000..bc4eb8c --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/adv-world.scm @@ -0,0 +1,83 @@ +;;; Data for adventure game. This file is adv-world.scm + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; setting up the world +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define Soda (instantiate place 'Soda)) +(define BH-Office (instantiate place 'BH-Office)) +(define MJC-Office (instantiate place 'MJC-Office)) +(define art-gallery (instantiate place 'art-gallery)) +(define Pimentel (instantiate place 'Pimentel)) +(define 61A-Lab (instantiate place '61A-Lab)) +(define Sproul-Plaza (instantiate place 'Sproul-Plaza)) +(define Telegraph-Ave (instantiate place 'Telegraph-Ave)) +(define Noahs (instantiate place 'Noahs)) +(define Intermezzo (instantiate place 'Intermezzo)) +(define s-h (instantiate place 'sproul-hall)) + + +(can-go Soda 'up art-gallery) +(can-go art-gallery 'down Soda) +(can-go art-gallery 'west BH-Office) +(can-go BH-Office 'east art-gallery) +(can-go art-gallery 'east MJC-Office) +(can-go MJC-office 'west art-gallery) +(can-go Soda 'south Pimentel) +(can-go Pimentel 'north Soda) +(can-go Pimentel 'south 61A-Lab) +(can-go 61A-Lab 'north Pimentel) +(can-go 61A-Lab 'west s-h) +(can-go s-h 'east 61A-Lab) +(can-go Sproul-Plaza 'east s-h) +(can-go s-h 'west Sproul-Plaza) +(can-go Sproul-Plaza 'north Pimentel) +(can-go Sproul-Plaza 'south Telegraph-Ave) +(can-go Telegraph-Ave 'north Sproul-Plaza) +(can-go Telegraph-Ave 'south Noahs) +(can-go Noahs 'north Telegraph-Ave) +(can-go Noahs 'south Intermezzo) +(can-go Intermezzo 'north Noahs) + +;; Some people. +; MOVED above the add-entry-procedure stuff, to avoid the "The computers +; seem to be down" message that would occur when hacker enters 61a-lab +; -- Ryan Stejskal + +(define Brian (instantiate person 'Brian BH-Office)) +(define hacker (instantiate person 'hacker 61A-lab)) +(define nasty (instantiate thief 'nasty sproul-plaza)) + +(define (sproul-hall-exit) + (error "You can check out any time you'd like, but you can never leave")) + +(define (bh-office-exit) + (print "What's your favorite programming language?") + (let ((answer (read))) + (if (eq? answer 'scheme) + (print "Good answer, but my favorite is Logo!") + (begin (newline) (bh-office-exit))))) + + +(ask s-h 'add-entry-procedure + (lambda () (print "Miles and miles of students are waiting in line..."))) +(ask s-h 'add-exit-procedure sproul-hall-exit) +(ask BH-Office 'add-exit-procedure bh-office-exit) +(ask Noahs 'add-entry-procedure + (lambda () (print "Would you like lox with it?"))) +(ask Noahs 'add-exit-procedure + (lambda () (print "How about a cinnamon raisin bagel for dessert?"))) +(ask Telegraph-Ave 'add-entry-procedure + (lambda () (print "There are tie-dyed shirts as far as you can see..."))) +(ask 61A-Lab 'add-entry-procedure + (lambda () (print "The computers seem to be down"))) +(ask 61A-Lab 'add-exit-procedure + (lambda () (print "The workstations come back to life just in time."))) + +;; Some things. + +(define bagel (instantiate thing 'bagel)) +(ask Noahs 'appear bagel) + +(define coffee (instantiate thing 'coffee)) +(ask Intermezzo 'appear coffee) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/adv.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/adv.txt new file mode 100644 index 0000000..755f2ed --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/adv.txt @@ -0,0 +1,718 @@ +Project: Write an adventure game. We'll provide most of the program. You +will mostly make modification and some additions. + +This project is designed to be done by two people working in parallel, then +combining your results into one finished product. (Hereafter the two partners +are called Person A and Person B.) But you will combine your work to hand in +a single report for your group. + +The project begins with two exercises that everyone should do; these +exercises do not require new programming, but rather familiarize you +with the overall structure of the program as we've provided it. After +that, each person has separate exercises. There is one final exercise +for everyone that requires the two partners' work to be combined. +(Therefore, you should probably keep notes about all of the procedures +that you've modified during the project, so you can notice the ones that +both partners modified independently.) + +This is a two-week project. Each week, your group should +hand in one paper (not one per person) including a listing of your modified +adv.scm program with the modifications highlighted, and a transcript of the +testing of your work. Indicate on the paper which of you is person A and +which is person B. + +Scoring: Each person works on nine problems. Three of these (numbers +1, 2, and 9) are common to the two partners; the others are separate. +You hand in a single solution to each problem. Both partners get +the points awarded to the group for problems 1, 2, and 9; each +person gets the points for his or her own problems 3 through 8. This means +that your score for the project is mostly based on your individual work but +also relies partly on the other member of your group. For the first two +problems, you could get away with letting your partner do the +work, but you shouldn't because those problems are necessary to help you +understand the structure of the entire project. Problem 9 requires that both +partners have already done their separate work, and meet together to +understand each other's solutions, so probably nobody will get credit for it +unless both have done their jobs. + +(Acknowledgement: This assignment is loosely based on an MIT homework +assignment in their version of this course. But since this is Berkeley we've +changed it to be politically correct; instead of killing each other, the +characters go around eating gourmet food all the time. N.B.: Unless you +are a diehard yuppie you may feel that eating gourmet food does not express +appropriate sensitivity to the plight of the homeless. But it's a start.) + +In this laboratory assignment, we will be exploring two key ideas: the +simulation of a world in which objects are characterized by a set of state +variables, and the use of message passing as a programming technique for +modularizing worlds in which objects interact. + +OBJECT-ORIENTED PROGRAMMING is becoming an extremely popular methodology for +any application that involves interactions among computational entities. +Examples: + + -- operating systems (processes as objects) + -- window systems (windows as objects) + -- games (asteroids, spaceships, gorillas as objects) + -- drawing programs (shapes as objects) + + +GETTING STARTED +To start, copy the following five files into your directory: + ~cs61a/lib/obj.scm The object-oriented system + ~cs61a/lib/adv.scm The adventure game program + ~cs61a/lib/tables.scm An ADT you'll need for parts A5 and B4 + ~cs61a/lib/adv-world.scm The specific people, places, and things + ~cs61a/lib/small-world.scm A smaller world you can use for debugging + +To work on this project, you must load these files into Scheme in the +correct order: obj.scm first, then adv.scm and tables.scm when you're using +that, and finally the particular world you're using, either adv-world.scm or +small-world.scm. The work you are asked to do refers to adv-world.scm; +small-world.scm is provided in case you'd prefer to debug some of your +procedures in a smaller world that may be less complicated to remember and +also faster to load. + +The reason the adventure game is divided into adv.scm (containing the +definitions of the object classes) and adv-world.scm (containing the +specific instances of those objects in Berkeley) is that when you change +something in adv.scm you may need to reload the entire world in order for +your changed version to take effect. Having two files means that you don't +also have to reload the first batch of procedures. + + +In this program there are three classes: THING, PLACE, and PERSON. + +Here are some examples selected from adv-world.scm: + +;;; construct the places in the world +(define Soda (instantiate place 'Soda)) +(define BH-Office (instantiate place 'BH-Office)) +(define art-gallery (instantiate place 'art-gallery)) +(define Pimentel (instantiate place 'Pimentel)) +(define 61A-Lab (instantiate place '61A-Lab)) +(define Sproul-Plaza (instantiate place 'Sproul-Plaza)) +(define Telegraph-Ave (instantiate place 'Telegraph-Ave)) +(define Noahs (instantiate place 'Noahs)) +(define Intermezzo (instantiate place 'Intermezzo)) +(define s-h (instantiate place 'sproul-hall)) + +;;; make some things and put them at places +(define bagel (instantiate thing 'bagel)) +(ask Noahs 'appear bagel) + +(define coffee (instantiate thing 'coffee)) +(ask Intermezzo 'appear coffee) + +;;; make some people +(define Brian (instantiate person 'Brian BH-Office)) +(define hacker (instantiate person 'hacker Pimentel)) + +;;; connect places in the world + +(can-go Soda 'up art-gallery) +(can-go art-gallery 'west BH-Office) +(can-go Soda 'south Pimentel) + +Having constructed this world, we can now interact with it by sending +messages to objects. Here is a short example. + +; We start with the hacker in Pimentel. + +> (ask Pimentel 'exits) +(NORTH SOUTH) +> (ask hacker 'go 'north) +HACKER moved from PIMENTEL to SODA + + +We can put objects in the different places, and the people can then take the +objects: + +> (define Jolt (instantiate thing 'Jolt)) +JOLT +> (ask Soda 'appear Jolt) +APPEARED +> (ask hacker 'take Jolt) +HACKER took JOLT +TAKEN + +You can take objects away from other people, but the management is not +responsible for the consequences... (Too bad this is a fantasy game, and +there aren't really vending machines in Soda that stock Jolt.) + +PART I: + +The first two exercises in this part should be done by everyone -- that is, +everyone should actually sit in front of a terminal and do it! It's okay to +work in pairs as long as you all really know what's going on by the time +you're finished. (Nevertheless, you should only hand in one solution, that +both agree about.) The remaining exercises have numbers like "A3" +which means exercise 3 for Person A. + +After you've done the work separately, you should meet together +to make sure that you each understands what the other person did, because +the second week's work depends on all of the first week's work. You can +do the explaining while you're merging the two sets of modifications into +one adv.scm file to hand in. + +1. Create a new person to represent yourself. Put yourself in a new place +called Dormitory (or wherever you live) and connect it to campus so that you +can get there from here. Create a place called Kirin, north of Soda. +(It's actually on Solano Avenue.) Put a thing called Potstickers there. +Then give the necessary commands to move your character to Kirin, take +the Potstickers, then move yourself to where Brian is, put down the +Potstickers, and have Brian take them. Then go back to the lab and get back +to work. (There is no truth to the rumor that you'll get an A in the course +for doing this in real life!) All this is just to ensure that you know how +to speak the language of the adventure program. + +LIST ALL THE MESSAGES THAT ARE SENT DURING THIS EPISODE. It's a good idea +to see if you can work this out in your head, at least for some of the +actions that take place, but you can also trace the ASK procedure to get +a complete list. You don't have to hand in this listing of messages. (Do +hand in a transcript of the episode without the tracing.) The point is that +you should have a good sense of the ways in which the different objects send +messages back and forth as they do their work. + +[Tip: we have provided a MOVE-LOOP procedure that you may find useful as +an aid in debugging your work. You can use it to move a person repeatedly.] + + +2. It is very important that you think about and understand the kinds of +objects involved in the adventure game. Please answer the following questions: + +2A. What kind of thing is the value of variable BRIAN? + +Hint: What is returned by scheme in the following situation: + You type: > BRIAN + + +2B. List all the messages that a PLACE understands. (You might want to +maintain such a list for your own use, for every type of object, to help +in the debugging effort.) + + +2C. We have been defining a variable to hold each object in our world. +For example, we defined bagel by saying: + + (define bagel (instantiate thing 'bagel)) + +This is just for convenience. Every object does not have to have a +top-level definition. Every object DOES have to be constructed and +connected to the world. For instance, suppose we did this: + +> (can-go Telegraph-Ave 'east (instantiate place 'Peoples-Park)) + +;;; assume BRIAN is at Telegraph +> (ask Brian 'go 'east) + +What is returned by the following expressions and WHY? + +> (ask Brian 'place) + +> (let ((where (ask Brian 'place))) + (ask where 'name)) + +> (ask Peoples-park 'appear bagel) + + + +2D. The implication of all this is that there can be multiple names for +objects. One name is the value of the object's internal NAME variable. In +addition, we can define a variable at the top-level to refer to an object. +Moreover, one object can have a private name for another object. For +example, BRIAN has a variable PLACE which is currently bound to the object +that represents People's Park. Some examples to think about: + + > (eq? (ask Telegraph-Ave 'look-in 'east) (ask Brian 'place)) + + > (eq? (ask Brian 'place) 'Peoples-Park) + + > (eq? (ask (ask Brian 'place) 'name) 'Peoples-Park) + + +OK. Suppose we type the following into scheme: + +> (define computer (instantiate thing 'Durer)) + + +Which of the following is correct? Why? + +(ask 61a-lab 'appear computer) + +or + +(ask 61a-lab 'appear Durer) + +or + +(ask 61a-lab 'appear 'Durer) + +What is returned by (computer 'name)? Why? + + +2E. We have provided a definition of the THING class that does not use +the object-oriented programming syntax described in the handout. Translate +it into the new notation. + +2F. Sometimes it's inconvenient to debug an object interactively because +its methods return objects and we want to see the names of the objects. You +can create auxiliary procedures for interactive use (as opposed to use +inside object methods) that provide the desired information in printable +form. For example: + +(define (name obj) (ask obj 'name)) +(define (inventory obj) + (if (person? obj) + (map name (ask obj 'possessions)) + (map name (ask obj 'things)))) + +Write a procedure WHEREIS that takes a person as its argument and returns +the name of the place where that person is. + +Write a procedure OWNER that takes a thing as its argument and returns the +name of the person who owns it. (Make sure it works for things that aren't +owned by anyone.) + +Procedures like this can be very helpful in debugging the later parts of the +project, so feel free to write more of them for your own use. + + +Now it's time for you to make your first modifications to the adventure +game. This is where you split the work individually. + +PART I -- PERSON A: + +A3. You will notice that whenever a person goes to a new place, the place +gets an 'ENTER message. In addition, the place the person previously +inhabited gets an 'EXIT message. When the place gets the message, it calls +each procedure on its list of ENTRY-PROCEDURES or EXIT-PROCEDURES as +appropriate. Places have the following methods defined for manipulating +these lists of procedures: ADD-ENTRY-PROCEDURE, ADD-EXIT-PROCEDURE, +REMOVE-ENTRY-PROCEDURE, +REMOVE-EXIT-PROCEDURE, CLEAR-ALL-PROCS. You can read their definitions in the +code. + +Sproul Hall has a particularly obnoxious exit procedure attached to it. Fix +SPROUL-HALL-EXIT so that it counts how many times it gets called, and stops +being obnoxious after the third time. + +Remember that the EXIT-PROCS list contains procedures, not names of +procedures! It's not good enough to redefine SPROUL-HALL-EXIT, since Sproul +Hall's list of exit procedures still contains the old procedure. The best +thing to do is just to load adv-world.scm again, which will define a new +sproul hall and add the new exit procedure. + + + +A4a. We've provided people with the ability to say something using the +messages 'TALK and 'SET-TALK. As you may have noticed, some people around +this campus start talking whenever anyone walks by. We want to simulate this +behavior. In any such interaction there are two people involved: the one +who was already at the place (hereafter called the TALKER) and the one who +is just entering the place (the LISTENER). We have already provided a +mechanism so that the listener sends an ENTER message to the place when +entering. Also, each person is ready to accept a NOTICE message, meaning +that the person should notice that someone new has come. The talker should +get a NOTICE message, and will then talk, because we've made a person's +NOTICE method send itself a TALK message. (Later we'll see that some special +kinds of people have different NOTICE methods.) + +Your job is to modify the ENTER method for places, so that in addition to +what that method already does, it sends a NOTICE message to each person in +that place other than the person who is entering. The NOTICE message should +have the newly-entered person as an argument. (You won't do anything with +that argument now, but you'll need it later.) + +Test your implementation with the following: + +(define singer (instantiate person 'rick sproul-plaza)) + +(ask singer 'set-talk "My funny valentine, sweet comic valentine") + +(define preacher (instantiate person 'preacher sproul-plaza)) + +(ask preacher 'set-talk "Praise the Lord") + +(define street-person (instantiate person 'harry telegraph-ave)) + +(ask street-person 'set-talk "Brother, can you spare a buck") + +YOU MUST INCLUDE A TRANSCRIPT IN WHICH YOUR CHARACTER WALKS AROUND AND +TRIGGERS THESE MESSAGES. + + +A4b. So far the program assumes that anyone can go anywhere they want. +In real life, many places have locked doors. + +Invent a MAY-ENTER? message for places that takes a person as an argument and +always returns #T. Then invent a LOCKED-PLACE class in which the MAY-ENTER? +method returns #T if the place is unlocked, or #F if it's locked. (It should +initially be locked.) The LOCKED-PLACE class must also have an UNLOCK +message. For simplicity, write this method with no arguments and have it +always succeed. In a real game, we would also invent keys, and a mechanism +requiring that the person have the correct key in order to unlock the door. +(That's why MAY-ENTER? takes the person as an argument.) + +Modify the person class so that it checks for permission to enter before +moving from one place to another. Then create a locked place and test +it out. + + +A5. Walking around is great, but some people commute from far away, so +they need to park their cars in garages. A car is just a THING, but you'll +have to invent a special kind of place called a GARAGE. Garages have two +methods (besides the ones all places have): PARK and UNPARK. You'll also +need a special kind of THING called a TICKET; what's special about it is +that it has a NUMBER as an instantiation variable. + +The PARK method takes a car (a THING) as its argument. First check to be sure +that the car is actually in the garage. (The person who possesses the car +will enter the garage, then ask to park it, so the car should have entered the +garage along with the person before the PARK message is sent.) Then generate +a TICKET with a unique serial number. (The counter for serial numbers should +be shared among all garages, so that we don't get in trouble later trying to +UNPARK a car from one garage that was parked in a different garage.) Every +ticket should have the name TICKET. + +You'll associate the ticket number with the car in a key-value table like the +one that we used with GET and PUT in 2.3.3. However, GET and PUT refer to a +single, fixed table for all operations; in this situation we need a separate +table for every garage. The file tables.scm contains an implementation of the +table Abstract Data Type: + +constructor: (make-table) returns a new, empty table. + +mutator: (insert! key value table) adds a new key-value pair to a table. + +selector: (lookup key table) returns the corresponding value, or #F if + the key is not in the table. + +You'll learn how tables are implemented in 3.3.3 (pp. 266-268). +For now, just take them as primitive. + +Make a table entry with the ticket number as the key, and the car as the +value. Then ask the car's owner to lose the car and take the ticket. + +The UNPARK method takes a ticket as argument. First make sure the object +you got is actually a ticket (by checking the name). Then look up the +ticket number in the garage's table. If you find a car, ask the ticket's +owner to lose the ticket and take the car. Also, insert #F in the table for +that ticket number, so that people can't unpark the car twice. + +A real-life garage would have a limited capacity, and would charge money +for parking, but to simplify the project you don't have to simulate those +aspects of garages. + + +--- End of Part I for Person A + + +PART I, PERSON B: + + +B3. Define a method TAKE-ALL for people. If given that message, a person +should TAKE all the things at the current location that are not already +owned by someone. + + +B4a. It's unrealistic that anyone can take anything from anyone. We want to +give our characters a STRENGTH, and then one person can take something from +another only if the first has greater STRENGTH than the second. + +However, we aren't going to clutter up the person class by adding a local +STRENGTH variable. That's because we can anticipate wanting to add lots +more attributes as we develop the program further. People can have CHARISMA +or WISDOM; things can be FOOD or not; places can be INDOORS or not. +Therefore, you will create a class called BASIC-OBJECT that keeps a local +variable called PROPERTIES containing an attribute-value table like the +one that we used with GET and PUT in 2.3.3. However, GET and PUT refer to +a single, fixed table for all operations; in this situation we need a +separate table for every object. The file tables.scm contains an +implementation of the table Abstract Data Type: + +constructor: (make-table) returns a new, empty table. + +mutator: (insert! key value table) adds a new key-value pair to a table. + +selector: (lookup key table) returns the corresponding value, or #F if + the key is not in the table. + +You'll learn how tables are implemented in 3.3.3 (pp. 266-268). +For now, just take them as primitive. + +You'll modify the person, place and thing classes so that they will inherit +from basic-object. This object will accept a message PUT so that + > (ask Brian 'put 'strength 100) +does the right thing. Also, the basic-object should treat any message not +otherwise recognized as a request for the attribute of that name, so + > (ask Brian 'strength) + 100 +should work WITHOUT having to write an explicit STRENGTH method in the +class definition. + +Don't forget that the property list mechanism in 3.3.3 returns #F if you ask +for a property that isn't in the list. This means that + > (ask Brian 'charisma) +should never give an error message, even if we haven't PUT that property in +that object. This is important for true-or-false properties, which will +automatically be #F (but not an error) unless we explicitly PUT a #T +value for them. + +Give people some reasonable (same for everyone) initial strength. Next +week they'll be able to get stronger by eating. + +B4b. You'll notice that the type predicate PERSON? checks to see if the type +of the argument is a member of the list '(person police thief). This means +that the PERSON? procedure has to keep a list of all the classes that +inherit from PERSON, which is a pain if we make a new subclass. + +We'll take advantage of the property list to implement a better system for +type checking. If we add a method named PERSON? to the person class, and +have it always return #T, then any object that's a type of person will +automatically inherit this method. Objects that don't inherit from person +won't find a PERSON? method and won't find an entry for person? in their +property table, so they'll return #F. + +Similarly, places should have a PLACE? method, and things a THING? method. + +Add these type methods and change the implementation of the type predicate +procedures to this new implementation. + + +B5. In the modern era, many places allow you to get connected to the net. +Define a HOTSPOT as a kind of place that allows network connectivity. Each +hotspot should have a PASSWORD (an instantiation variable) that you must know +to connect. (Note: We're envisioning a per-network password, not a per-person +password as you use with AirBears.) The hotspot has a CONNECT method with two +arguments, a LAPTOP (a kind of thing, to be invented in a moment) and a +password. If the password is correct, and the laptop is in the hotspot, add +it to a list of connected laptops. When the laptop leaves the hotspot, remove +it from the list. + +Hotspots also have a SURF method with two arguments, a laptop and a text +string, such as + + "http://www.cs.berkeley.edu" + +If the laptop is connected to the network, then the surf method should + + (system (string-append "lynx " url)) + +where URL is the text string argument. + +Now invent laptops. A laptop is a thing that has two extra methods: CONNECT, +with a password as argument, sends a CONNECT message to the place where the +laptop is. SURF, with a URL text string as argument, sends a SURF message to +the place where it is. Thus, whenever a laptop enters a new hotspot, the user +must ask to CONNECT to that hotspot's network; when the laptop leaves the +hotspot, it must automatically be disconnected from the network. (If it's in +a place other than a hotspot, the SURF message won't be understood; if it's in +a hotspot but not connected, the hotspot won't do anything.) + + +--- End of Part I, PERSON B. + + +PART II: + +This part of the project includes three exercises for each person, but YOU +HAVE TO READ EACH OTHER'S CODE midweek, because one partner's exercises 7 and +8 build on the other partner's exercise 6. Finally, exercise 9 requires the +two partners' work to be combined. You will have to create a version of +adv.scm that has both partners' changes. This may take some thinking! If +both parners modify the same method in the same object class, you'll have to +write a version of the method that incorporates both modifications. + + +PART II, PERSON A: + +Adv.scm includes a definition of the class THIEF, a subclass of person. +A thief is a character who tries to steal food from other people. Of +course, Berkeley can not tolerate this behavior for long. Your job is to +define a POLICE class; police objects catch thieves and send them directly +to jail. To do this you will need to understand how theives work. + +Since a thief is a kind of person, whenever another person enters the place +where the thief is, the thief gets a NOTICE message from the place. When +the thief notices a new person, he does one of two things, depending on the +state of his internal BEHAVIOR variable. If this variable is set to STEAL, +the thief looks around to see if there is any food at the place. If there +is food, the thief takes the food from its current possessor and sets his +behavior to RUN. When the thief's behavior is RUN, he moves to a new random +place whenever he NOTICEs someone entering his current location. The RUN +behavior makes it hard to catch a thief. + +Notice that a thief object delegates many messages to its person object. + + +A6a. To help the police do their work, you will need to create a place called +jail. Jail has no exits. Moreover, you will need to create a method for +persons and thieves called GO-DIRECTLY-TO. Go-directly-to does not require +that the new-place be adjacent to the current-place. So by calling (ASK +THIEF 'GO-DIRECTLY-TO JAIL) the police can send the thief to jail no matter +where the thief currently is located, assuming the variable thief is bound +to the thief being apprehended. + + +A6b. Thieves sometimes try to leave their place in a randomly chosen +direction. This, it turns out, won't work if there are no exits from +that place -- for example, the jail. Modify the THIEF class so that +a thief won't try to leave a place with no exits. + +** Now get your partner to explain problem B6 and its solution. ** + +A7a. We are now going to invent restaurant objects. People will interact +with the restaurants by buying food there. First we have to make it possible +for people to buy stuff. Give PERSON objects a MONEY property, which is a +number, saying how many dollars they have. Note that money is not an +object. We implement it as a number because, unlike the case of objects +such as chairs and potstickers, a person needs to be able to spend SOME +money without giving up all of it. In principle we could have objects like +QUARTER and DOLLAR-BILL, but this would make the change-making process +complicated for no good reason. + +To make life simple, we'll have every PERSON start out with $100. (We should +really start people with no money, and invent banks and jobs and so on, but +we won't.) Create two methods for people, GET-MONEY and PAY-MONEY, each of +which takes a number as argument and updates the person's money value +appropriately. PAY-MONEY must return true or false depending on whether +the person had enough money. + + +A7b. Another problem with the adventure game is that Noah's only has one +bagel. Once someone has taken that bagel, they're out of business. + +To fix this, we're going to invent a new kind of place, called a RESTAURANT. +(That is, RESTAURANT is a subclass of PLACE.) Each restaurant serves only +one kind of food. (This is a simplification, of course, and it's easy to see +how we might extend the project to allow lists of kinds of food.) When a +restaurant is instantiated, it should have two extra arguments, besides the +ones that all places have: the class of food objects that this restaurant +sells, and the price of one item of this type: + + > (define-class (bagel) (parent (food ...)) ...) + + > (define Noahs (instantiate restaurant 'Noahs bagel 0.50)) + +Notice that the argument to the restaurant is a CLASS, not a particular +bagel (instance). + +Restaurants should have two methods. The MENU method returns a list +containing the name and price of the food that the restaurant sells. +The SELL method takes two arguments, the person who wants to buy something +and the name of the food that the person wants. The SELL method must first +check that the restaurant actually sells the right kind of food. If so, +it should ASK the buyer to PAY-MONEY in the appropriate amount. If that +succeeds, the method should instantiate the food class and return the new +food object. The method should return #F if the person can't buy the food. + + +A8. Now we need a BUY method for people. It should take as argument the +name of the food we want to buy: (ask Brian 'buy 'bagel). The method must +send a SELL message to the restaurant. If this succeeds (that is, if the +value returned from the SELL method is an object rather than #F) the new food +should be added to the person's possessions. + +--- Person A skip to question 9 below. + +PART II, PERSON B: + +B6. The way we're having people take food from restaurants is unrealistic +in several ways. Our overall goal this week is to fix that. As a first +step, you are going to create a FOOD class. +We will give things that are food two properties, an EDIBLE? property +and a CALORIES property. EDIBLE? will have the value #T if the object is a +food. If a PERSON eats some food, the food's CALORIES are added to the +person's STRENGTH. + +(Remember that the EDIBLE? property will automatically be false for objects +other than food, because of the way properties were implemented in question B4. +You don't have to go around telling all the other stuff not to be edible +explicitly.) + +Write a definition of the FOOD class that uses THING as the parent class. +It should return #T when you send it an EDBILE? message, and it should +correctly respond to a CALORIES message. + +Replace the procedure named EDIBLE? in the original adv.scm with a new +version that takes advantage of the mechanism you've created, instead of +relying on a built-in list of types of food. + +Now that you have the FOOD class, invent some child classes for particular +kinds of food. For example, make a bagel class that inherits from FOOD. +Give the bagel class a class-variable called NAME whose value is the word +bagel. (We'll need this later when we invent RESTAURANT objects.) + +Make an EAT method for people. Your EAT method should look at your +possessions and filter for all the ones that are edible. It should then add +the calorie value of the foods to your strength. Then it should make the +foods disappear (no longer be your possessions and no longer be at your +location). + +** Now get your partner to explain problem A6 and its solution. ** + +B7. Your job is to define the police class. A policeperson is to have the +following behavior: + +The police stays at one location. When the police notices a new person +entering the location, the police checks to see if that person is a thief. +If the person is a thief the police says "Crime Does Not Pay," then takes +away all the thief's possessions and sends the thief directly to jail. + +Give thieves and police default strengths. Thieves should start out stronger +than persons, but police should be stronger than thieves. Of course, if you +eat lots you should be able to build up enough STRENGTH (mass?) to take food +away from a thief. (Only a character with a lot of CHUTZPAH would take food +away from the police. :-) + +Please test your code and turn in a transcript that shows the thief stealing +your food, you chasing the thief and the police catching the thief. In case +you haven't noticed, we've put a thief in Sproul Plaza. + + +B8. Now we want to reorganize TAKE so that it looks to see who previously +possesses the desired object. If its possessor is 'NO-ONE, go ahead and +take it as always. Otherwise, invoke + (ask thing 'MAY-TAKE? receiver) +The MAY-TAKE? method for a thing that belongs to someone should compare +the strength of its owner with the strength of the requesting person to +decide whether or not it can be taken. The method should return #F +if the person may not take the thing, or the thing itself if the person may +take it. This is a little more complicated than necessary right now, but +we are planning ahead for a situation in which, for example, an object +might want to make a clone of itself for a person to take. + +Note the flurry of message-passing going on here. We send a message to the +taker. It sends a message to the thing, which sends messages to two people +to find out their strengths. + +--- End of Part II, Person B (but both partners do question 8 below). + +9. Combine the two partners' work. For example, both partners have +created new methods for the PERSON class. Both partners have done work +involving strengths of kinds of people; make sure they work together. + +Now make it so that when a POLICE person asks to BUY some food the +restaurant doesn't charge him or her any money. (This makes the game +more realistic...) + +******** OPTIONAL ********** +As you can imagine, this is a truly open-ended project. If you have the +time and inclination, you can populate your world with new kinds of people +(e.g., punk-rockers), places (Gilman-St), and especially things (magic +wands, beer, gold pieces, cars looking for parking places...). + +For your enjoyment we have developed a procedure that creates a labyrinth (a +maze) that you can explore. To do so, load the file ~cs61a/lib/labyrinth.scm. +[Note: labyrinth.scm may need some modification to work with the procedures +you developed in part two of the project.] + +Legend has it that there is a vast series of rooms underneath Sproul Plaza. +These rooms are littered with food of bygone days and quite a few theives. +You can find the secret passage down in Sproul Plaza. + +You may want to modify FANCY-MOVE-LOOP so that you can look around in nearby +rooms before entering so that you can avoid thieves. You might also want +your character to maintain a list of rooms visited on its property list so +you can find your way back to the earth's surface. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/obj.scm b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/obj.scm new file mode 100644 index 0000000..d4a9d7a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/obj.scm @@ -0,0 +1,279 @@ +;;; obj.scm version 4.0 5/18/2000 +;;; -- implementation of the object-oriented syntax +;; By Matt Wright, based on a handout from MIT +;; Revised for STk by Brian Gaeke - removed scm and procedure->macro + +;;; Utilities + +;; MAKNAM: create a new symbol whose name is the concatenation of the +;; names of those in the symbol list SYMBOLS. +(define (maknam . symbols) + (string->symbol (apply string-append (map symbol->string symbols)))) + +;; ASK: send a message to an object + +; The dot in the first line of the definition of ASK, below, makes it +; take a variable number of arguments. The first argument is associated +; with the formal parameter OBJECT; the second with MESSAGE; any extra +; actual arguments are put in a list, and that list is associated with +; the formal parameter ARGS. (If there are only two actual args, then +; ARGS will be the empty list.) + +; APPLY takes two arguments, a procedure and a list, and applies the +; procedure to the things in the list, which are used as actual +; argument values. + +(define (ask object message . args) + (let ((method (object message))) + (if (method? method) + (apply method args) + (error "No method " message " in class " (cadr method))))) + +(define (no-method name) + (list 'no-method name)) + +(define (no-method? x) + (if (pair? x) + (eq? (car x) 'no-method) + #f)) + +(define (method? x) + (not (no-method? x))) + + +;; INSTANTIATE and INSTANTIATE-PARENT: Create an instance of a class + +; The difference is that only INSTANTIATE initializes the new object + +(define (instantiate class . arguments) + (let ((new-instance (apply (class 'instantiate) arguments))) + (ask new-instance 'initialize new-instance) + new-instance)) + +(define (instantiate-parent class . arguments) + (apply (class 'instantiate) arguments)) + +;; GET-METHOD: Send a message to several objects and return the first +;; method found (for multiple inheritance) + +(define (get-method give-up-name message . objects) + (if (null? objects) + (no-method give-up-name) + (let ((method ((car objects) message))) + (if (method? method) + method + (apply get-method (cons give-up-name + (cons message (cdr objects)) )))))) + + + +;; USUAL: Invoke a parent's method +;; Note: The 'send-usual-to-parent method is put in automatically by +;; define-class. + +(define-macro (usual . args) + `(ask dispatch 'send-usual-to-parent . ,args)) + + +;; DEFINE-CLASS: Create a new class. + +; DEFINE-CLASS is a special form. When you type (define-class body...) +; it's as if you typed (make-definitions (quote body...)). In other +; words, the argument to DEFINE-CLASS isn't evaluated. This makes sense +; because the argument isn't Scheme syntax, but rather is the special +; object-oriented programming language we're defining. +; Make-definitions transforms the OOP notation into a standard Scheme +; expression, then uses EVAL to evaluate the result. (You'll see EVAL +; again in chapter 4 with the metacircular evaluator.) + +; When you define a class named THING, for example, two global Scheme +; variables are created. The variable THING has as its value the +; procedure that represents the class. This procedure is invoked by +; INSTANTIATE to create instances of the class. A second variable, +; THING-DEFINITION, has as its value the text of the Scheme expression +; that defines THING. This text is used only by SHOW-CLASS, the +; procedure that lets you examine the result of the OOP-to-Scheme +; translation process. + +(define-macro (define-class . body) (make-definitions body)) + +(define (make-definitions form) + (let ((definition (translate form))) + (eval `(define ,(maknam (class-name form) '-definition) ',definition)) + (eval definition) + (list 'quote (class-name form)))) + +(define (show-class name) + (eval (maknam name '-definition)) ) + +; TRANSLATE does all the work of DEFINE-CLASS. +; The backquote operator (`) works just like regular quote (') except +; that expressions proceeded by a comma are evaluated. Also, expressions +; proceeded by ",@" evaluate to lists; the lists are inserted into the +; text without the outermost level of parentheses. + +(define (translate form) + (cond ((null? form) (error "Define-class: empty body")) + ((not (null? (obj-filter form (lambda (x) (not (pair? x)))))) + (error "Each argument to define-class must be a list")) + ((not (null? (extra-clauses form))) + (error "Unrecognized clause in define-class:" (extra-clauses form))) + (else + `(define ,(class-name form) + (let ,(class-var-bindings form) + (lambda (class-message) + (cond + ,@(class-variable-methods form) + ((eq? class-message 'instantiate) + (lambda ,(instantiation-vars form) + (let ((self '()) + ,@(parent-let-list form) + ,@(instance-vars-let-list form)) + (define (dispatch message) + (cond + ,(init-clause form) + ,(usual-clause form) + ,@(method-clauses form) + ,@(local-variable-methods form) + ,(else-clause form) )) + dispatch ))) + (else (error "Bad message to class" class-message)) ))))))) + +(define *legal-clauses* + '(instance-vars class-vars method default-method parent initialize)) + +(define (extra-clauses form) + (obj-filter (cdr form) + (lambda (x) (null? (member (car x) *legal-clauses*))))) + +(define class-name caar) + +(define (class-var-bindings form) + (let ((classvar-clause (find-a-clause 'class-vars form))) + (if (null? classvar-clause) + '() + (cdr classvar-clause) ))) + +(define instantiation-vars cdar) + +(define (parent-let-list form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map (lambda (parent-and-args) + (list (maknam 'my- (car parent-and-args)) + (cons 'instantiate-parent parent-and-args))) + (cdr parent-clause))))) + +(define (instance-vars-let-list form) + (let ((instance-vars-clause (find-a-clause 'instance-vars form))) + (if (null? instance-vars-clause) + '() + (cdr instance-vars-clause)))) + +(define (init-clause form) + (define (parent-initialization form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map + (lambda (parent-and-args) + `(ask ,(maknam 'my- (car parent-and-args)) 'initialize self) ) + (cdr parent-clause) )))) + (define (my-initialization form) + (let ((init-clause (find-a-clause 'initialize form))) + (if (null? init-clause) '() + (cdr init-clause)))) + (define (init-body form) + (append (parent-initialization form) + (my-initialization form) )) + + `((eq? message 'initialize) + (lambda (value-for-self) + (set! self value-for-self) + ,@(init-body form) ))) + +(define (variable-list var-type form) + (let ((clause (find-a-clause var-type form))) + (if (null? clause) + '() + (map car (cdr clause)) ))) + +(define (class-variable-methods form) + (cons `((eq? class-message 'class-name) (lambda () ',(class-name form))) + (map (lambda (variable) + `((eq? class-message ',variable) (lambda () ,variable))) + (variable-list 'class-vars form)))) + +(define (local-variable-methods form) + (cons `((eq? message 'class-name) (lambda () ',(class-name form))) + (map (lambda (variable) + `((eq? message ',variable) (lambda () ,variable))) + (append (cdr (car form)) + (variable-list 'instance-vars form) + (variable-list 'class-vars form))))) + +(define (method-clauses form) + (map + (lambda (method-defn) + (let ((this-message (car (cadr method-defn))) + (args (cdr (cadr method-defn))) + (body (cddr method-defn))) + `((eq? message ',this-message) + (lambda ,args ,@body)))) + (obj-filter (cdr form) (lambda (x) (eq? (car x) 'method))) )) + +(define (parent-list form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map (lambda (class) (maknam 'my- class)) + (map car (cdr parent-clause)))))) + +(define (usual-clause form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + `((eq? message 'send-usual-to-parent) + (error "Can't use USUAL without a parent." ',(class-name form))) + `((eq? message 'send-usual-to-parent) + (lambda (message . args) + (let ((method (get-method ',(class-name form) + message + ,@(parent-list form)))) + (if (method? method) + (apply method args) + (error "No USUAL method" message ',(class-name form)) ))))))) + +(define (else-clause form) + (let ((parent-clause (find-a-clause 'parent form)) + (default-method (find-a-clause 'default-method form))) + (cond + ((and (null? parent-clause) (null? default-method)) + `(else (no-method ',(class-name form)))) + ((null? parent-clause) + `(else (lambda args ,@(cdr default-method)))) + ((null? default-method) + `(else (get-method ',(class-name form) message ,@(parent-list form))) ) + (else + `(else (let ((method (get-method ',(class-name form) + message + ,@(parent-list form)))) + (if (method? method) + method + (lambda args ,@(cdr default-method)) ))))))) + +(define (find-a-clause clause-name form) + (let ((clauses (obj-filter (cdr form) + (lambda (x) (eq? (car x) clause-name))))) + (cond ((null? clauses) '()) + ((null? (cdr clauses)) (car clauses)) + (else (error "Error in define-class: too many " + clause-name "clauses.")) ))) + +(define (obj-filter l pred) + (cond ((null? l) '()) + ((pred (car l)) + (cons (car l) (obj-filter (cdr l) pred))) + (else (obj-filter (cdr l) pred)))) + +(provide "obj") diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/small-world.scm b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/small-world.scm new file mode 100644 index 0000000..dcd6bd1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project3/small-world.scm @@ -0,0 +1,28 @@ +;;; small-world.scm +;;; Miniature game world for debugging the CS61A adventure game project. +;;; You can load this instead of adv-world.scm, and reload it quickly +;;; whenever you change a class. + +;;; How to use this file: +;;; If, for example, your person class doesn't work, and you do something +;;; like (define Matt (instantiate person 'Matt)), and then fix your +;;; person class definition, Matt is still bound to the faulty person +;;; object from before. However, reloading this file whenever you +;;; change something should redefine everything in your world with the +;;; currently loaded (i.e. most recent) versions of your classes. + +(define 61A-Lab (instantiate place '61A-Lab)) +(define Lounge (instantiate place 'Lounge)) +(can-go 61A-Lab 'up Lounge) +(can-go Lounge 'down 61A-Lab) +;;; Hopefully you'll see more of the world than this in real life +;;; while you're doing the project! + +(define homework-box (instantiate thing 'homework-box)) +(ask 61A-Lab 'appear homework-box) + +(define Coke (instantiate thing 'Coke)) +(ask Lounge 'appear Coke) + +(define laba (instantiate person 'Lab-assistant 61A-Lab)) + diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project4/logo-meta.scm b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project4/logo-meta.scm new file mode 100644 index 0000000..f66afdc --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project4/logo-meta.scm @@ -0,0 +1,371 @@ +;;; logo-meta.scm Part of programming project #4 + +;;; Differences between the book and this version: Eval and apply have +;;; been changed to logo-eval and logo-apply so as not to overwrite the Scheme +;;; versions of these routines. An extra procedure initialize-logo has been +;;; added. This routine resets the global environment and then executes the +;;; driver loop. This procedure should be invoked to start the Logo +;;; evaluator executing. Note: It will reset your global environment and all +;;; definitions to the Logo interpreter will be lost. To restart the Logo +;;; interpreter without resetting the global environment, just invoke +;;; driver-loop. Don't forget that typing control-C will get you out of +;;; the Logo evaluator back into Scheme. + +;;; Problems A1, A2, and B2 are entirely in logo.scm +;;; Problems 3, 7, and up require you to find and change existing procedures. + +;;; Procedures that you must write from scratch: + +;;; Problem B1 eval-line + +(define (eval-line line-obj env) + (error "eval-line not written yet!")) + + +;;; Problem 4 variables (other procedures must be modified, too) +;;; data abstraction procedures + +(define (variable? exp) + #f) ;; not written yet but we fake it for now + +(define (variable-name exp) + (error "variable-name not written yet!")) + + +;;; Problem A5 handle-infix + +(define (de-infix token) + (cdr (assoc token '((+ . sum) + (- . difference) + (* . product) + (/ . quotient) + (= . equalp) + (< . lessp) + (> . greaterp))))) + +(define (handle-infix value line-obj env) + value) ;; This doesn't give an error message, so other stuff works. + + +;;; Problem B5 eval-definition + +(define (eval-definition line-obj) + (error "eval-definition not written yet!")) + + +;;; Problem 6 eval-sequence + +(define (eval-sequence exps env) + (error "eval-sequence not written yet!")) + + + + +;;; SETTING UP THE ENVIRONMENT + +(define the-primitive-procedures '()) + +(define (add-prim name count proc) + (set! the-primitive-procedures + (cons (list name 'primitive count proc) + the-primitive-procedures))) + +(add-prim 'first 1 first) +(add-prim 'butfirst 1 bf) +(add-prim 'bf 1 bf) +(add-prim 'last 1 last) +(add-prim 'butlast 1 bl) +(add-prim 'bl 1 bl) +(add-prim 'word 2 word) +(add-prim 'sentence 2 se) +(add-prim 'se 2 se) +(add-prim 'list 2 list) +(add-prim 'fput 2 cons) + +(add-prim 'sum 2 (make-logo-arith +)) +(add-prim 'difference 2 (make-logo-arith -)) +(add-prim '=unary-minus= 1 (make-logo-arith -)) +(add-prim '- 1 (make-logo-arith -)) +(add-prim 'product 2 (make-logo-arith *)) +(add-prim 'quotient 2 (make-logo-arith /)) +(add-prim 'remainder 2 (make-logo-arith remainder)) + +(add-prim 'print 1 logo-print) +(add-prim 'pr 1 logo-print) +(add-prim 'show 1 logo-show) +(add-prim 'type 1 logo-type) +(add-prim 'make '(2) make) + +(add-prim 'run '(1) run) +(add-prim 'if '(2) logo-if) +(add-prim 'ifelse '(3) ifelse) +(add-prim 'equalp 2 (logo-pred (make-logo-arith equalp))) +(add-prim 'lessp 2 (logo-pred (make-logo-arith <))) +(add-prim 'greaterp 2 (logo-pred (make-logo-arith >))) +(add-prim 'emptyp 1 (logo-pred empty?)) +(add-prim 'numberp 1 (logo-pred (make-logo-arith number?))) +(add-prim 'listp 1 (logo-pred list?)) +(add-prim 'wordp 1 (logo-pred (lambda (x) (not (list? x))))) + +(add-prim 'stop 0 (lambda () '=stop=)) +(add-prim 'output 1 (lambda (x) (cons '=output= x))) +(add-prim 'op 1 (lambda (x) (cons '=output= x))) + +(define (pcmd proc) (lambda args (apply proc args) '=no-value=)) +(add-prim 'cs 0 (pcmd cs)) +(add-prim 'clearscreen 0 (pcmd cs)) +(add-prim 'fd 1 (pcmd fd)) +(add-prim 'forward 1 (pcmd fd)) +(add-prim 'bk 1 (pcmd bk)) +(add-prim 'back 1 (pcmd bk)) +(add-prim 'lt 1 (pcmd lt)) +(add-prim 'left 1 (pcmd lt)) +(add-prim 'rt 1 (pcmd rt)) +(add-prim 'right 1 (pcmd rt)) +(add-prim 'setxy 2 (pcmd setxy)) +(add-prim 'setx 1 (lambda (x) (setxy x (ycor)) '=no-value=)) +(add-prim 'sety 1 (lambda (y) (setxy (xcor) y) '=no-value=)) +(add-prim 'xcor 0 xcor) +(add-prim 'ycor 0 ycor) +(add-prim 'pos 0 pos) +(add-prim 'seth 1 (pcmd setheading)) +(add-prim 'setheading 1 (pcmd setheading)) +(add-prim 'heading 0 heading) +(add-prim 'st 0 (pcmd st)) +(add-prim 'showturtle 0 (pcmd st)) +(add-prim 'ht 0 (pcmd ht)) +(add-prim 'hideturtle 0 (pcmd ht)) +(add-prim 'shown? 0 shown?) +(add-prim 'pd 0 (pcmd pendown)) +(add-prim 'pendown 0 (pcmd pendown)) +(add-prim 'pu 0 (pcmd penup)) +(add-prim 'penup 0 (pcmd penup)) +(add-prim 'pe 0 (pcmd penerase)) +(add-prim 'penerase 0 (pcmd penerase)) +(add-prim 'home 0 (pcmd home)) +(add-prim 'setpc 1 (pcmd setpc)) +(add-prim 'setpencolor 1 (pcmd setpc)) +(add-prim 'pc 0 pc) +(add-prim 'pencolor 0 pc) +(add-prim 'setbg 1 (pcmd setbg)) +(add-prim 'setbackground 1 (pcmd setbg)) + +(add-prim 'load 1 meta-load) + +(define the-global-environment '()) +(define the-procedures the-primitive-procedures) + +;;; INITIALIZATION AND DRIVER LOOP + +;;; The following code initializes the machine and starts the Logo +;;; system. You should not call it very often, because it will clobber +;;; the global environment, and you will lose any definitions you have +;;; accumulated. + +(define (initialize-logo) + (set! the-global-environment (extend-environment '() '() '())) + (set! the-procedures the-primitive-procedures) + (driver-loop)) + +(define (driver-loop) + (define (helper) + (prompt "? ") + (let ((line (logo-read))) + (if (not (null? line)) + (let ((result (eval-line (make-line-obj line) + the-global-environment))) + (if (not (eq? result '=no-value=)) + (logo-print (list "You don't say what to do with" result)))))) + (helper)) + (logo-read) + (helper)) + +;;; APPLYING PRIMITIVE PROCEDURES + +;;; To apply a primitive procedure, we ask the underlying Scheme system +;;; to perform the application. (Of course, an implementation on a +;;; low-level machine would perform the application in some other way.) + +(define (apply-primitive-procedure p args) + (apply (text p) args)) + + +;;; Now for the code that's based on the book!!! + + +;;; Section 4.1.1 + +;; Given an expression like (proc :a :b :c)+5 +;; logo-eval calls eval-prefix for the part in parentheses, and then +;; handle-infix to check for and process the infix arithmetic. +;; Eval-prefix is comparable to Scheme's eval. + +(define (logo-eval line-obj env) + (handle-infix (eval-prefix line-obj env) line-obj env)) + +(define (eval-prefix line-obj env) + (define (eval-helper paren-flag) + (let ((token (ask line-obj 'next))) + (cond ((self-evaluating? token) token) + ((variable? token) + (lookup-variable-value (variable-name token) env)) + ((quoted? token) (text-of-quotation token)) + ((definition? token) (eval-definition line-obj)) + ((left-paren? token) + (let ((result (handle-infix (eval-helper #t) + line-obj + env))) + (let ((token (ask line-obj 'next))) + (if (right-paren? token) + result + (error "Too much inside parens"))))) + ((right-paren? token) + (error "Unexpected ')'")) + (else + (let ((proc (lookup-procedure token))) + (if (not proc) (error "I don't know how to " token)) + (logo-apply proc + (collect-n-args (arg-count proc) + line-obj + env) ))) ))) + (eval-helper #f)) + +(define (logo-apply procedure arguments) + (cond ((primitive-procedure? procedure) + (apply-primitive-procedure procedure arguments)) + ((compound-procedure? procedure) + (error "Compound procedures not implemented yet.")) + (else + (error "Unknown procedure type -- LOGO-APPLY " procedure)))) + +(define (collect-n-args n line-obj env) + (cond ((= n 0) '()) + ((and (< n 0) (not (ask line-obj 'empty?))) + (let ((token (ask line-obj 'next))) + (ask line-obj 'put-back token) + (if (right-paren? token) + '() + (let ((next (logo-eval line-obj env))) + (cons next + (collect-n-args (- n 1) line-obj env)) )))) + (else + (let ((next (logo-eval line-obj env))) + (cons next + (collect-n-args (- n 1) line-obj env)) )))) + +;;; Section 4.1.2 -- Representing expressions + +;;; numbers + +(define (self-evaluating? exp) (number? exp)) + +;;; quote + +(define (quoted? exp) + (or (list? exp) + (eq? (string-ref (word->string (first exp)) 0) #\"))) + +(define (text-of-quotation exp) + (if (list? exp) + exp + (bf exp))) + +;;; parens + +(define (left-paren? exp) (eq? exp left-paren-symbol)) + +(define (right-paren? exp) (eq? exp right-paren-symbol)) + +;;; definitions + +(define (definition? exp) + (eq? exp 'to)) + +;;; procedures + +(define (lookup-procedure name) + (assoc name the-procedures)) + +(define (primitive-procedure? p) + (eq? (cadr p) 'primitive)) + +(define (compound-procedure? p) + (eq? (cadr p) 'compound)) + +(define (arg-count proc) + (caddr proc)) + +(define (text proc) + (cadddr proc)) + +(define (parameters proc) (car (text proc))) + +(define (procedure-body proc) (cdr (text proc))) + +;;; Section 4.1.3 + +;;; Operations on environments + +(define (enclosing-environment env) (cdr env)) + +(define (first-frame env) (car env)) + +(define the-empty-environment '()) + +(define (make-frame variables values) + (cons variables values)) + +(define (frame-variables frame) (car frame)) +(define (frame-values frame) (cdr frame)) + +(define (add-binding-to-frame! var val frame) + (set-car! frame (cons var (car frame))) + (set-cdr! frame (cons val (cdr frame)))) + +(define (extend-environment vars vals base-env) + (if (= (length vars) (length vals)) + (cons (make-frame vars vals) base-env) + (if (< (length vars) (length vals)) + (error "Too many arguments supplied " vars vals) + (error "Too few arguments supplied " vars vals)))) + +(define (lookup-variable-value var env) + (define (env-loop env) + (define (scan vars vals) + (cond ((null? vars) + (env-loop (enclosing-environment env))) + ((equal? var (car vars)) + (car vals)) + (else (scan (cdr vars) (cdr vals))))) + (if (eq? env the-empty-environment) + (error "Unbound variable " var) + (let ((frame (first-frame env))) + (scan (frame-variables frame) + (frame-values frame))))) + (env-loop env)) + +(define (set-variable-value! var val env) + (define (env-loop env) + (define (scan vars vals) + (cond ((null? vars) + (env-loop (enclosing-environment env))) + ((equal? var (car vars)) + (set-car! vals val)) + (else (scan (cdr vars) (cdr vals))))) + (if (eq? env the-empty-environment) + (error "Unbound variable -- SET! " var) + (let ((frame (first-frame env))) + (scan (frame-variables frame) + (frame-values frame))))) + (env-loop env)) + +(define (define-variable! var val env) + (let ((frame (first-frame env))) + (define (scan vars vals) + (cond ((null? vars) + (add-binding-to-frame! var val frame)) + ((equal? var (car vars)) + (set-car! vals val)) + (else (scan (cdr vars) (cdr vals))))) + (scan (frame-variables frame) + (frame-values frame)))) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project4/logo.scm b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project4/logo.scm new file mode 100644 index 0000000..d957e7f --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project4/logo.scm @@ -0,0 +1,179 @@ +;;; logo.scm part of programming project #4 + + +;;; Problem A1 make-line-obj + +(define (make-line-obj text) + (error "make-line-obj not written yet!")) + + +;;; Problem A2 logo-type + +(define (logo-type val) + (error "logo-type not written yet!")) + +(define (logo-print val) + (logo-type val) + (newline) + '=no-value=) + +(define (logo-show val) + (logo-print (list val))) + + + +;;; Problem 4 variables (logo-meta.scm is also affected) + +(define (make env var val) + (error "make not written yet!") + '=no-value=) + + +;;; Here are the primitives RUN, IF, and IFELSE. Problem B2 provides +;;; support for these, but you don't have to modify them. + +(define (run env exp) + (eval-line (make-line-obj exp) env)) + +(define (logo-if env t/f exp) + (cond ((eq? t/f 'true) (eval-line (make-line-obj exp) env)) + ((eq? t/f 'false) '=no-value=) + (else (error "Input to IF not true or false " t/f)))) + +(define (ifelse env t/f exp1 exp2) + (cond ((eq? t/f 'true) (eval-line (make-line-obj exp1) env)) + ((eq? t/f 'false) (eval-line (make-line-obj exp2) env)) + (else (error "Input to IFELSE not true or false " t/f)))) + + +;;; Problem B2 logo-pred + +(define (logo-pred pred) + pred) ;; This isn't written yet but we fake it for now. + + +;;; Here is an example of a Scheme predicate that will be turned into +;;; a Logo predicate by logo-pred: + +(define (equalp a b) + (if (and (number? a) (number? b)) + (= a b) + (equal? a b))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Stuff below here is needed for the interpreter to work but you ;;; +;;; don't have to modify anything or understand how they work. ;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;;; The Logo reader + +(define left-paren-symbol (string->symbol (make-string 1 #\( ))) +(define right-paren-symbol (string->symbol (make-string 1 #\) ))) +(define quote-symbol (string->symbol (make-string 1 #\" ))) + +(define (logo-read) + (define lookahead #f) + (define (logo-read-help depth) + (define (get-char) + (if lookahead + (let ((char lookahead)) + (set! lookahead #f) + char) + (let ((char (read-char))) + (if (eq? char #\\) + (list (read-char)) + char)))) + (define (quoted char) + (if (pair? char) + char + (list char))) + (define (get-symbol char) + (define (iter sofar char) + (cond ((pair? char) (iter (cons (car char) sofar) (get-char))) + ((memq char + '(#\space #\newline #\+ #\- #\* #\/ + #\= #\< #\> #\( #\) #\[ #\] )) + (set! lookahead char) + sofar) + (else (iter (cons char sofar) (get-char))) )) + (string->word (list->string (reverse (iter '() char)))) ) + (define (get-token space-flag) + (let ((char (get-char))) + (cond ((eq? char #\space) (get-token #t)) + ((memq char '(#\+ #\* #\/ #\= #\< #\> #\( #\) )) + (string->symbol (make-string 1 char))) + ((eq? char #\-) + (if space-flag + (let ((char (get-char))) + (let ((result (if (eq? char #\space) + '- + '=unary-minus=))) + (set! lookahead char) + result)) + '-)) + ((eq? char #\[) (logo-read-help (+ depth 1))) + ((pair? char) (get-symbol char)) + ((eq? char #\") + (let ((char (get-char))) + (if (memq char '(#\[ #\] #\newline)) + (begin (set! lookahead char) quote-symbol) + (string->symbol (word quote-symbol + (get-symbol (quoted char))))))) + (else (get-symbol char)) ))) + + (define (after-space) + (let ((char (get-char))) + (if (eq? char #\space) + (after-space) + char))) + (let ((char (get-char))) + (cond ((eq? char #\newline) + (if (> depth 0) (set! lookahead char)) + '()) + ((eq? char #\space) + (let ((char (after-space))) + (cond ((eq? char #\newline) + (begin (if (> depth 0) (set! lookahead char)) + '())) + ((eq? char #\]) + (if (> depth 0) '() (error "Unexpected ]"))) + (else (set! lookahead char) + (let ((token (get-token #t))) + (cons token (logo-read-help depth))))))) + ((eq? char #\]) + (if (> depth 0) '() (error "Unexpected ]"))) + ((eof-object? char) char) + (else (set! lookahead char) + (let ((token (get-token #f))) + (cons token (logo-read-help depth)) ))))) + (logo-read-help 0)) + + +;;; Assorted stuff + +(define (make-logo-arith op) + (lambda args (apply op (map maybe-num args)))) + +(define (maybe-num val) + (if (word? val) + (string->word (word->string val)) + val)) + +(define tty-port (current-input-port)) + +(define (prompt string) + (if (eq? (current-input-port) tty-port) + (begin (display string) (flush)))) + +(define (meta-load fn) + (define (loader) + (let ((exp (logo-read))) + (if (eof-object? exp) + '() + (begin (eval-line (make-line-obj exp) + the-global-environment) + (loader))))) + (with-input-from-file (symbol->string fn) loader) + '=no-value=) diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project4/obj.scm b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project4/obj.scm new file mode 100644 index 0000000..d4a9d7a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/Project4/obj.scm @@ -0,0 +1,279 @@ +;;; obj.scm version 4.0 5/18/2000 +;;; -- implementation of the object-oriented syntax +;; By Matt Wright, based on a handout from MIT +;; Revised for STk by Brian Gaeke - removed scm and procedure->macro + +;;; Utilities + +;; MAKNAM: create a new symbol whose name is the concatenation of the +;; names of those in the symbol list SYMBOLS. +(define (maknam . symbols) + (string->symbol (apply string-append (map symbol->string symbols)))) + +;; ASK: send a message to an object + +; The dot in the first line of the definition of ASK, below, makes it +; take a variable number of arguments. The first argument is associated +; with the formal parameter OBJECT; the second with MESSAGE; any extra +; actual arguments are put in a list, and that list is associated with +; the formal parameter ARGS. (If there are only two actual args, then +; ARGS will be the empty list.) + +; APPLY takes two arguments, a procedure and a list, and applies the +; procedure to the things in the list, which are used as actual +; argument values. + +(define (ask object message . args) + (let ((method (object message))) + (if (method? method) + (apply method args) + (error "No method " message " in class " (cadr method))))) + +(define (no-method name) + (list 'no-method name)) + +(define (no-method? x) + (if (pair? x) + (eq? (car x) 'no-method) + #f)) + +(define (method? x) + (not (no-method? x))) + + +;; INSTANTIATE and INSTANTIATE-PARENT: Create an instance of a class + +; The difference is that only INSTANTIATE initializes the new object + +(define (instantiate class . arguments) + (let ((new-instance (apply (class 'instantiate) arguments))) + (ask new-instance 'initialize new-instance) + new-instance)) + +(define (instantiate-parent class . arguments) + (apply (class 'instantiate) arguments)) + +;; GET-METHOD: Send a message to several objects and return the first +;; method found (for multiple inheritance) + +(define (get-method give-up-name message . objects) + (if (null? objects) + (no-method give-up-name) + (let ((method ((car objects) message))) + (if (method? method) + method + (apply get-method (cons give-up-name + (cons message (cdr objects)) )))))) + + + +;; USUAL: Invoke a parent's method +;; Note: The 'send-usual-to-parent method is put in automatically by +;; define-class. + +(define-macro (usual . args) + `(ask dispatch 'send-usual-to-parent . ,args)) + + +;; DEFINE-CLASS: Create a new class. + +; DEFINE-CLASS is a special form. When you type (define-class body...) +; it's as if you typed (make-definitions (quote body...)). In other +; words, the argument to DEFINE-CLASS isn't evaluated. This makes sense +; because the argument isn't Scheme syntax, but rather is the special +; object-oriented programming language we're defining. +; Make-definitions transforms the OOP notation into a standard Scheme +; expression, then uses EVAL to evaluate the result. (You'll see EVAL +; again in chapter 4 with the metacircular evaluator.) + +; When you define a class named THING, for example, two global Scheme +; variables are created. The variable THING has as its value the +; procedure that represents the class. This procedure is invoked by +; INSTANTIATE to create instances of the class. A second variable, +; THING-DEFINITION, has as its value the text of the Scheme expression +; that defines THING. This text is used only by SHOW-CLASS, the +; procedure that lets you examine the result of the OOP-to-Scheme +; translation process. + +(define-macro (define-class . body) (make-definitions body)) + +(define (make-definitions form) + (let ((definition (translate form))) + (eval `(define ,(maknam (class-name form) '-definition) ',definition)) + (eval definition) + (list 'quote (class-name form)))) + +(define (show-class name) + (eval (maknam name '-definition)) ) + +; TRANSLATE does all the work of DEFINE-CLASS. +; The backquote operator (`) works just like regular quote (') except +; that expressions proceeded by a comma are evaluated. Also, expressions +; proceeded by ",@" evaluate to lists; the lists are inserted into the +; text without the outermost level of parentheses. + +(define (translate form) + (cond ((null? form) (error "Define-class: empty body")) + ((not (null? (obj-filter form (lambda (x) (not (pair? x)))))) + (error "Each argument to define-class must be a list")) + ((not (null? (extra-clauses form))) + (error "Unrecognized clause in define-class:" (extra-clauses form))) + (else + `(define ,(class-name form) + (let ,(class-var-bindings form) + (lambda (class-message) + (cond + ,@(class-variable-methods form) + ((eq? class-message 'instantiate) + (lambda ,(instantiation-vars form) + (let ((self '()) + ,@(parent-let-list form) + ,@(instance-vars-let-list form)) + (define (dispatch message) + (cond + ,(init-clause form) + ,(usual-clause form) + ,@(method-clauses form) + ,@(local-variable-methods form) + ,(else-clause form) )) + dispatch ))) + (else (error "Bad message to class" class-message)) ))))))) + +(define *legal-clauses* + '(instance-vars class-vars method default-method parent initialize)) + +(define (extra-clauses form) + (obj-filter (cdr form) + (lambda (x) (null? (member (car x) *legal-clauses*))))) + +(define class-name caar) + +(define (class-var-bindings form) + (let ((classvar-clause (find-a-clause 'class-vars form))) + (if (null? classvar-clause) + '() + (cdr classvar-clause) ))) + +(define instantiation-vars cdar) + +(define (parent-let-list form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map (lambda (parent-and-args) + (list (maknam 'my- (car parent-and-args)) + (cons 'instantiate-parent parent-and-args))) + (cdr parent-clause))))) + +(define (instance-vars-let-list form) + (let ((instance-vars-clause (find-a-clause 'instance-vars form))) + (if (null? instance-vars-clause) + '() + (cdr instance-vars-clause)))) + +(define (init-clause form) + (define (parent-initialization form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map + (lambda (parent-and-args) + `(ask ,(maknam 'my- (car parent-and-args)) 'initialize self) ) + (cdr parent-clause) )))) + (define (my-initialization form) + (let ((init-clause (find-a-clause 'initialize form))) + (if (null? init-clause) '() + (cdr init-clause)))) + (define (init-body form) + (append (parent-initialization form) + (my-initialization form) )) + + `((eq? message 'initialize) + (lambda (value-for-self) + (set! self value-for-self) + ,@(init-body form) ))) + +(define (variable-list var-type form) + (let ((clause (find-a-clause var-type form))) + (if (null? clause) + '() + (map car (cdr clause)) ))) + +(define (class-variable-methods form) + (cons `((eq? class-message 'class-name) (lambda () ',(class-name form))) + (map (lambda (variable) + `((eq? class-message ',variable) (lambda () ,variable))) + (variable-list 'class-vars form)))) + +(define (local-variable-methods form) + (cons `((eq? message 'class-name) (lambda () ',(class-name form))) + (map (lambda (variable) + `((eq? message ',variable) (lambda () ,variable))) + (append (cdr (car form)) + (variable-list 'instance-vars form) + (variable-list 'class-vars form))))) + +(define (method-clauses form) + (map + (lambda (method-defn) + (let ((this-message (car (cadr method-defn))) + (args (cdr (cadr method-defn))) + (body (cddr method-defn))) + `((eq? message ',this-message) + (lambda ,args ,@body)))) + (obj-filter (cdr form) (lambda (x) (eq? (car x) 'method))) )) + +(define (parent-list form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + '() + (map (lambda (class) (maknam 'my- class)) + (map car (cdr parent-clause)))))) + +(define (usual-clause form) + (let ((parent-clause (find-a-clause 'parent form))) + (if (null? parent-clause) + `((eq? message 'send-usual-to-parent) + (error "Can't use USUAL without a parent." ',(class-name form))) + `((eq? message 'send-usual-to-parent) + (lambda (message . args) + (let ((method (get-method ',(class-name form) + message + ,@(parent-list form)))) + (if (method? method) + (apply method args) + (error "No USUAL method" message ',(class-name form)) ))))))) + +(define (else-clause form) + (let ((parent-clause (find-a-clause 'parent form)) + (default-method (find-a-clause 'default-method form))) + (cond + ((and (null? parent-clause) (null? default-method)) + `(else (no-method ',(class-name form)))) + ((null? parent-clause) + `(else (lambda args ,@(cdr default-method)))) + ((null? default-method) + `(else (get-method ',(class-name form) message ,@(parent-list form))) ) + (else + `(else (let ((method (get-method ',(class-name form) + message + ,@(parent-list form)))) + (if (method? method) + method + (lambda args ,@(cdr default-method)) ))))))) + +(define (find-a-clause clause-name form) + (let ((clauses (obj-filter (cdr form) + (lambda (x) (eq? (car x) clause-name))))) + (cond ((null? clauses) '()) + ((null? (cdr clauses)) (car clauses)) + (else (error "Error in define-class: too many " + clause-name "clauses.")) ))) + +(define (obj-filter l pred) + (cond ((null? l) '()) + ((pred (car l)) + (cons (car l) (obj-filter (cdr l) pred))) + (else (obj-filter (cdr l) pred)))) + +(provide "obj") diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume1/hw.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/hw.pdf new file mode 100644 index 0000000..4bf9a8c --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume1/hw.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/CS 61A Course Reader, Volume 2.html b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/CS 61A Course Reader, Volume 2.html new file mode 100644 index 0000000..56f5a05 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/CS 61A Course Reader, Volume 2.html @@ -0,0 +1,154 @@ +<html><head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>CS 61A Course Reader, Volume 2</title><style type="text/css">@namespace url(http://www.w3.org/1999/xhtml); +@font-face { + font-family: 'EasyRead2'; + font-style: normal; + font-weight: 400; + src: local('EasyRead2'), url(https://cdn.rawgit.com/PullJosh/files/gh-pages/Arial-LargePeriod2.woff) format('woff'); +}input[type="text"], input[type="textarea"], textarea { + font-family: "EasyRead2" !important; + }</style></head> +<body> + +<center> +<h1> CS61A: Structure and Interpretation of Computer Programs </h1> +<h3> Course Reader, Volume 2: Reference Documents </h3> +</center> + +<p><b>These documents are here for online reference! Please do not print +these on the printers in Berkeley computer labs. Lab printers are for your +homework and project solutions, not for reference documents. Thank you.</b> + +</p><p>For many years I resisted the trend to putting course materials online, +but I've been convinced because of the increasing numbers of people who +aren't at Berkeley but use the +<a href="http://wla.berkeley.edu/main.php?course=cs61a">online lectures</a> +to study SICP. Welcome, visitors! + +</p><ul> +<li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/OOP/aboveline.pdf"> +Object-Oriented Programming: Above the Line View</a> +</li><li> <a href="OOP/ref-man.pdf"> +Reference Manual for the OOP Language</a> +</li><li><a href="OOP/belowline.pdf"> +Object-Oriented Programming: Below the Line View</a> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/gnuemacs.pdf"> +Highlights of GNU Emacs</a><sup>*</sup> +</li><li> <a href="quick.pdf"> +Emacs Quick Reference Guide</a><sup>*</sup> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/exit.pdf"> +Exit Information (Read at end of semester!)</a> +</li><li><a href="Therac-25.pdf"> +An Investigation of the Therac-25 Accidents</a><sup>**</sup> +</li><li><a href="r5rs.pdf"> +Revised<sup>5</sup> Report on Scheme</a><sup>***</sup><br /> +(the last <i>real</i> version of Scheme before its hostile takeover +by industrial programmers) +</li><li><a href="mapreduce-osdi04.pdf"> +MapReduce: Simplified Data Processing on Large Clusters</a><sup>****</sup> +</li><li>Sample Exams: +<ul> +<li><b>Please read this:</b> + +<p>These exams are made up of actual past exam questions, but reorganized to +make each sample more comprehensive and to choose the best possible questions. +Some of the exams are a little longer (by one question) than actual exams, but +they're in the right ballpark. + +</p><p>Since the questions within a sample are taken from different semesters, +don't try to compare the number of points between problems. The solutions +include scoring information only to give you an idea of how part credit is +awarded within each problem. + +</p></li><li>Midterm 1 +<ul> +<li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/Midterm1/mt1-1.pdf"> +Sample exam 1</a> +</li><li><a href="Midterm1/mt1-1.soln.txt"> +Solutions to sample exam 1</a> +</li><li><a href="Midterm1/mt1-2.pdf"> +Sample exam 2</a> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/Midterm1/mt1-2.soln.txt"> +Solutions to sample exam 2</a> +</li><li><a href="Midterm1/mt1-3.pdf"> +Sample exam 3</a> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/Midterm1/mt1-3.soln.txt"> +Solutions to sample exam 3</a> +</li></ul> +</li><li>Midterm 2 +<ul> +<li><a href="Midterm2/mt2-1.pdf"> +Sample exam 1</a> +</li><li><a href="Midterm2/mt2-1.soln.txt"> +Solutions to sample exam 1</a> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/Midterm2/mt2-2.pdf"> +Sample exam 2</a> +</li><li><a href="Midterm2/mt2-2.soln.txt"> +Solutions to sample exam 2</a> +</li><li><a href="Midterm2/mt2-3.pdf"> +Sample exam 3</a> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/Midterm2/mt2-3.soln.txt"> +Solutions to sample exam 3</a> +</li></ul> +</li><li>Midterm 3 +<ul> +<li><a href="Midterm3/mt3-1.pdf"> +Sample exam 1</a> +</li><li><a href="Midterm3/mt3-1.soln.txt"> +Solutions to sample exam 1</a> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/Midterm3/mt3-2.pdf"> +Sample exam 2</a> +</li><li><a href="Midterm3/mt3-2.soln.txt"> +Solutions to sample exam 2</a> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/Midterm3/mt3-3.pdf"> +Sample exam 3</a> +</li><li><a href="Midterm3/mt3-3.soln.txt"> +Solutions to sample exam 3</a> +</li></ul> +</li><li>Final exam +<ul> +<li><a href="Final/f-1.pdf"> +Sample exam 1</a> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/Final/f-1.soln.txt"> +Solutions to sample exam 1</a> +</li><li><a href="Final/f-2.pdf"> +Sample exam 2</a> +</li><li><a href="Final/f-2.soln.txt"> +Solutions to sample exam 2</a> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/Final/f-3.pdf"> +Sample exam 3</a> +</li><li><a href="Final/f-3.soln.txt"> +Solutions to sample exam 3</a> +</li></ul> +</li></ul> +</li><li><a href="mapreduce-osdi04.pdf"> +Mapreduce: Simplified Data Processing on Large Clusters</a><sup>****</sup> +</li><li><a href="https://people.eecs.berkeley.edu/~bh/61a-pages/Volume2/notes.pdf"> +Lecture Notes</a> +</li><li><a href="sicp-errata.txt"> +SICP Errata</a><sup>*****</sup> +</li><li><a href="word.txt"> +Berkeley Word/Sentence Functions</a> +</li><li>Ergonomic Information (external links): +<ul> +<li><a href="https://www.uhs.umich.edu/computerergonomics"> +Computer Workstation Ergonomics (UMich)</a> +</li><li><a href="https://www.ors.od.nih.gov/sr/dohs/HealthAndWellness/Ergonomics/Pages/ergonomics_home.aspx"> +Ergonomics (NIH DOHS)</a> +</li></ul> +</li></ul> + +<p> +*: Prof. Paul Hilfinger, UCB EECS<br> +**: Nancy G. Leveson, Clark S. Turner. IEEE <cite>Computer</cite>, July 1993<br> +***: Richard Kelsey, William Clinger, Jonathan Rees (Editors), et al., 1998<br> +****: Jeffrey Dean, Sanjay Ghemawat, Google, Inc., OSDI 2004<br> +*****: Harold Abelson, Gerald Jay Sussman, Julie Sussman, 1999 +</p><p> +</p><p> +</p><p> +</p><p><a href="../Volume1/CS 61A Course Reader, Volume 1.html">Volume 1</a> +</p><p><a href="../../61a-pages">Back to class web page</a> + + +</p></body></html> diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-1.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-1.pdf new file mode 100644 index 0000000..65ea079 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-1.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-2.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-2.pdf new file mode 100644 index 0000000..d5d8ddb --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-2.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-2.soln.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-2.soln.txt new file mode 100644 index 0000000..4f1a8a1 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-2.soln.txt @@ -0,0 +1,540 @@ +CS 61A Solutions to sample final exam #2 + +1. HOFs in 21 project + +A higher order procedure is one that uses procedures as data -- either as +arguments or as its return value. Many people forgot about the latter. + +BEST-TOTAL takes a hand (a sentence) as argument and returns a number. +No procedures; not higher order. + +STOP-AT-17 takes a hand (a sentence) and a card (a word) as arguments, +returning #T or #F. No procedures; not higher order. + +PLAY-N takes a strategy (which is a procedure!) and a number as arguments, +returning a score. It's higher order. + +STOP-AT takes a number as argument, returning a strategy -- a procedure. +So it's higher order. + +MAJORITY takes three strategies as arguments and returns a strategy. +Clearly higher order! + + +Scoring: 2 points if correct; 1 point if all but one correct (usually +leaving out STOP-AT). + + +2. Foo and baz. + +(foo 3) ==> (if 3 (foo #f) 5) + ==> (foo #f) + ==> (if #f (foo #f) 5) + ==> 5 + +(baz 3) ==> (and 3 (baz #f) 5) + ==> (and (baz #f) 5) ; since 3 is true + ==> (and (and #f (baz #f) 5) 5) + ==> (and #f 5) ; inner AND is false + ==> #f + +Scoring: 1 point each. + + +3. Iterative and recursive. + +FOO is iterative; BAZ is recursive. + +In FOO, when IF decides to evaluate (foo #f), it already knows that whatever +the answer from (foo #f) is will be the answer to the entire problem. + +In BAZ, after the (baz #f) returns, AND must check whether the answer is +true or false. If false (as, in fact, it is), then indeed the answer to +(baz #f) is also the answer to (baz 3). But AND didn't know that until the +recursive call is complete! If (baz #f) had been true, the answer would +have been 5. + +A good one-sentence answer: "An iterative process is one in which +the caller has no more work to do once the recursive callee returns." + +Many people quoted sentences from the book, often the one about "deferred +operations"; we accepted these if it sounded as if you might have some idea +what it actually meant. + +Some people quoted a sentence about how something "depends on the return +value" but mostly these answers were wrong: the answer to the overall +problem does depend, in both cases, on the answer to the recursive call. +The question is whether it also depends on anything else! + +Worst of all was "FOO is iterative because IF is a special form." +Sorry -- AND is a special form, too! + +Scoring: 2 points if you had FOO iterative and BAZ recursive, with a +convincing sentence. 1 point if you had FOO iterative and BAZ recursive. +(If you had FOO recursive and/or BAZ iterative, we didn't even read your +sentence.) + + +4. How are the pairs connected? + +We know that A's box and pointer diagram looks like this: + +A --> [1 . -]---> [2 . -]---> [ | . -]---> [6 . /] + | + V + [3 . -]---> [4 . -]---> [5 . /] + +We also know that (CDDR B) is the same pair as (CADDR A), which is the pair +whose car is 3. Therefore the list (3 4 5) is shared between A and B, so +the diagram is + +A --> [1 . -]---> [2 . -]---> [ | . -]---> [6 . /] + | + V + B --> [1 . -]---> [2 . -]---> [3 . -]---> [4 . -]---> [5 . /] + +We also know that (CADDR C) is *not* the same pair as (CADDR A), so the list +C must have its own distinct pair with 3 in the car. On the other hand, +(CDADDR C) *is* the same as (CDDDR B), so the pairs with 4 and 5 in the cars +are shared between C and the other lists: + +A --> [1 . -]---> [2 . -]---> [ | . -]---> [6 . /] + | + V + B --> [1 . -]---> [2 . -]---> [3 . -]---> [4 . -]---> [5 . /] + ^ + / + [3 . -]--/ + ^ + | +C --> [1 . -]---> [2 . -]---> [ | . -]---> [6 . /] + +(Actually, we don't know whether or not A and C share the pair whose car is +6. But this will turn out not to affect the solution.) + +Now we make two changes to the box and pointer diagram, changing one of the +threes to a seven, and changing the four to an eight: + +A --> [1 . -]---> [2 . -]---> [ | . -]---> [6 . /] + | + V + B --> [1 . -]---> [2 . -]---> [7 . -]---> [8 . -]---> [5 . /] + ^ + / + [3 . -]--/ + ^ + | +C --> [1 . -]---> [2 . -]---> [ | . -]---> [6 . /] + +We can read the results directly from the diagram: + +B is (1 2 7 8 5) +C is (1 2 (3 8 5) 6) + +Scoring: 1 point each. + + +5. OOP to normal Scheme + +(define (make-echo saved) + (let ((count 0)) + (lambda (message) + (cond ((eq? message 'count) count) + ((eq? message 'saved) saved) + (else (set! count (+ count 1)) + (let ((result saved)) + (set! saved message) + result)))))) + +The code for the ELSE clause is exactly the code for the default-method +in the OOP class definition! We didn't understand why so many people +invented much more complicated ways to do it -- or, worse, incorrect ways. + +Scoring: +3 correct +2 has the idea (at least a dispatch procedure inside the let) +1 has an idea +0 other + +Most people did okay on this, but a fairly frequent one-point answer had the +LET (for COUNT) inside the LAMBDA instead of outside. This means you missed +the whole idea about local state variables. + +A noteworthy zero-point solution tried to avoid the problem that the inner +LET solves this way: + + (else (set! count (+ count 1)) + (display saved) ; wrong wrong wrong! + (set! saved message)) + +By now everyone should understand that procedures return values, and that +printing isn't the same as returning, because it doesn't allow for +composition of functions, the most important programming technique you will +ever learn. + + +6. mystery stream + +The stream is made by sticking a 1 in front of an interleave of the integers +with something: + +1 1 ___ 2 ___ 3 ___ 4 ___ 5 ___ 6 ___ 7 ___ 8 ___ 9 ___ 10 + +Then you just fill in the blanks with the elements of MYSTERY, including all +of them -- the initial 1, the integers, and the underlined ones: + +1 1 _1_ 2 _1_ 3 _1_ 4 _2_ 5 _1_ 6 _3_ 7 _1_ 8 _4_ 9 _2_ 10 + + +Scoring: 3 points for the above solution. 2 points for small errors (such +as one number missing); there weren't many of those. 1 point for the +following wrong sequence: + + 1 1 1 2 1 3 2 4 1 5 3 6 2 7 4 8 1 9 5 10 + +which is reached by forgetting about the initial 1 and trying to create +(interleave mystery integers) instead, making the initial 1 part of the +interleaved values. + + +7. Infix in metacircular evaluator. + +This was an interesting question because the most aesthetically pleasing +solution isn't the easiest solution. + +This problem asks you to change the notation of expressions, not their +meaning. EVAL is about expressions; APPLY is about what it means to call a +function. So the right place for this change is in EVAL, changing the COND +clause for procedure calls to this: + + ((application? exp) + (let ((left (eval (operator exp) env))) + (if (or (compound-procedure? left) + (primitive-procedure? left)) + (apply left (list-of-values (operands exp) env)) + (if (= (length exp) 3) + (apply (eval (cadr exp) env) + (list left (eval (caddr exp) env))) + (error "Applying non-procedure" left))))) + +It's important to do the evaluating of subexpressions exactly right: only +once each (just in case the expression involves side effects), but before +testing for procedureness (because it's the value that's a procedure -- or a +number, if you're testing for numbers -- not the expression). That's why I +had to use a LET to save the result of evaluating the first subexpression. + +This is an important point, missed by many students. The example in the +exam was just (2 + 3), but it should also work to say (x + 3), or +((2 * 5) + 3), and in those cases the first subexpression is not itself +a number. The *value* of the expression is a number. Similarly, if you're +looking at the second subexpression, the problem could be + (2 (car (list + - *)) 3) +in which the second subexpression has an arithmetic operator as its value. + +All of that is avoided if you make the change in APPLY, where you take apart +the arguments you're given and rearrange them if needed. But it's not an +aesthetically pleasing solution, partly because applying a procedure to +arguments is a semantic operation that shouldn't know anything about the +shape of the expression the user typed, and partly because it means +disassembling an argument called "arguments" to look for a procedure in it, +and using the argument called "procedure" as an argument. + +Another solution would be to have an intermediate step between EVAL and APPLY, +like this: + +(define (eval exp env) + (cond ... + ((application? exp) (check-infix (list-of-values exp env))) + ...)) + +(define (check-infix values) + (if (and (not (meta-procedure? (car values))) + (= (length values) 3) + (meta-procedure? (cadr values))) + (apply (cadr values) (cons (car values) (cddr values))) + (apply (car values) (cdr values)))) + +(define (meta-procedure? thing) + (or (primitive-procedure? thing) + (compound-procedure? thing))) + +Some solutions treated the problem as one of syntactic rewriting, like +changing a COND to an IF or vice versa. This can work, except for the fact +that you have to partly evaluate the expression in order to know whether or +not to do the rewriting, and then you'll end up evaluating something twice. + +Another solution, very clever and elegant in its intent, has the same +problem of double evaluation: rewriting the OPERATOR and OPERANDS selectors, +similar in spirit to the way the selectors for a DEFINE expression recognize +the implicit-lambda special case. But in the DEFINE situation, we can tell +just from the notation -- the syntax -- whether or not an implicit lambda is +involved. In the case of infix arithmetic we're not sure until we've +evaluated some subexpressions. + +Other solutions reordered the expression by mutation. We didn't take off +for that if it was otherwise correct, but you should try not to develop the +habit of mutating data structures that you get as arguments unless that's +specifically in the "contract" with the caller of your procedure. That same +data structure might be shared with some other purpose. + +The intent of the problem was that *any* two-argument procedure should be +usable in infix notation. The problem statement says "[i]f a compound +expression has three subexpressions, of which the second is a procedure but +the first isn't..." But since the problem statement did also mention "infix +arithmetic," we accepted solutions that work only for the specific operator +symbols +, -, *, and so on. However, such solutions aren't very Schemely, +since the binding of those symbols to arithmetic functions isn't guaranteed. +A Scheme program could say + + (let ((plus +) (+ word)) ...) + +and then the value of (+ 3 4) would be 34! + +Note how my solution checks for a procedure. Strictly speaking, you can't +use PROCEDURE? to check, because that's a Scheme primitive that checks for +whether something is a procedure in the underlying Scheme, not a procedure +in the metacircular Scheme. But we didn't take off for this subtle error. + + +Scoring: + +4 correct + +3 subexpression(s) evaluated twice + failure to check that the first subexpression isn't a procedure + [consider the case (map - '(4 5 6)) which isn't infix!] + +2 testing unevaluated subexpressions for being procedures or numbers + +1 no evaluation at all + infix works but prefix doesn't + +0 references to line-obj or other such Logo interpreter structures + +Of course not every error is listed above, but these are the common ones. + + +8. Logic programming + +(a) Less + +The solution we were expecting was this: + +(rule (less () (a . ?y))) ; 0 < anything positive + +(rule (less (a . ?x) (a . ?y)) ; if x < y then x+1 < y+1 + (less ?x ?y)) + +Several variants were also okay. The first rule above could be replaced by + +(rule (less () ?x) + (not (same ?x ()))) + +but not just by + +(rule (less () ?x)) ; wrong! + +because that would allow the case 0 < 0, and not by + +(rule (less () (?x))) ; wrong! + +because that only allows for 0 < 1, not for other larger numbers. But +having a 0 < 1 rule is okay if you also include a rule + +(rule (less ?x (a . ?y)) ; if x < y then x < y+1 + (less ?x ?y)) + +But it's quite wrong to have a rule, as many papers did, that if x < y +then x+1 < y. That's not true! + +(Some combinations of these rules would lead to the query system giving +the same answer more than once, which is unaesthetic. The first set of +rules above avoid that.) + +Another approach would use PLUS, which you're given: + +(rule (less ?x ?y) + (plus ?x (a . ?z) ?y)) + +This says that x < y if adding some positive number to x gives y. This is +elegant because a single rule handles all cases. + + +(b) Divide + +Only one rule is needed: + +(rule (divide ?dividend ?divisor ?quotient ?remainder) + (and (times ?divisor ?quotient ?x) + (plus ?x ?remainder ?dividend) + (less ?remainder ?divisor))) + +The third clause is needed to prevent solutions such as 12/4 = 1 remainder 8. + +Many people included a lot of base case rules for dividing zero by things, +dividing things by zero, and so on -- or wrote the rules to exclude zero by +calling the divisor (a . ?foo). None of this is necessary; there won't be +any successful matches of this rule when the divisor is zero. (This is +easy to prove: the remainder would have to be less than zero!) + +The reason no base case is needed is that this is not a recursive rule; +there is no reference to DIVIDE in the conditions of the rule. There is +still some recursion going on, but it's hidden inside the PLUS and TIMES +rules. + +Scoring: Each half was worth 2 points if correct, 1 point for a solution that +has the general idea but with details wrong. (A common mistake was to think +that the remainder has to be less than the quotient, or less than the dividend.) + +No credit for composition of functions: + + (plus (times ?divisor ?quotient) ?remainder ?dividend) ; WRONG WRONG WRONG!!! + + +9. Environment diagram + +In the diagram there are three frames: + +G: x=3, y=4, foo=P2 [see below] (the global frame) +E1: x=7, extends G +E2: y=10, extends E1 + +and two procedures: + +P1: parameter x, body (lambda (y) (+ x y)), created in G +P2: parameter y, body (+ x y), created in E1 + +When we define FOO, Scheme evaluates the expression + + ( (lambda (x) (lambda (y) (+ x y))) + (+ x y) ) + +The value of the first subexpression is procedure P1, created in the +global environment (obviously, since it's the only one we have so far). +The value of the second subexpression is 7, computed using the global +values of X and Y. + +We invoke P1, creating environment E1, in which P1's parameter X is bound to +the actual argument value 7. In that new environment we evaluate the body +of P1, which is another lambda expression, creating P2. + +Then DEFINE binds FOO to that result, P2, in the global environment. + +When we evaluate the expression (foo 10), environment E2 is created. FOO's +parameter Y is bound to the argument value 10, in the new frame. Then we +evaluate the body of P2, (+ x y), using the values in E2: x=7 (from E1), +y=10. So the answer is 17. + + +Scoring: 1 point for the answer 17. For the diagram, 3 points minus the +number of mistakes. In counting mistakes we looked for three frames, +two procedures, and five arrows (two arrows extending environments, +two arrows from procedures to environments, and the arrow binding FOO). + +There were too many rearrangement errors to classify, but one common error +that's worth mention was to say that in E1, X is bound to x+y. By the time +E1 is created, we no longer know where the argument value 7 came from; +that's what it means to say that Scheme uses applicative order. + + +10. Locate. + +The most elegant solution, I think, is this: + +(define (locate value struct) + (define (help struct fn) + (cond ((equal? value struct) fn) + ((pair? struct) + (or (help (car struct) (compose car fn)) + (help (cdr struct) (compose cdr fn)))) + (else #f))) + (help struct (lambda (x) x))) + +This is a case in which an iteration-like style, with a helper procedure +with an extra argument, makes things simpler instead of more complicated. +(It's not really iterative, of course, since there's a tree recursion, +but the second recursion, for the cdr, *is* iterative.) + +Here's a more straightforward solution: + +(define (locate value struct) + (cond ((equal? value struct) (lambda (x) x)) + ((pair? struct) + (let ((left (locate value (car struct)))) + (if left + (compose left car) + (let ((right (locate value (cdr struct)))) + (if right + (compose right cdr) + #f))))) + (else #f))) + +Note that for both the car and the cdr you have to check whether the +recursive call actually returned a procedure, rather than #F, before you +try to compose the procedure with something. + +Instead of using COMPOSE you could equivalently use lambda expressions: + (lambda (x) (left (car x))) + +Notice, by the way, that the iterative-style solution does the composing +backwards from the recursive-style solution; this is analogous to the list +reversal that plagues iterative solutions to list-building problems. + +One point that many students missed is that the problem says "If the value +is not found in the structure, LOCATE should return #F" -- not a procedure +that returns #F! So you can't say + +(define (locate value struct) + (lambda (other-struct) ...)) ; wrong + +Another commonly missed point is that the problem does *not* say the values +have to be atomic. (locate '(a b) '(x y (a b) z)) should work, returning +the procedure caddr. In particular, this means that solutions that flatten +the structure into a simple sequence of atoms, although clever in a way, +miss the point and aren't satisfactory. + +Even worse were the solutions that assume the values are numbers, just +because the given example had numbers. A relatively mild version of that +was to use = for equality checking; much worse was to use list-ref to look +for the desired element. + +A couple of students used AMB in their solutions. Although we had in mind +a solution using standard Scheme, we would have allowed this, because it's +such an appropriate idea -- the problem involves backtracking, so a +nondeterministic solution makes sense. But actually getting it right is +tricky, and nobody managed it: + +(define (locate value struct) + (define (locate1) + (define (help struct fn) + (cond ((equal? value struct) fn) + (else (require (pair? struct)) + (let ((cxr (amb car cdr))) + (help (cxr struct) (compose cxr fn)))))) + (help struct (lambda (x) x))) + (amb (locate1) #f)) + +That LOCATE1 subprocedure is required because in case of failure, the +natural response of the nondeterministic evaluator is to print a message +saying no more values were found, but we want it to return #F to some +calling procedure. + +Many students made the program much more complicated than necessary, with +special cases for (car struct), (cadr struct), etc. Partly this is because +students don't believe in leaf nodes of trees, and partly it's because +some students found a somewhat similar problem, called SELECT, in a previous +exam in the course reader. But SELECT really did require complications, +because the first element of a sublist had a special meaning in that problem. +Here the elements are treated uniformly. + + +Scoring: + +4 correct +3 small errors (typical: only works for atoms, only works if no #F in a list, + returns (lambda (x) #f) instead of #f) +2 has the idea (domain and range correct, uses tree recursion) but + more serious errors +1 not tree recursive (typical: if the car is a list, and doesn't have the + value, then the cdr isn't checked) +0 incoherent diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-3.soln.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-3.soln.txt new file mode 100644 index 0000000..0c4cc82 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Final/f-3.soln.txt @@ -0,0 +1,1125 @@ +CS 61A Solutions to sample final exam #3 + +1. Domain and range + +The domain of a procedure is the TYPE of thing(s) it accepts as argument(s). +The range is the TYPE of thing it returns. So we wanted types as the answers +to this question. That's generally what you gave for the domain, but for the +range, several people instead gave explanations of the purpose of the +procedure, e.g., "Range: the children of the tree node." + +(a) CHILDREN + +CHILDREN takes one argument, a Tree (which is the same as a node). +It returns a forest, which is a list of Trees. So: + + Domain: TREE or NODE + Range: FOREST or LIST OF TREES or just LIST + +Most people got this one. + +(b) OWNER + +OWNER takes one argument, a THING object. It returns the *name of* the +person who owns the thing (not the person, not the name of the thing). +A name is a word, not an object! So: + + Domain: OBJECT or THING OBJECT or THING INSTANCE + Range: WORD + +We also accepted NAME for the range, although that isn't really a type. +The most common wrong answer for the range was PERSON; that's a kind of +object, not a word. A fairly common wrong answer for the domain was CLASS; +the procedure takes a particular thing as its argument, not the class of all +things. Another common wrong answer was PROCEDURE; it's true that we use +procedures to represent objects, but not every procedure is an object, and +not every procedure can be used as the argument to OWNER. + +(c) SET-CDR! + +SET-CDR! takes two arguments; the first must be a pair, and the second can be +of any type. Its return value is unspecified, since it is used for its effect +rather than for its return value, so we accepted anything for the range in +this part. + + Domain: PAIR and ANYTHING (you had to say both). + Range: UNSPECIFIED (but we accepted anything). + +We didn't accept LIST for the domain; there is no requirement that the first +argument to SET-CDR! be a pair whose cdr is a list (which is what it means for +a pair to be a list). Also, the LIST domain would include the empty list, +which can't be used as the first argument to SET-CDR!. + +Scoring: One point each, all or nothing. + + +2. Data abstraction + +The argument is a LIST of RATIONALs. For the list itself, the appropriate +selectors are CAR and CDR. (Constructors for lists include CONS, LIST, and +APPEND, but in this problem we are not constructing a list!) For a rational +number, the constructor is MAKE-RAT and the selectors are NUMER and DENOM. +So the corrected version is + +(define (ratprod lst) + (define (helper lst n d) + (if (null? lst) + (MAKE-RAT n d) + (helper (CDR lst) (* n (NUMER (CAR lst)) (* d (DENOM (CAR lst))))))) + (helper lst 1 1)) + +The call to CDR doesn't change because it is selecting part of a list, not +part of a single rational number. The calls to CAAR and CDAR do change, +as shown above; they both select the first element of the list (CAR), and +each then selects one piece of a rational number (NUMER or DENOM). + +Scoring: -1 point per error, either a required change not made or something +changed that shouldn't have been. But 0 points if no correct change was +made at all (e.g., if the question was left blank). + + +3. Order of growth + +(a) + +(define (two-to-the n) + (if (zero? n) + 1 + (let ((prev (two-to-the (- n 1)))) + (* prev 2) ))) + +Each call to this procedure does three constant-time operations (ZERO?, -, +and *) in addition to making one recursive call. So there are N recursive +calls, each of which takes constant time. Therefore, this procedure takes +time Theta(N). + +(b) + +(define (two-to-the n) + (if (zero? n) + 1 + (let ((prev (two-to-the (- n 1)))) + (+ prev prev) ))) + +The only difference here is (+ PREV PREV) instead of (* PREV 2). This +is still a single, constant-time arithmetic operation, although both operands +are the variable PREV rather than including the explicit number 2. But +finding the value of a variable is also constant time, so this doesn't affect +the program's running time, which is still Theta(N). + +(c) + +(define (two-to-the n) + (if (zero? n) + 1 + (+ (two-to-the (- n 1)) + (two-to-the (- n 1)) ))) + +In this version, each call to TWO-TO-THE gives rise to *two* recursive +calls. So, for example, (two-to-the 5) calls (two-to-the 4) twice; each +of those makes two calls, for a total of four calls of (two-to-the 3). +Similarly, there are eight (two-to-the 2) calls and 16 of (two-to-the 1). +Increasing N by 1 doubles the total number of recursive calls, so the +running time for this procedure is exponential, Theta(2^N). + +The most common error was to think that the last version was Theta(N^2). + +Scoring: One point each. + + +4. Functions of functions. + +The point of this question is to illustrate some of the ways in which +functions can be manipulated on their own, without explicit reference to +the arguments of the functions. You've seen COMPOSE before, in lecture; +the other two tools given here are similar in spirit. + +One way to think about these questions would be to try writing the +desired procedure without using COMPOSE, SPECIALIZE, or SWAP-ARGS, and +then think about how you did it. + +[a] INITIALS + +(define (initials sent) + (every first sent)) + +So INITIALS is a specialized version of EVERY, in which the first +(procedure) argument is FIRST. Thus we have the answer: + +(define initials (specialize every first)) + + +[b] POSITIVE? + +(define (positive num) + (> num 0)) + +This is a specialization of >, in which the *second* argument is held +constant (zero), not the first argument as in INITIALS. So SPECIALIZE +won't quite do the job by itself. One solution would be to use < +instead of >: + +(define (positive num) + (< 0 num)) + +(define positive (specialize < 0)) + +but that wasn't one of the choices. Instead we use SWAP-ARGS to get +the arguments in the right order: + +(define positive (specialize (swap-args >) 0)) + + +[c] LEAF? + +(define (leaf? node) + (null? (children node)) + +This is a composition of functions: + +(define leaf? (compose null? children)) + + +Scoring: One point each. + + +5. Mystery function on Trees + +(define (mystery tree) + (if (null? (children tree)) + (make-tree (datum tree) '()) + (make-tree (+ (datum tree) 100) + (map mystery (cdr (children tree)))))) + +This function says: If the node is a leaf, return a leaf node with the +same datum. (This is actually unnecessarily complicated; it could have +just returned the argument TREE itself, since the node it constructs has +the same datum and the same (empty) children.) If the node isn't a leaf, +add 100 to its datum, and recursively apply the same function to its +children, but omit the first child (because of the CDR call). + +In the given tree, the root node (datum 1) has three children, so we add +100 to its datum (giving 101), we omit the subtree headed by the node with +datum 2, and we recursively process nodes 3 and 4. + +Node 3 (I'm using this as an abbreviation for "the node with datum 3" and +similarly for the other nodes) has two children, so we add 100 to its +datum, omit the first child (6), and recursively process the other child +(node 7). + +Node 7 has no children, so we just return a leaf with datum 7. + +Node 4 has one child. So we add 100 to its datum, omit its first (only) +child 8, and recursively process its other children -- but there aren't +any, so the node with datum 104 will be a leaf node in the resulting tree. + +Omitting a node doesn't just mean omitting the datum of that node; we +never look at its children either. So we don't have to think about nodes +5, 9, and 10. + +Don't forget that this function builds a new tree! It doesn't mutate the +argument tree. In particular, one common wrong answer was to return a +tree with 10 nodes, just like the argument tree, but with 100 added to +some of the data. The correct answer is a tree with only the four nodes +mentioned earlier as part of the result: + + 101 + / \ + 103 104 + | + 7 + +Another too-common mistake was to draw a tree in which some nodes have +lists as the datum. For example, the child of the 103 node was shown as +having (7) as its datum, or the 104 node had a child with the empty list +as its datum. These errors, I think, come from not respecting the data +abstraction, but instead trying to translate the tree selectors and +constructor into operations on pairs. As you can see from the explanation +above, there is no need to think about how tree nodes are represented! The +only pair operation used is the CDR in the procedure, and that's because +(CHILDREN TREE) returns a forest -- a list of trees -- rather than a single +tree node. + +Several people thought that a Scheme error would result from the expression + + (map mystery (cdr (children tree))) + +when it is applied to the 4 node, which has only one child, because in this +case the expression is equivalent to + + (map mystery '()) + +But there's nothing wrong with this -- MAP is happy to take the empty list +as its second argument, in which case it returns the empty list without +ever calling MYSTERY. Empty lists are legitimate lists! + + +Scoring: + +5 Correct. + +4 Correct except that instead of 101, 103, and 104, the values in those + nodes are computed by some different arithmetic; most commonly these + nodes have the data 101, 301, and 401. Node 7 must be correct. + +3 Right shape, but one incorrect datum (most often 107 instead of 7). + +2 The four correct nodes plus one or two extras, including the case of + "error" as a child of node 104. + +2 The solution obtained by ignoring the CDR in the procedure: 10 nodes + in the same shape as the original, but with 1, 2, 3, 4, and 8 changed + to 101, 102, 103, 104, and 108. + +0 "Error" as the complete answer without an explanation. + +0 Any list structure in the tree data. + +0 Anything else, including the "mutation" solution mentioned earlier with + 10 nodes like the original but with 1, 3, and 4 changed to 101, 103, 104. + + + +6. Scheme to OOP + +We are given + +(define foo + (let ((a 3)) + (LAMBDA (B) ;; This is the class FOO + (let ((c 4)) + (LAMBDA (MESSAGE) ;; This is the instance's dispatch procedure + (cond ((eq? message 'hi) + (+ a b)) + (else + (+ c message)))))))) + +The scope of the LET variable A encloses the procedure representing the class, +so it's a class variable. B is an argument to the class, so it's an +instantiation variable. And C is inside the scope of the class, but outside +the scope of the instance, so it's an instance variable -- each instance has +its own C. Therefore: + +(define-class (foo b) + (class-vars (a 3)) + (instance-vars (c 4)) + (method (hi) + (+ a b)) + (default-method + (+ c message))) + +The dispatch procedure looks explicitly for the message HI and provides +a method for it; the ELSE clause in the dispatch procedure handles any +other message, so it's a default method. + +Most people got the translation of the LET expressions for A and C right, +although a few people reversed them and a few people thought A and C were +the same kind of variable. B was trickier; some people didn't realize +that that LAMBDA represents the class, and instead thought that B was a +formal parameter of a method. + +Similarly, some people thought the inner LAMBDA expression represents a +method rather than a dispatch procedure, so they wrote methods with +MESSAGE as a parameter. + +As in any object class definition, it's possible to have only a default +method that checks for particular messages explicitly: + + (default-method + (if (eq? message 'hi) + (+ a b) + (+ c message))) + +and we accepted that, although it's contrary to the spirit of OOP. But +most people who were confused about the meaning of the inner LAMBDA came +up with incorrect solutions, such as + + (method (hi message b) ...) + (default-method (message) ...) + (method (hi) (if ...)) + +Scoring: The correct solution has five components: the use of B as an +instantiation variable, and the four clauses within the define-class (A, C, +HI, and DEFAULT-METHOD). We subtracted one point for each missing or +incorrect component. Incorrect solutions that tried to combine the HI +method with the default method lost both points, except for the + (method (hi) (if ...)) +version (no parameter to HI!), which lost only one point for the methods. + + +7. Environment diagrams + +The diagrams have many features in common: They all have a global frame +and an additional frame E1; they all have a symbol F bound to a procedure. +But there are two things that differ among diagrams: + + * The symbol F is in frame G (diagrams A and B) or in frame + E1 (diagrams C and D). + + * The procedure's right bubble points to frame G (diagrams + A and C) or to frame E1 (diagrams B and D). + +So, to figure out this question, for each of the four Scheme programs we +have to ask "where is the procedure created?" and "where is F bound?" + +(let ((f (lambda (x) x))) + 'okay) + + Here the LAMBDA expression is evaluated in the global environment, + because LET value expressions are evaluated *before* the implicit + procedure created by the LET is invoked. But the binding for F is + made locally, in the frame E1 that's created by the LET. So this + is diagram C: procedure points to G, F bound in E1. + +(define f + (let () + (lambda (x) x))) + + This time the LAMBDA expression is evaluated in the body of the LET, + so its current environment is E1, and so that's what the right bubble + remembers. But the DEFINE is in the global environment, so that's + where F is bound. This is diagram B: procedure points to E1, F + bound in G. + +(let () + (define f (lambda (x) x))) + + This time both the LAMBDA and the DEFINE are in the body of the LET, + so both of them have E1 as the current environment. This is diagram + D: procedure points to E1, F bound in E1. + +(define (f) f) +(f) + + Here we have a straightforward global definition of a procedure F, + so both the (implicit) LAMBDA and the DEFINE happen in G. So this + is diagram A: procedure points to G, F bound in G. (Frame E1 is + created by the second, separate expression, which invokes F.) + +Most students got this correct. The most common wrong answer was DBCA. +Choosing D for the first expression comes from the frequent misunderstanding +in which students think that the expressions that provide the values for the +LET variables are evaluated inside the scope of the LET. I'm not sure how +anyone would choose C for the third expression, but probably it's because you +assumed (correctly) that each diagram was used once. + +Scoring: one point each. + + +8. CADR for message-passing pairs + +A pair made by MAKE-PAIR can handle CAR and CDR messages directly because +its local state variables X and Y contain the desired values. But in order +to handle the CADR message, it has to find its own CDR (which is Y) and +send a CAR message to that other pair: + +(define (make-pair x y) + (lambda (msg) + (cond ((eq? msg 'car) x) + ((eq? msg 'cdr) y) + ((EQ? MSG 'CADR) (Y 'CAR)) ;; <<=== This line added! + (else (error "I have no idea what you're talking about.")) ))) + +One common mistake was (ASK Y 'CAR); this has the idea, but we're using +plain Scheme message passing, not the OOP language. + +Many students used roundabout means to find the pair's CDR, such as + + ((eq? msg 'cadr) (((make-pair x y) 'cdr) 'car)) + +presumably because you mistrusted a simple Y as something you can invoke. +This works, but it really violates the spirit of the problem -- it creates a +new pair every time you look at the pair -- and didn't get full credit. + +Another common error was (CAR Y). Unless you explicitly redefine CAR to +use the message-passing pairs, this will invoke the ordinary CAR that +expects a built-in Scheme pair as its argument, not a procedure. We +named the pair constructor MAKE-PAIR rather than CONS to make it clear +that we didn't mean to eliminate the regular pairs, and our example says +(ABC 'CAR) rather than (CAR ABC). + +Of course the worst mistake was to build the specific example ABC into +the solution! + +Scoring: + +3 Correct. + +2 (ASK Y 'CAR) + +2 (X 'CDR) ; this would give the CDAR, not the CADR. + +2 Working solutions that call MAKE-PAIR. + +1 (X 'CAR) or (Y 'CDR) ; CAAR and CDDR. + +0 Anything else, including (CAR Y). + + + +9. List mutation. + +Here is the box-and-pointer diagram *before* doing any mutation: + +---> XX------------> XX------------> X/ + | | | + V V V + + XX---> X/ XX---> X/ E + | | | | + V V V V + + A B C D + +The expression (SET-CAR! (CADR LST) (CDDR LST)) modifies the pair that is +the CADR of the original list -- the CAR of the CDR. (CDR LST) is the +second pair of the spine, in the top row. CAR of that pair is the first +pair in the spine of the sublist (C D). So we are going to change the CAR +of that pair, replacing C with something. With what? With the value of +(CDDR LST), the second argument to SET-CAR!. (CDDR LST) is the third +pair of the spine of the entire list, the one whose CAR is E. So after +this first mutation we have + +---> XX------------> XX---------->-> X/ + | | / | + V V * V + * + XX---> X/ XX---> X/ * E + | | * | * + V V * V * + * * + A B * D * + * * + ************ + +The second mutation, (SET-CAR! (CAR LST) (CADDR LST)), modifies (CAR LST), +which is the first element of the big list -- the first pair of the spine +of the sublist (A B). We change the CAR of this pair, so that instead of +pointing to A, it points to the CADDR of the big list, which is the third +element, the symbol E: + +---> XX------------> XX---------->-> X/ + | | / | + V V * V + * + XX---> X/ XX---> X/ * E + * | * | * + * V * V * ^ + * * * * + * B * D * * + * * * * + * ************ * + * * + ********************************* + +Notice that the first mutation points to a pair, not to E, but the second +one points to E. This is the difference between (CDDR LST) and (CADDR LST). + +It's okay if you draw another E underneath the relevant pair, instead of +drawing an arrow over to the original E. Since two equal symbols are always +EQ, it's not important to distinguish two equal symbols in the diagram. + +The third mutation is (SET-CDR! (CAR LST) (CDAR LST)). This says, "change +the CDR of (CAR LST) to the CDR of (CAR LST)"! In other words, it doesn't +really change anything: + +---> XX------------> XX---------->-> X/ + | | / | + V V * V + * + XX***> X/ XX---> X/ * E + * | * | * + * V * V * ^ + * * * * + * B * D * * + * * * * + * ************ * + * * + ********************************* + +Finally we have (SET-CAR! (CDDR LST) 'X). This modifies (CDDR LST), which +is the last pair of the spine. Its CAR used to point to E, but now points +to X instead: + +---> XX------------> XX---------->-> X/ + | | / * + V V * * + * V + XX***> X/ XX---> X/ * + * | * | * X + * V * V * + * * * + * B * D * E + * * * + * ************ ^ + * * + ********************************* + +So the printed representation of the final result is: + + ((E B) ((X) D) X) + +The most common wrong answer was ((X B) ((X) D) X). This comes from thinking +that the last mutation changes *everything* that points to E so that it points +to X instead. But that would be true only if the pair (CAR LST) pointed to +the *pair* (CDDR LST), whose CAR is changed from E to X, rather than pointing +directly to E. + +Another common wrong answer was ((E B) (X D) X), ignoring the fact that the +first mutation replaces the letter C with the *pair* (CDDR LST), which is a +list, not a symbol; its printed representation is (X). + +A common error in the diagram itself was to create new pairs, most often +making a *copy of* (CDDR LST) to be the CAR of (CADR LST). + +Another misunderstanding, which led to huge errors in the diagram, was to +think that (CAR LST) means the first *pair in the spine* of LST, rather +than the first *element* of LST. Similarly, students misinterpreted +(CADR LST) to mean the second pair of the spine, and so on. + +Scoring: We subtracted one point per wrong change in the diagram (out of +the four possible changes), and one point if the printed representation +didn't match your diagram. + + +10. Scheme vs Logo evaluators + +In Scheme, evaluating the expression (+ A 3) requires the evaluator to look up +two variables: + and A. Since we are giving MC-EVAL an environment that only +has a binding for A, this first expression gives the result + + ERROR: Unbound variable + + +In Logo, procedure names aren't part of the environment, but are found in a +separate, global table that's used automatically by LOGO-EVAL. So in order to +evaluate the Logo expression (SUM 2 :A), we have to look up A in the +environment, but we don't need SUM in the environment. Therefore the result +of this evaluation is + + 5 + + +One too-common error was to say (+ A 3) as the value returned in the first +case. Presumably students who said this were reacting to the fact that the +expression (+ A 3) is quoted when used as an argument to MC-EVAL. But this +just means that the argument is (+ A 3) rather than being the result of +evaluating (+ A 3) in the underlying STk evaluator! + +Scoring: Two points each. We accepted any ERROR message for the first part. + +For the second part, we accepted 6 instead of 5 (because it's not important +if you didn't notice that the second expression used 2 rather than 3) for +full credit. + +We gave half credit (one point) to either of two particular wrong answers +to the second part: + + You don't say what to do with 5 + +(which would be correct if we were calling DRIVER-LOOP instead of LOGO-EVAL), +and + + 5 =no-value= + +(which can't be correct, since it's two values instead of one, but presumably +is meant to show the values computed by EVAL-LINE, although that isn't right +either because EVAL-LINE returns a value as soon as it gets anything other +than =no-value= from evaluating an expression). + + +11. Streams + +The first two elements are explicitly given as A and B. The remaining +elements are the result of interleaving two streams, so we can draw a +picture like this: + + + A B ___ ___ ___ ___ + + ___ ___ ___ ___ + + +The second argument to INTERLEAVE is a stream containing only elements +that are the symbol B, so we can start to fill this in: + + + A B ___ ___ ___ ___ + + _B_ _B_ _B_ _B_ + + +To fill in the top row, we just copy the entire stream FOO. We already +know FOO's first two elements, so we can fill those in, and that tells us +FOO's third and fifth elements. (Its fourth element is the first B on the +bottom row.) + + + A B _A_ _B_ _A_ _B_ + + _B_ _B_ _B_ _B_ + + +Putting this back into a single row gives the solution: + + A B A B B B A B B B + + +Scoring: We subtracted one point per wrong letter. This means that the +common error in which only the first letter is A [A B B B B B B B B B B] +got one point. + +Exception: Some people apparently think that STREAM-FILTER keeps only +the elements that *don't* satisfy the predicate, so they put a stream of +As in the bottom row rather than a stream of Bs. This gives the incorrect +solution A B A A B A A A A A, to which we gave one point. + + +12. Logic programming + +As a reminder, here's ASSOC written in Scheme: + +(define (assoc key alist) + (cond ((null? alist) #f) + ((equal? key (caar alist)) (car alist)) + (else (assoc key (cdr alist))))) + +The first COND clause does not have any analog in the logic program! In +logic programming, if nothing satisfies the question we're asking, we just +don't match any rule. We don't want a rule that shows a value of #F. + +Here's the rule corresponding to the second COND clause: + +(assert! (rule (assoc ?key ((?key . ?value) . ?rest) (?key . ?value)))) + +No condition is necessary for this rule; the pattern says it all. But +it would be okay to show this rule in a form closer to that of the Scheme +program: + +(assert! (rule (assoc ?key (?car . ?cdr) ?car) + (and (same ?car (?caar . ?cdar)) + (same ?key ?caar)))) + +The second COND clause is a little tricky, because we only want to allow +the recursion if the key doesn't match the first entry. In Scheme, COND +automatically handles this, because COND can only return one value, so it +doesn't look at any clauses after the first successful one. But logic +programming allows multiple results, so we have to explicitly disable the +recursion in case of a match: + +(assert! (rule (assoc ?key ((?caar . ?cdar) . ?rest) ?result) + (and (assoc ?key ?rest ?result) + (not (same ?key ?caar))))) + +To make this work we also have to define the SAME relation: + +(assert! (rule (same ?x ?x))) + +but we didn't require this to be explicitly included in your solution. + + +Some people tried to use a single rule that matches any association list +that has the desired key anywhere in it, like this: + +(rule (assoc ?key (?left . (?key . ?value) . ?right) (?key . ?value))) ;WRONG! + +This isn't such a bad idea, except that there is no (x . y . z) notation for +a list that has element Y in the middle. But the desired result can be +obtained using the APPEND rules: + +(assert! (rule (assoc ?key ?alist (?key . ?value)) + (and (append ?left ((?key . ?value) . ?right) ?alist) + (not (assoc ?key ?left ?something))))) + +The NOT clause is required to eliminate duplicate matching keys. Alas, +most people who tried this didn't quite use APPEND correctly. The worst +problem was to try to use it as a function rather than a relation: + + (rule (assoc ?key (append ?left ((?key . ?value) . ?right)) + (?key . ?value))) ; WRONG!!! + +This is an attempt to use the "return value" from APPEND as part of the +pattern for the ASSOC rule, but APPEND doesn't return a value. It's a +relation that succeeds or fails, and the appended list is one of the +components of the relation, as in the correct version above. + + +The most common error was to include spurious base cases, such as + + (rule (assoc ?key () #f)) ; WRONG! + +A more subtle error was to try to eliminate duplicate keys in the +association list in the wrong rule: + +(assert! (rule (assoc ?key ((?key . ?value) . ?rest) (?key . ?value)) + (not (assoc ?key ?rest ?something)))) ; WRONG! + +This rule would find the last matching key, not the first matching key, +in the association list. + + +Scoring: + +5 Correct. + +4 Extracts just the key, or just the value, rather than the entire pair. + +4 Finds the last matching key rather than the first one. + +3 Finds all matching keys (no NOT clause). + +3 Spurious base case for empty list. + +2 No recursive rule at all. + +2 Other "has the idea" but non-working solutions with a rule that tries + to match the car of the association list. + +0 No rule matching the car of the association list (recursive rule only). + +0 Has the example built in (e.g., only works for lists of length four). + +0 Composition of functions (like the incorrect APPEND version above). + +0 Anything not mentioned above. + + +13. Concurrency + +All of the examples try to call the procedures F and G, which both modify +the variable X, and must therefore be protected against each other. +Therefore, we must use the same serializer for both of them. + +(parallel-execute (s f) (t g)) + + This uses two different serializers for the two thunks, so they + are not protected against each other. This can give rise to + INCORRECT RESULTS. + +(parallel-execute (s f) (s g)) + + This is the correct way to do it -- a single serializer protects + the variable X, and every process that depends on X is protected + using S. So it produces NEITHER incorrect results nor deadlock. + +(parallel-execute (s (t f)) (t g)) + + This has an unnecessary invocation of serializer S. Both processes + are protected by T, so no incorrect results are possible, and nothing + is added by calling S also. But since S is used for only one process, + there will be NEITHER incorrect results nor deadlock. + +(parallel-execute (s (t f)) (s g)) + + This is just like the previous case: S does the needed protection, + and T is unhelpful but not harmful either, since only one process + uses it. So NEITHER problem can arise. + +(parallel-execute (s (t f)) (t (s g))) + + There won't be incorrect results, since both processes use the same + serializer (either S or T can be considered as the useful one). The + second serializer is unnecessary. But this time, since two processes + use the same two serializers, in different orders, DEADLOCK is + possible. + +Scoring: One point each. + + +14. Tree to binary tree. + +The crucial point here is that two different abstract data types (Tree and +Binary Tree) are involved. A binary tree isn't just a Tree! It's different +because if a node has exactly one child, a Binary Tree can distinguish whether +this is the left child or the right child; the Tree type doesn't allow for +this distinction. So, for example, you couldn't use the Tree type to +represent a binary search tree. + +We are given a Tree as argument, and asked to return a Binary Tree. +Therefore, our program should use the *selectors* for the Tree type (namely +DATUM and CHILDREN), but should use the *constructor* for the Binary Tree +type (MAKE-BT). + +We didn't say explicitly in the problem what the arguments to MAKE-BT should +be, but we did say it's based on the Binary Tree type in the text (see page +157), except changing the name from MAKE-TREE to MAKE-BT. It takes three +arguments, the three components of a Binary Tree node: entry, left, and right. + +(define (tree->bt tree) + (if (> (length (children tree)) 2) + #f + (let ((kids (map tree->bt (children tree)))) + (cond ((member #f kids) #f) ; propagate failure upward + ((null? kids) (make-bt (datum tree) '() '())) + ((null? (cdr kids)) (make-bt (datum tree) (car kids) '())) + (else (make-bt (datum tree) (car kids) (cadr kids))))))) + +The most common error was to forget the first COND clause. It's not good +enough to return #F if *this* node has three or more children; we also have to +return #F if any *child* (or grandchild, etc.) of this node has too many +children. So we see if the value returned by any recursive call to TREE->BT +is false, and if so we return false too. + +Since MAKE-BT has separate arguments for the left and right branches, +we need three COND clauses for each of the possible number of children +in order to put the child(ren) in the right place(s). + +We accepted solutions in which MAKE-BT takes a list of length exactly two, +every time, to specify the two branches of the new node. But we didn't accept +solutions in which MAKE-BT takes a list of any number of children, because +that interface wouldn't allow the user to distinguish the case of a node with +only a left child from the case of a node with only a right child. (In this +problem we say that we aren't going to create any nodes with only a right +child, but you can't specify a constructor for Binary Trees that doesn't allow +for that possibility.) + +Another common error was data abstraction violations. These come in two +forms: (1) mixing the selectors and constructors for Trees with those for +Binary Trees, and (2) using list/pair selectors and constructors (CONS, CAR, +etc.) for either Trees or Binary Trees. We considered the first category less +severe than the second, although either kind of DAV really shows a failure to +understand the point of data abstraction! (This is true despite the fact that +a few students wrote essays to try to justify their violations.) + +Another severe error was to try to mutate the tree instead of constructing a +new data structure. This was rarely explicit (e.g., using SET-CAR!); the +usual thing was for students to call MAP, ignore its return value, and think +(apparently) that something has changed in the argument tree. We referred to +this in the grading as the "MAP!" error -- using MAP as if it were a mutator. + +Scoring: + +6 Correct. + +4 Correct except that #F from a child isn't propagated to the parent. + +2 Case analysis errors, e.g., two-child nodes handled correctly but + one-child nodes handled incorrectly. + +2 Tree vs. Binary Tree DAV. + +0 Tree vs. Pair DAV [e.g., (CAR TREE)]. + +0 No deep recursion (grandchildren not examined). + +0 Pseudo-mutation (using MAP as if it were MAP! mutator). + +0 Anything worse. + + + +15. SWAP! + +This was a relatively easy mutation problem, since there was no need to +examine inside any lists found as elements of the argument list. We only +care about elements of the top-level list. + +The first decision to be made is whether this is a job for SET-CAR! or +for SET-CDR!. The best choice is SET-CAR!, because we don't want to change +which pair comes first in the list's spine, in case some variable used in the +calling procedure is bound to this list. + +We want to mutate the pairs of the spine, not any pairs that might be elements +of the list. And we need a temporary variable to remember one of the elements +while we're doing the swapping. + +(define (swap! lst) + (cond ((null? lst) lst) + ((null? (cdr lst)) lst) + (else (let ((temp (car lst))) + (set-car! lst (cadr lst)) + (set-car! (cdr lst) temp) + (swap! (cddr lst)) + lst)))) + +Scoring: + +6 Correct. + +5 Swaps correctly but doesn't return a value. + +5 Correct except for base cases. + +4 Has the idea: + * Uses a temporary variable; and + * SET-CAR! of two pairs, with at least one in the spine; and + * Recursive; + but... + - recurs on (CDR LST) instead of (CDDR LST); or + - uses SET-CDR! and reorders correctly but loses the head pair; or + - has the wrong value in TEMP (a spine pair instead of an element). + +3 (set-car! (CAR lst) (cadr lst)) and (set-car! (CADR lst) temp). + +2 Has an idea: + - only one SET-CxR!; or + - no temporary variable; or + - mutates two wrong pairs; or + - thinks SET! will change a pair, but also uses SET-CxR!. + +0 Other, including: + - allocates pairs (CONS, LIST, APPEND, etc.); or + - no recursion; or + - no SET-CxR!; or + - SET! of a non-symbol [e.g., (SET! (CAR LST) (CADR LST))]. + + +16. Partial application in MCE + +The feature we want to add, which in the programming language literature is +generally called "partial application," is used when a procedure is called. +Procedure calling is the job of MC-APPLY, so that's where we have to make the +change. (It's possible to do it elsewhere, but less straightforward.) + +We are asked to construct a new procedure. How do we do that? The best +answer is to call MAKE-PROCEDURE. There's no need to construct and then +evaluate a LAMBDA expression! + +What should the procedure look like? One solution is to do exactly what's +shown in the question: a procedure whose body is an invocation of the +underlying procedure. But this is actually a little tricky, because when we +get to APPLY we no longer know what *expression* has that procedure as its +value! We only have the procedure itself. So the easiest thing will be if we +can create a procedure with the same body as the original procedure. For +example, if the original procedure is + + (lambda (base exp) + (cond ((= exp 0) 1) + ((even? exp) (fast-exp (* base base) (/ exp 2))) + (else (* base (fast-exp base (- exp 1)))))) + +then we'll create a procedure + + (lambda (EXP) ;; only this line is different + (cond ((= exp 0) 1) + ((even? exp) (fast-exp (* base base) (/ exp 2))) + (else (* base (fast-exp base (- exp 1)))))) + +but we'll create it in an environment with BASE bound to 2, as if the +user had typed + + (let ((base 2)) + (lambda (exp) + (cond ((= exp 0) 1) + ((even? exp) (fast-exp (* base base) (/ exp 2))) + (else (* base (fast-exp base (- exp 1))))))) + +But of course we can't build this particular example into the solution; +it has to work for any procedure, with any number of parameters, and with +any smaller number of arguments given in the invocation. + +(define (mc-apply procedure arguments) + (cond ((primitive-procedure? procedure) + (apply-primitive-procedure procedure arguments)) + ((compound-procedure? procedure) + (IF (< (LENGTH ARGUMENTS) (LENGTH (PROCEDURE-PARAMETERS PROCEDURE))) + (MAKE-PROCEDURE + (BUTFIRST-N (LENGTH ARGUMENTS) + (PROCEDURE-PARAMETERS PROCEDURE)) ; parameters + (PROCEDURE-BODY PROCEDURE) ; body + (EXTEND-ENVIRONMENT ; environment + (FIRST-N (LENGTH ARGUMENTS) + (PROCEDURE-PARAMETERS PROCEDURE)) + ARGUMENTS + (PROCEDURE-ENVIRONMENT PROCEDURE))) ; lexical scope! + (eval-sequence + (procedure-body procedure) + (extend-environment + (procedure-parameters procedure) + arguments + (procedure-environment procedure))))) + (else + (error + "Unknown procedure type -- APPLY" procedure)))) + +This solution uses helper procedures to extract the first N parameters, +and all but the first N parameters, from the original procedure's list of +parameters: + +(define (first-n n lst) + (if (= n 0) + '() + (cons (car lst) (first-n (- n 1) (cdr lst))))) + +(define (butfirst-n n lst) + ((repeated cdr n) lst)) + +This is the most elegant solution, because it deals only with values, +not with expressions -- there's no need to call MC-EVAL anywhere in it. +It's also possible to solve the problem by manipulating the text of the +procedure in various ways. For example, we could try to substitute the +argument values for the first N parameters in the body, so we'd get the +procedure + + (lambda (exp) + (cond ((= exp 0) 1) + ((even? exp) (fast-exp (* 2 2) (/ exp 2))) + (else (* 2 (fast-exp 2 (- exp 1)))))) + +for our example. This is trickier than it looks to get correct, though. +In this example the actual argument is a number, which is self-evaluating. +But suppose the actual argument value is a non-numeric word or a list. +It won't work to substitute the argument *value* into the body; we have +to find the argument *expression* (which means we'd have to do the job in +MC-EVAL rather than in MC-APPLY), or else we have to quote the value each +time we substitute it. + +The key point is to be clear on the difference between an expression and a +value -- for example, a LAMBDA expression versus a procedure. We want to +return a procedure, so either we call MAKE-PROCEDURE or we call + + (mc-eval (make-lambda ...) some-environment) + +Which environment should we extend? The one in the original procedure, +of course -- we don't want to break Scheme's lexical scope rule. Some +solutions passed the current environment from MC-EVAL to MC-APPLY, thereby +switching to dynamic scope. + +Many students came up with solutions modifying EXTEND-ENVIRONMENT instead of +modifying MC-APPLY. This is a reasonable first idea, since the problem is +about matching formal parameters with actual arguments, and that's the job of +EXTEND-ENVIRONMENT. But it's really tricky to get this right, because the +context in which EXTEND-ENVIRONMENT is called is that MC-APPLY is going to use +the resulting environment to evaluate the body of the procedure, and we don't +want to evaluate the body in the case of partial application. Some of you +actually managed to work around this problem by modifying EVAL-SEQUENCE as +well as EXTEND-ENVIRONMENT, something along these lines: + + (define (extend-environment vars vals base-env) + (if (= (length vars) (length vals)) + (cons (make-frame vars vals) base-env) + (if (< (length vars) (length vals)) + (error "Too many arguments supplied" vars vals) + (MAKE-PROCEDURE ...)))) + + (define (eval-sequence exps ENV-OR-PROC) + (cond ((COMPOUND-PROCEDURE? ENV-OR-PROC) ENV-OR-PROC) + ((last-exp? exps) (mc-eval (first-exp exps) env)) + (else (mc-eval (first-exp exps) env) + (eval-sequence (rest-exps exps) env)))) + +but this is an ugly solution. For one thing, EVAL-SEQUENCE might be used +someplace other than in MC-APPLY, so we shouldn't change its behavior without +thinking about those other callers. But even if the call to EVAL-SEQUENCE in +MC-APPLY is the only one in the program, it's ugly to have a procedure named +EVAL-SEQUENCE that sometimes doesn't actually evaluate a sequence! We +accepted working solutions on this model, but you shouldn't get in the habit +of designing this way. + + +Scoring: There are too many variants to list them all. We decided to group +them according to one central issue: do they actually return a procedure? + +6 Correct. + +5 Correct except for some trivial error. + +4 Has the idea: Checks for length mismatch between parameters and arguments, + and returns a procedure if there are fewer parameters, but something is + wrong with the new procedure's parameters, body, or environment. + +2 Has an idea: Checks for length mismatch, but then returns a lambda + expression, an environment, or something else that isn't an MCE procedure + (including an STk procedure formed by an underlying-Scheme LAMBDA + expression!). + +0 Anything else, including modifying only EVAL-SEQUENCE. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm1/mt1-1.soln.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm1/mt1-1.soln.txt new file mode 100644 index 0000000..80fa31f --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm1/mt1-1.soln.txt @@ -0,0 +1,423 @@ +CS 61A Solutions to sample midterm 1 #1 + +1. What will Scheme print? + +> (every - (keep number? '(the 1 after 909))) +(-1 -909) + + The KEEP part of the expression has the value (1 909), selecting the + numbers from the given sentence. (By the way, not everyone recognized + this as the name of a Beatles song, from the album _Let It Be_, the + last one they released, but the next-to-last one they recorded.) + + (every - '(1 909)) computes (- 1) and (- 909), putting the results in + a sentence. Some people thought this was an error because - requires + two arguments, but it doesn't. With one argument it means negation, + rather than subtraction. (Look it up in the Scheme reference manual + at the back of your course reader!) + + A few people said -908, because they thought EVERY would call the + function once, giving both numbers as arguments. That would be + (APPLY - '(1 909)), not EVERY. + + +> ((lambda (a b) ((if (< b a) + *) b a)) 4 6) +24 + + Substitute 4 for A and 6 for B in the body of the lambda: + ((if (< 6 4) + *) 6 4) + (< 6 4) is false, so the IF expression returns the multiplication + procedure, which is the value of the expression *. This procedure + is then called with 6 and 4 as its arguments. + + +> (word (first '(cat)) (butlast 'dog)) +CATDO + + The wrong answer we expected was CDO, but FIRST of a sentence is its + entire first word, even if there's only one word in it. Another + fairly common wrong answer was ERROR, presumably from people who + rightly thought that WORD won't accept a sentence as argument, but who + didn't see that FIRST of a sentence is a word, which makes it an okay + argument to WORD. + + A few people said CATOG because they didn't notice that it was + BUTLAST rather than BUTFIRST. We didn't take off for this. + +> (cons (list 1 2) (cons 3 4)) + +((1 2) 3 . 4) + + + --------- --------- + | | | | | | +--->| | | ------->| | | | | + | | | | | | | | | + --|------ --|---|-- + | | | + | V V + | + | 3 4 + | + V + --------- --------- + | | | | | /| + | | | ------->| | | / | + | | | | | | |/ | + --|------ --|------ + | | + V V + + 1 2 + + There were two important points to this problem: knowing the + difference between CONS and LIST, and knowing how Scheme prints + improper lists. (The two upper pairs in the diagram form the + spine of an improper list, which is a cdr-linked set of pairs in + which the cdr of the last pair isn't the empty list.) + + +> (let ((p (list 4 5))) + (cons (cdr p) (cddr p)) ) + +((5)) + + p is bound to (4 5) + (cdr p) evaluates to (5), and (cddr p) evaluates to () + (cons '(5) '()) evaluates to ((5)) + +Box and pointer diagram: + +---+---+ +--->| o | / | + +-+-+---+ + | + v + +---+---+ + | o | / | + +-+-+---+ + | + v + 5 + +> (cadadr '((a (b) c) (d (e) f) (g (h) i))) +(e) + +--->X/ + | + V + e + + We didn't take off for including other pairs from the large argument + in your picture, as long as there was a clear start arrow showing + where the return value starts. + + The quickest way to solve this problem is to remember that CADR means + the second element, and to view CADADR as (CADR (CADR ...)) -- the + second element of the second element of the argument. Alternatively, + we can spell it out step by step: + + (cdr '((a (b) c) (d (e) f) (g (h) i))) ==> ((d (e) f) (g (h) i)) + (car '((d (e) f) (g (h) i))) ==> (d (e) f) + (cdr '(d (e) f)) ==> ((e) f) + (car '((e) f)) ==> (e) + + The crucial point is to see that it's CAR of CDR of CAR of CDR of the + list, which means the first step is CDR -- you have to work from + inside out, which in a case like this means from right to left. If + you start by taking the CAR of the big list, you end up with the empty + list. + + + +Scoring: one point each. + + +2. Order of growth + +(define (foo n) + (if (< n 2) + 1 + (+ (baz (- n 1)) + (baz (- n 2)) ))) + +(define (baz n) + (+ n (- n 1))) + +FOO is Theta(1). + + Since FOO calls BAZ twice, we have to know the running time of BAZ + before we can figure out the running time of FOO. + + BAZ does not contain any recursive calls, either to baz itself or to + foo. Rather, it performs two fixed-time operations, an addition and a + subtraction, and so its running time is Theta(1). + + Therefore, everything FOO does is fixed-time! It calls <, +, -, and + BAZ, all of which are Theta(1). And so FOO itself is also Theta(1). + + The most frequent wrong answer was Theta(2^n). People who thought + that put too much weight on the *form* of procedure FOO. They saw two + procedure calls, and thought that the process was therefore comparable + to the Fibonacci computation or the Pascal's Triangle computation. + But in those cases, the two calls are *recursive* calls, not calls to + a fixed-time helper. + +(define (garply n) + (if (= n 0) + 0 + (+ (factorial n) (garply (- n 1))) )) + +(define (factorial n) + (if (= n 0) + 1 + (* n (factorial (- n 1))) )) + +GARPLY is Theta(n^2). + + GARPLY calls itself recursively N times, so it's tempting to think + that it's Theta(n), the most common wrong answer. But each of those N + invocations of GARPLY includes an invocation of FACTORIAL, which is + itself Theta(n). So N calls to a Theta(N) procedure makes a total of + N*N fixed-time operations. + +Scoring: one point each. + + +3. Normal and applicative order. + +The expression (* (counter) (counter)) has the value 2 under both +applicative and normal order. + +Under applicative order, all subexpressions are evaluated before * is called. +There are two subexpressions of the form (counter), each of which is +evaluated separately. The first evaluation returns 1; the second returns 2. +(It doesn't matter whether they are evaluated left to right or right to +left, since 1 times 2 = 2 times 1.) + +Under normal order, you might think that things would get more complicated, +but since * is a primitive (as the problem statement says), its arguments +are evaluated before it is invoked even under normal order. It's only +arguments to user-defined procedures that are handled differently. + +But even if we did something like this: + + (define (times a b) + (* a b)) + + (times (counter) (counter)) + +it wouldn't change the result. Normal order *would* affect the call to +TIMES, so that instead of substituting 1 and 2 for A and B, we'd +substitute the expression (COUNTER) for both A and B in the body of +TIMES. The result of that substitution would be + + (* (counter) (counter)) + +which is the same thing we started with. + +The most common error was to say that the answer would be 1 under applicative +order. People who said that were confusing this problem with a different one, +more like what I did in lecture: + + (define (square x) + (* x x)) + + (square (counter)) + +For *that* problem, the answer would be 1 under applicative order and 2 under +normal order. But this is the opposite of the situation you were given. +Normal order can turn one subexpression into multiple copies (which are then +separately evaluated), but it can't turn two expressions, even if identical, +into a single expression to be evaluated once. + +Interestingly, almost as many people said that the answer would be 1 under +*normal* order. My guess is that they were thinking of the square problem, +but instead of actually working through that problem, they just remembered +that normal order is the one that gives the weird answer. :-) + +Scoring: 1 point, all or nothing. + + +4. Recursive or iterative process? + +(define (butfirst-n num stuff) + (if (= num 0) + stuff + (butfirst-n (- num 1) (bf stuff)))) + +ITERATIVE PROCESS. The recursive call is the last thing the procedure has +to do. (It's inside an IF, but it isn't evaluated until after IF has decided +which branch to take.) + + +(define (member? thing stuff) + (cond ((empty? stuff) #f) + ((equal? thing (first stuff)) #t) + (else (member? thing (bf stuff))))) + +ITERATIVE PROCESS. Again, the recursive call is the last thing the +procedure has to do. + + +(define (addup nums) + (if (empty? nums) + 0 + (+ (first nums) + (addup (bf nums))))) + +RECURSIVE PROCESS. The recursive call is the last *line* of the procedure +definition, but it's inside a call to the + procedure, so the after the +recursion finishes we still have to call +. + +Scoring: one point each. + + +5. Recursive procedures. + +This is the only one that I didn't expect to be immediately obvious +to all of you. There are lots of ways to do it. Here is the one +suggested by the hint: + +(define (syllables wd) + (define (chop wd) + (cond ((empty? wd) "") + ((vowel? (first wd)) + (chop (bf wd))) + (else wd)) ) + (cond ((empty? wd) 0) + ((vowel? (first wd)) (+ (syllables (chop wd)) 1)) + (else (syllables (bf wd))) )) + +Another way is to count a vowel only if the next letter isn't one: + +(define (syllables wd) + (cond ((empty? wd) 0) + ((vowel? (first wd)) + (cond ((empty? (bf wd)) 1) + ((vowel? (first (bf wd))) (syllables (bf wd))) + (else (+ (syllables (bf wd)) 1)) )) + (else (syllables (bf wd))) )) + +Yet another way is to use a state variable to remember whether +or not the previous letter was a vowel: + +(define (syllables wd) + (define (s1 wd was-cons) + (cond ((empty? wd) 0) + ((vowel? (first wd)) (+ was-cons (s1 (bf wd) 0))) + (else (s1 (bf wd) 1)) )) + (s1 wd 1) ) + +There were too many kinds of errors to list. The trick here is +that the program structure can't be exactly like the examples +seen earlier, but you have to cope with that while not forgetting +everything you know about functional programming. For example, +many people wanted to keep a count of the number of syllables so +far in a state variable, so they said things like + (if (vowel? (first wd)) + (+ count 1) + (... something else ...)) +as if + CHANGED THE VALUE of the variable count. Thinking in BASIC! + + +6. Higher order procedures. + +(define (in-order? pred sent) + (cond ((empty? sent) #t) + ((empty? (bf sent)) #t) + ((pred (first sent) (first bf sent)) + (in-order? pred (bf sent)) ) + (else #f) )) + +(define (order-checker pred) + (lambda (sent) (in-order? pred sent)) ) + +One common error was to use (in-order? pred (bf (bf sent))) as the +recursive step, on the theory that the first two elements have already +been looked at. The trouble is that you have to compare overlapping +pairs of elements. For example, (in-order? < '(2 8 5 9)) should be +false, even though 2<8 and 5<9, because 8>5. + +Scoring: For part (a), three if it's right, two if it's correctly +typed (that is, your procedure takes a two-argument predicate and +a sentence as arguments, and returns true or false), one if it has +some idea, zero if not. For part (b), two if it's right, one if +it's correctly typed (takes a predicate function of two arguments +and returns a predicate function of one argument), zero if not. + + +7. Time ADT + +(define (time-print-form time) + (word (hour time) ': (two-digit (minute time)) (category time))) + +(define (two-digit num) + (if (< num 10) + (word 0 num) + num)) + + +(define (24-hour time) + (+ (* (hour time) 100) + (minute time) + (if (equal? (category time) 'pm) 1200 0))) + + +(define (make-time hr min cat) + (+ (* hr 100) + min + (if (equal? cat 'pm) 1200 0))) + +(define (hour time) + (if (>= time 1200) + (- (div time 100) 12) + (div time 100))) + +(define (minute time) + (remainder time 100)) + +(define (category time) + (if (>= time 1200) 'pm 'am)) + + +The most common serious errors were writing a non-function in part (a) and +rewriting make-time with the wrong number of arguments in part (c). These +errors were the ones that gave rise to the most complaints about harsh +grading, but I really think they're about crucial issues in the course. + +Part (a) says, "Write a FUNCTION time-print-form that takes a time as its +argument and RETURNS a word of the form 3:07pm." In week 7 of the course +you should know what it means for a function to return a value! Some people +said they were confused by the fact that the word "print" is part of the +function's name, but a "print form" is the form in which we want things to +be printed; computing the print form of a time doesn't mean that we should +actually print it! Maybe the print form will be used as part of a larger +sentence that we'll want to print later. + +Part (c) says, "Now we decide to change the *internal* representation of +times to be a number in 24-hour form. BUT WE WANT THE CONSTRUCTOR AND +SELECTORS TO HAVE THE SAME INTERFACE SO THAT PROGRAMS USING THE ABSTRACT +DATA TYPE DON'T HAVE TO CHANGE." That means that the arguments to make-time +must be the same things they were all along: an hour (in 12-hour time), a +minute, and a category (am/pm). + + +Many people returned 3:7pm instead of 3:07pm in part (a), because they +thought that it would be sufficient to say something like + (time-print-form (make-time 3 07 'pm)) +The trouble is that Scheme interprets 07 as the number 7; Scheme doesn't +remember exactly how you typed the number. This was a minor error. + +Many people, in part (c), changed the internal representation to something +other than a number, e.g., a list of two numbers. I've spoken with four +students who didn't understand why this was wrong, and I asked them to +read the first sentence of part (c), and they said "... representation of +times to be in 24-hour form." And I said, "No, read it again." On the +third or fourth try they'd finally read the words "a number." Sigh. + +Typical errors and scores: + +4 3:7pm +3 changes internal form to (15 7) instead of 1507 +2 printing in (a) or wrong args in (c), as above +1 glimmers of using the abstraction diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm1/mt1-2.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm1/mt1-2.pdf new file mode 100644 index 0000000..e7f1e90 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm1/mt1-2.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm1/mt1-3.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm1/mt1-3.pdf new file mode 100644 index 0000000..09e97c3 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm1/mt1-3.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-1.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-1.pdf new file mode 100644 index 0000000..0b90000 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-1.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-1.soln.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-1.soln.txt new file mode 100644 index 0000000..e80be44 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-1.soln.txt @@ -0,0 +1,411 @@ +CS 61A Solutions to sample midterm 2 #1 + +1. What will Scheme print? + +Note: Please draw actual boxes, as in the book and the lectures, not XX and X/ +as in these ASCII-art solutions. + +Also, please put in the start arrows! Sometimes it's hard to know where your +diagrams are supposed to begin, especially if you use leftward and upward +pointing arrows. + +> (map caddr '((2 3 5) (7 11 13) (17 19))) +ERROR + + (caddr '(2 3 5)) is 5; (caddr '(7 11 13)) is 13. But (17 19) + doesn't have a caddr, which would be the third element of a + two-element list. The error is attempting to take the car of + the empty list. + + The most common wrong answer was (5 13), thinking that the error + would just slide under the rug. + +> (list (cons 2 (cons 3 5))) +((2 3 . 5)) + + +--->X/ + | + XX--->XX---> 5 + | | + V V + 2 3 + + There were two points to note in this problem: (cons 3 5) creates + an improper list, and LIST is called with one argument, making a + one-element list (whose spine is the topmost pair in the diagram). + + One error was to think that every call to CONS results in something + that prints with a dot, like this: ((2 . (3 . 5))) But in fact + Scheme never prints a dot if the cdr is a pair; if the ultimate + pair of a chain of cdr-linked pairs doesn't have the empty list as + its cdr, you get the improper list notation (2 3 . 5) + + The extra parentheses in the printed form show that the result is + a one-element list whose element is a list structure (in this case, + an improper list rather than an actual list). + + +> (append (list '(2) '(3)) (cons '(4) '(5))) +((2) (3) (4) 5) + + +--->XX--->XX--->XX--->X/ + | | | | + V V V V + X/ X/ X/ 5 + | | | + V V V + 2 3 4 + + The most problematic part of this for most students was the CONS. + Some people, remembering that the arguments to APPEND must be + lists, said that this produced an error -- but of course CONS can + produce a list, if its second argument is a list, as it is here. + [Fine print: In fact the *last* argument to APPEND is *not* required + to be a list, although the others are. See the Scheme reference + manual.] In this case, the CONS call produces the list ((4) 5). + The asymmetry in the handling of (4) and (5) comes from the meaning + of CONS in creating a list: the first argument, the car of the new + pair, is an *element* of the resulting list, whereas the second + argument, the cdr of the new pair, is a *sublist* of the resulting + list. If this confuses you, think about what you'd expect + (cons 4 '(5)) + to do. + + The most common error, still about the CONS call, was to see that + it has to do something different from the LIST call, but still + try to make it treat its arguments symmetrically, resulting in + the wrong answer ((2) (3) 4 5). + + +> (list (cons '(0) '(1)) (append '(2) '(3))) +(((0) 1) (2 3)) + +--->XX------------->X/ + | | + V V + XX--->X/ XX--->X/ + | | | | + V V V V + X/ 1 2 3 + | + V + 0 + + LIST returns a list with as many elements as it has arguments -- in + this case, two elements. The top two pairs in the diagram are the + ones generated by LIST. + + CONS generates exactly one new pair. In this problem, the first pair + on the second line of the diagram is the one generated by CONS. Its + car is the pair on the third line, which is the list (0); its cdr is + the second pair on the second line, which is the list (1). The + important thing to see here is that the lists (0) and (1) do not play + similar roles in the result, because of the way lists are defined. + The car of a pair is a list *element*; the cdr of the same pair is a + *sublist*. So the value returned by the CONS invocation is a list of + two elements, namely (0) and 1 -- not (0) and (1); not 0 and 1. + + APPEND strings together the elements of its arguments, so in this + case, the result of the APPEND invocation is the list (2 3). + +There were two common wrong answers to this part. One mistake was to put +the last element of a sublist in the cdr of a pair, like this: + +--->XX------------->X/ ; WRONG! + | | + V V + XX--->1 XX--->3 + | | + V V + X/ 2 + | + V + 0 + +The numbers 1 and 3 are attached to the cdrs of their parent pairs, +rather than to the cars. + +The other common mistake was to leave out the pair just above the zero, +like this: + +--->XX------------->X/ ; WRONG! + | | + V V + XX--->X/ XX--->X/ + | | | | + V V V V + 0 1 2 3 + +A less common, but more serious, error was to leave out part of the +work by having parentheses in the diagram: + +--->XX------------->X/ ; WRONG! + | | + V V + XX--->(1) XX--->(3) + | | + V V + (0) 2 + +There are never any parentheses in a box and pointer diagram. The +parentheses in the *printed representation* of a list structure are +just a notation to represent *pairs* in the actual structure. + + +Scoring: One point for each printed result; one point for each diagram, +except for the first part, which got two points or none. + + +2. Binary search trees + +Although the ADT doesn't include empty trees, the program is easier to +write if you allow for the possibility of getting an empty list as +argument instead of a tree, because that's what happens when you try to +recur for the children of a leaf node. On that assumption, here's one +way to write it: + +(define (all-smaller? tree num) + (or (null? tree) + (and (< (entry tree) num) + (all-smaller? (left-branch tree) num) + (all-smaller? (right-branch tree) num)))) + +(define (bst? tree) + (or (null? tree) + (and (all-smaller? (left-branch tree) (entry tree)) + (all-larger? (right-branch tree) (entry tree)) + (bst? (left-branch tree)) + (bst? (right-branch tree))))) + +Most people wrote equivalent programs using COND, which is fine, but I +find this style cleaner when writing predicates. + +A BINARY TREE is just a tree in which each node has at most two +children. A BINARY SEARCH TREE is a binary tree with the ordering +constraints as described in the text. The text doesn't make that +entirely clear, because their only use of binary trees is to represent +the SET ADT, for which a BST is needed. Therefore, we didn't take off +points if in part (a) you assumed the ordering relationship and therefore +only checked the right branch of the tree, as long as you did the tree +recursion properly in (b). + +Scoring: This and the remaining problems are graded on the scale + 5 correct + 3-4 has the idea + 1-2 has an idea + 0 other + +Having the idea, in this problem, means doing a tree recursion. The most +common form of not having the idea was to think, in part (b), that the +ordering must be checked only with respect to the root node, so you left +out the recursive calls to BST?. + +We took off one point if you violated the binary tree ADT, using CAR and +CDR instead of ENTRY, LEFT-BRANCH, and RIGHT-BRANCH. (If you thought +that those three things are names of trees, rather than of procedures, +you didn't have the idea.) + +A too-common error was to say things like + (< (left-branch tree) (entry tree)) +as if the left branch were a number! It's not; it's a tree. + + +3. Tree fanout. + +The best answer is + +(define (max-fanout tree) + (accumulate max + (length (children tree)) + (map max-fanout (children tree)))) + +This takes advantage of the fact that ACCUMULATE requires a starting value +for the accumulation, usually 0 or 1 in the book's examples, but we can use +the fanout of this node as the starting value. + +Here's the non-higher-order, mutual-recursion version: + +(define (max-fanout tree) + (max (length (children tree)) + (max-fanout-forest (children tree)))) + +(define (max-fanout-forest forest) + (if (null? forest) + 0 + (max (max-fanout (car forest)) + (max-fanout-forest (cdr forest))))) + +Some people made this more complicated by using a one-element forest as +the base case in max-fanout-forest, thereby requiring that max-fanout +check for the special case of a leaf node. If this were a general +problem about accumulating the MAX of arbitrary numbers, we couldn't use +0 as the base case, because all the numbers might be negative, so if +anything the base case would have to be negative infinity. But here +the numbers are node fanouts, and there's no such thing as a negative +number of children! + +Note that max-fanout does not need a base case. The recursion happens +either in MAP, for the first solution, or in MAX-FANOUT-FOREST, for +the second solution. + +Having the idea, in this problem, mostly meant understanding the Tree ADT. +The totally wrong solutions were ones that applied CAR and CDR to a Tree -- +or, equivalently, the ones that said DATUM and CHILDREN but meant CAR and +CDR. Note that there is no reference to DATUM in a correct solution to +this problem! The fanout has nothing to do with the values in the nodes, +only with the Tree's shape. + +Not only is CAR/CDR recursion a data abstraction violation, it's also a +fundamental misunderstanding of this particular problem. It's often the +case that similar problems could be posed for abstract Trees and for +list structures viewed as trees. But if you use CAR/CDR recursion, you +are thinking of each pair as a node in a binary tree, essentially, so +the fanout is always 2! The whole issue of fanout doesn't arise unless +you have real Trees to think about. + +CAR/CDR programs, or their equivalent -- such as programs with expressions +of the form (not (pair? tree)) -- got at most 2 points, but more often 0 or 1. +So did programs that confused trees with forests. + +Some not-so-bad programs tried to apply MAX to a list of lists of numbers, +rather than to a list of numbers. Our general rule was that if we could +fix your program by replacing a call to MAP with a call to FLATMAP, it +got 3 points. + +A common problem, not so bad, was to get confused about the domain of MAX. +This procedure takes numbers as arguments, not lists; you can't say + (max '(1 2 3 4)) +but you *can* say + (apply max '(1 2 3 4)) +or in this case, because all the numbers are positive, + (accumulate max 0 '(1 2 3 4)) +The advantage of ACCUMULATE over APPLY is that in some cases, people who +used APPLY ended up applying MAX to an empty list -- in other words, trying +to call MAX with no arguments. That's not allowed, but ACCUMULATE always +calls MAX with exactly two arguments, if at all, so it doesn't have the +same potential bug. All problems in this category lost only one point. + +The comments in the solution to question 2 about making unnecessary data +structures apply here, too. Several people made trees in which the datum +of each node was replaced by its fanout. Others made linear sequences of +tree nodes. All of these things only complicate the program; whatever you +end up doing to create the structure and then process it could instead +solve the problem directly in one step. + +Scoring: 3 or more points for a solution that uses the Tree ADT correctly +and actually computes fanouts and maximums. 2 or fewer points for a solution +with car/cdr recursion, tree/forest confusion, nothing about fanouts, or +nothing about maximum. + + +4. Data-directed programming. + +(define (plus x y) + (let ((tx (type x)) + (ty (type y))) + (if (eq? tx ty) + (attach-tag tx (+ (contents x) (contents y))) + (let ((gxy (get tx ty)) + (gyx (get ty tx))) + (cond ((number? gxy) + (attach-tag ty (+ (* gxy (contents x)) (contents y)))) + ((number? gyx) + (attach-tag tx (+ (contents x) (* gyx (contents y))))) + (else (error "You can't add apples and oranges."))))))) + + +The use of LET in this solution isn't essential; various rearrangements +are possible and are equally good. + +Surprising numbers of people had trouble understanding what the problem +was asking for. They wrote programs in which 3 dynes PLUS 4 centimeters +equals 12 ergs! Sorry, 3 plus 4 is not 12 no matter how clever your +coding style is. As the problem clearly stated, you were asked to write +one procedure, the addition procedure, for a larger project that would +also include a multiplication procedure when completed. Moral: don't +be in such a hurry to write code. Make sure you understand the problem +you are being asked to solve first! + +Another common way to get in trouble was to try to apply the number you +found in the table (12, in the example) as a procedure. Just because +there is an example in the book in which a table contains procedures as +entries, that doesn't mean that every table has to contain procedures! +This particular table contains numbers, for units that can be added +together, and symbols, for units that can be multiplied. + +Scoring: 8 points for a perfect solution. + 4-7 points for a flawed solution not grossly confused. + 2-3 points for a grossly confused but not clueless solution. + 0-1 point for a solution showing no understanding at all. + +In general we subtracted two points for each flaw, down to the +minimum for the categories as indicated. Here are some 2-point errors +that bottomed at 4 points: + +-- not checking the number? predicate +-- not checking for the arguments being backwards in the table +-- incorrect conversion formula +-- violation of the attach-tag data abstraction +-- wrong args to GET + +Here are some errors eligible for the 2-3 point range: + +-- checking explicitly for 'ft or 'in +-- applying a non-procedure +-- Lisp syntax errors like non-symbol formal parameters + + +5. OOP + +The central point of this question is that in the OOP paradigm, objects are +used for everything, and the structure of the object classes reflects the +structure of the real-world situation being simulated. + +(a) parenthood + +The class VANILLA has the class SCOOP as its parent, because a vanilla scoop +is a particular kind of scoop. + +Is a scoop a special kind of cone? No. + +Is a cone a special kind of scoop? No. + +So the correct answer is "Neither." Most people got this; the most common +wrong answer was to say that SCOOP should have CONE as its parent, probably +because a scoop can be viewed as *part of* a cone. But the parent/child +relationship isn't "a part of"; it's "a kind of." + +(b) flavors method + +(method (flavors) + (map (LAMBDA (S) (ASK S 'FLAVOR)) scoops)) + +You *could* write the CONE class so that its instance variable SCOOPS would be +a list of flavors (i.e., names of flavors) instead of a list of scoop objects. +But that wouldn't be following the OOP paradigm. (Not to mention that using +the name SCOOPS for a list of flavors would be really confusing!) So if we +want to know the flavors in a cone, we have to ask each scoop for its flavor. + +A few people said something like (USUAL 'FLAVOR) instead of (ASK S 'FLAVOR), +presumably because FLAVOR is a method of the SCOOP class, rather than of the +VANILLA or CHOCOLATE class. But even if this could work, the whole idea of +inheritance is that you can send the child class (e.g., VANILLA) the same +messages you can send to the parent class (SCOOP). You don't have to know +whether VANILLA handles the FLAVOR message itself or delegates the message to +its parent. And in any case it wouldn't work; USUAL can only be used inside +a DEFINE-CLASS, because otherwise it doesn't know what object you're talking +about! + + +(c) adding a scoop + +Given a particular ice cream cone, we want to add a particular scoop of +vanilla ice cream to it -- not the VANILLA class, and not the word VANILLA. +So the right answer is the last one listed: + (ask my-cone 'add-scoop (instantiate vanilla)) +The argument to INSTANTIATE is a class, not the name of a class. + +Scoring: 2 points each. No partial credit except that in part (B) leaving +out the quotation mark before FLAVOR got one point. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-2.soln.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-2.soln.txt new file mode 100644 index 0000000..701905a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-2.soln.txt @@ -0,0 +1,609 @@ +CS 61A Solutions to sample midterm 2 #2 + +1. What will Scheme print? + +Please put in the start arrows! Sometimes it's hard to know where your +diagrams are supposed to begin, especially if you use leftward and upward +pointing arrows. + +> (list (cons 2 3) 4) +((2 . 3) 4) + + +---+---+ +---+---+ + | | | | | /| +--------->| | | ------->| | | / | + | | | | | | |/ | + +-|-+---+ +-|-+---+ + | | + | V + | + | 4 + | + V + +---+---+ + | | | + | | | | | + | | | | | + +-|-+-|-+ + | | + V V + + 2 3 + +Most people got this. The ones who didn't most often left out the dot +in the printed version. + + +> (append (cons '(a) '(b)) '(c)) +((A) B C) + + +---+---+ +---+---+ +---+---+ + | | | | | | | | /| +---------> | | | ----->| | | ----->| | | / | + | | | | | | | | | | |/ | + +-|-+---+ +-|-+---+ +-|-+---+ + | | | + | V V + | + | B C + V + +---+---+ + | | /| + | | | / | + | | |/ | + +-|-+---+ + | + V + + A + +Many people were confused about this one, especially the CONS part. +Here is a box and pointer diagram of (cons '(a) '(b)). The starred +pair is the one created by the CONS: + + + *********** + *+---+---+* +---+---+ + *| | |* | | /| +--------->*| | | ----------->| | | / | + *| | | |* | | |/ | + *+-|-+---+* +-|-+---+ + ***|******* | + | V + | + | B + | + V + +---+---+ + | | /| + | | | / | + | | |/ | + +-|-+---+ + | + V + + A + +Even though this structure was created using CONS rather than LIST, +it's a list, because the cdr of the new pair is a list. This list +has two elements; the first is (A) and the second is B. So in +effect the call to APPEND is (append '((a) b) '(c)). + +We weren't very sympathetic to people who drew diagrams like this: + + +---+---+ + | | | +---------->| | | ------> etc + | | | | + +-|-+---+ + | + V + + (A) + +Things in parentheses in the printed representation must be shown +as pairs in the diagram! + + + +> (cdadar '((e (f) g) h)) +() + +Note that the result is (), not '()! + +There really is no need for a box-and-pointer diagram for an empty +list, which is an atom. We accepted + + +---+ + | /| +---------->| / | + |/ | + +---+ + +but *NOT* this: + + +---+---+ + | /| /| +---------->| / | / | + |/ |/ | + +---+---+ + +because that would be a pair, representing the list (()), not an empty list. + +Some people got this wrong because they figured the cdadar incorrectly. +Here's how to get there: + +(car '((e (f) g) h)) ===> (e (f) g) +(cdr '(e (f) g)) ===> ((f) g) +(car '((f) g)) ===> (f) +(cdr '(f)) ===> () + +CDADAR is an abbreviation for (cdr (car (cdr (car ...)))), so you have +to start at the inside and take the CAR of the argument first. Some +people read CDADAR left to right as "take the cdr, then the car, ..." +but that's wrong. + +Scoring: One point for each, with both printed form and b&p diagram +correct to get the point. One point total for people who got all three +printed results correct but left out the b&p diagrams. + + + +2. Fill in the blank. + +> (CADADR '(g (h i) j)) +I + + +The letter I is the second element of (H I), so it's + (cadr '(h i)) +But the sublist (h i) is the second element of the entire argument, +so it's + (cadr '(g (h i) j)) +So we want + (cadr (cadr '(g (h i) j))) +and that's abbreviated as CADADR. + +Scoring: one point, all or nothing! + + +3. Proj2 data abstraction + +(a) Type-tagged segment ADT. The solution we wanted was this: + +(define (make-segment start end) + (attach-tag 'segment (cons start end))) + +(define (start-segment seg) + (car (contents seg))) + +(define (end-segment seg) + (cdr (contents seg))) + +Alternatively, you could use LIST instead of CONS and CADR instead of CDR. + +Here is the crucial point to understand about data abstraction: WE WANT +THIS CHANGE NOT TO BREAK EXISTING PROCEDURES IN THE PROJECT! That means +that start-segment, for example, must return a vector, just as it did +before the change. + +Some people wrote + +(define (start-segment seg) ;; wrong!!! + (attach-tag 'segment (car seg))) + +One problem with this is that the start-segment of a segment isn't the +car of the argument anymore, once we have a type attached. But it's +much worse to attach the SEGMENT type to the result, because the result +isn't a segment! It's a vector. + +Other people gave make-segment only one argument. Probably this means +that you don't know what a segment is, because you let your partner do +all the work on the project. + + +Scoring: +2 As shown above. +1 Working code, but not respecting the tagged-data abstraction + (e.g., cons instead of attach-tag, cadr and cddr in the selectors). +0 Anything else. + + +(b) Find the midpoint of a segment or frame. + +(define (midpoint shape) + (cond ((eq? (type-tag shape) 'segment) + (scale-vect 0.5 + (add-vect (start-segment shape) + (end-segment shape)))) + ((eq? (type-tag shape) 'frame) + ((frame-coord-map shape) (make-vect 0.5 0.5))) + (else #f))) + +We accepted less elegant but correct algorithms for the midpoints of +the shapes. For a segment another approach is + + (make-vect (/ (+ (xcor-vect (start-segment shape)) + (xcor-vect (end-segment shape))) + 2) + (/ (+ (ycor-vect (start-segment shape)) + (ycor-vect (end-segment shape))) + 2)) + +For frames we saw two other correct approaches. One was essentially +to rewrite frame-coord-map: + + (add-vect (origin-frame shape) + (scale-vect 0.5 + (add-vect (edge1-frame shape) + (edge2-frame shape)))) + +Another was to find the midpoint of a diagonal of the parallelogram: + + (midpoint (make-segment (add-vect (origin-frame shape) + (edge1-frame shape)) + (add-vect (origin-frame shape) + (edge2-frame shape)))) + +Most people had correct algorithms for the midpoint of a segment. There +were two common incorrect algorithms for frames; one wrong approach was +to ignore the frame's origin, and the other was to assume that the frame's +edge1 contributes only to the x-coordinate of the midpoint and that its +edge2 contributes only to the y-coordinate. + +One reason for incorrect solutions to the midpoint of a frame was that +people confused the origin of the FRAME with the origin of the COORDINATE +SYSTEM -- that is, the point (0, 0). The vector returned by +(origin-frame shape) points from the coordinate system origin (0, 0) to +the frame's origin, which is one of its corners. That corner might or +might not be at (0,0)! For example, when you wrote procedures like +BELOW in the project that combine two pictures in adjacent frames, at +least one of those frames doesn't begin at (0, 0). + +Some people wrote a data-directed solution, including things like + + (put 'frame 'midpoint frame-midpoint) + +This was okay, but more work than the problem required. Other people +tried to use message passing, with less success. A correct use of +message passing means that the data -- the frames and segments -- must +be represented as procedures: + +(define (make-segment start end) + (lambda (message) + ...)) + +But this is incompatible with part (a)! Some people tried to use a +dispatch procedure for the *operator*: + +(define (midpoint shape) ;; wrong! + (lambda (message) + ...)) + +but that doesn't make any sense. You send messages to objects, not +to operators. In general, the way to learn in this course is to focus +on the IDEAS, not on the SYNTAX. Don't think: "Message passing means +that you say (lambda (message) ...) somewhere." Instead think: +"Message passing means that the data objects in the system know how +to carry out operations on themselves." + + +Some people either didn't read or didn't understand the sample exams +in the course reader. Here is a quote from the spring 1995 solutions: + + *** RESPECTING THE DATA ABSTRACTION DOES **NOT** MEAN SAYING "DATUM" + *** WHENEVER YOU MEAN CAR, AND "CHILDREN" WHENEVER YOU MEAN CDR!! That + is precisely DISrespecting the data abstraction! Respecting it means to + distinguish between a Tree, whose component parts are called datum and + children, and other data types that have other component parts, such as + forests (car and cdr, since a forest is just a particular kind of + sequence), rational numbers (numer and denom), and so on. + +The same thing is true here, except that instead of Trees, this problem +used tagged data. RESPECTING THE DATA ABSTRACTION DOES **NOT** MEAN +SAYING "TYPE-TAG" WHENEVER YOU MEAN CAR, AND "CONTENTS" WHENEVER YOU MEAN CDR! +That is precisely DISrespecting the data abstraction! Respecting it means +to distinguish between a type-tagged datum, whose component parts are +called type-tag and children, and other data types that have other component +parts, such as segments, frames, and vectors. + + +Scoring: + +3 Correct. + +2 The structure of the COND correct, and also + (a) both algorithms work, but have data abstraction violations, or + (b) one algorithm is correct, and there are no DAVs. + +1 At least one working algorithm. + +0 Other. + + +4. Maximum path in Tree + +(define (maxpath tree) + (if (null? (children tree)) + (datum tree) + (+ (datum tree) + (biggest (map maxpath (children tree)))))) + +Notice that there is no CAR or CDR in this program! + +If you didn't want to use MAP, the equivalent recursive solution is + +(define (maxpath tree) + (if (null? (children tree)) + (datum tree) + (+ (datum tree) + (maxpath-forest (children tree))))) + +(define (maxpath-forest forest) + (if (null? (cdr forest)) + (maxpath (car forest)) + (max (maxpath (car forest)) + (maxpath-forest (cdr forest))))) + +This solution does take the CAR and the CDR of a forest (which is +a sequence of Trees), but still does not apply CAR or CDR to a Tree. + +In either case, the algorithm is to find the maxpath of each child, +take the biggest of those, and add the value at the root. So, for +the example in the exam, the maxpath values for the three children +are 10 (7+3), 11 (2+9), and 10 (4+6). The biggest of those is 11, +so we add 5 to that and the overall answer is 16. + +It doesn't work to find the largest immediate child of the root +and work downward from there. In this example, the largest of the +children is 7, the first child, but the largest overall path doesn't +go through that child. + + +PLEASE don't ever try to solve a tree problem iteratively! Iteration +is good for sequences of information -- that is, for one-dimensional +structures. But tree problems are fundamentally recursive. A lot of +solutions had the form + +(define (maxpath tree) + (maxpath-helper tree (children tree) tree '() '() 0 (datum tree))) + +or some similar thing with zillions of extra arguments. All such +solutions turned out to be quite wrong, and what's worse, they take +a long time for us to grade! :-( + + +Here's another correct solution that some people tried: + +(define (maxpath tree) + (biggest (maxpath-helper tree))) + +(define (maxpath-helper tree) + (if (null? (children tree)) + (LIST (datum tree)) + (map (lambda (t) (+ (MAXPATH t) (datum tree))) + (children tree)))) + +Unfortunately, most people who tried this made two mistakes; one was +to leave out the LIST, using just (datum tree) as the base case, and +the other was to call maxpath-helper instead of the capitalized +MAXPATH above. Both of these errors could be avoided by thinking +about the domains and ranges of the functions involved: + + function argument return + + biggest list of numbers number + maxpath Tree number + maxpath-helper Tree list of numbers + +Since BIGGEST expects a list as its argument, maxpath-helper +must return a list, even in the base case. And since + expects +numbers as arguments, you can't use maxpath-helper to provide +one of the arguments to +, because maxpath-helper returns a list. + + +This was apparently the hardest problem, mainly because people don't +understand the Tree Abstract Data Type. The two parts of a Tree +are its DATUM, which is a number, and its CHILDREN, which is a forest, +that is, a list of Trees. A list of Trees is not a Tree! An expression +such as (maxpath (children tree)) has to be wrong because maxpath +requires a Tree as its argument, not a list of Trees. + + +Scoring: There were so many wrong approaches that I can't possibly +list them all. The general strategy we tried to follow was + +5 correct +3-4 has the idea +1-2 has an idea +0 no idea + +Here are a few common cases: + +4 correct except for the base case +3 recursive call to maxpath-helper as described above +2 (maxpath (children tree)) +2 binary tree ADT (e.g., calls to left-branch and right-branch) +1 (biggest (children tree)) with no recursion + + +5. Debugging the broken EVAL-1. + +Of the six test cases given, the four that don't give error messages +give the correct answer; it's the two that say ERROR that are wrong. +What do those two have in common? A compound expression -- a procedure +call -- is used as an argument to another procedure. + +(In the first case, the expression (* 2 2) provides an argument to +; +in the second, the expression (+ 1 1) provides an argument to the +procedure created by the lambda expression.) + +So there's something wrong with the evaluation of argument subexpressions. +That evaluation of subexpressions happens on line 11. The correct line is + + (map eval-1 (cdr exp)) )) ; closing earlier open parentheses + +The reason some of the test cases *do* work is that numbers are +self-evaluating, so using the argument expressions instead of the argument +values doesn't matter if the argument is just a number. The student said + + (cdr exp) )) ; This is what you should have in your solution. + +leaving out the MAP EVAL-1 part. + +The most common error was to say that the error was + + (eval-1 (cdr exp)) )) + +omitting just the MAP. But that would be a disaster; none of the examples +would have worked. Take the first test case: (+ 2 3). If that's EXP, +then (CDR EXP) is (2 3). But if we try to EVAL-1 that list, we are asking +to invoke the procedure 2 with the argument 3! + +By the way, the reason the last test case doesn't fail is that IF is a +special form, so eval-1 never reaches line 11; the subexpressions are +evaluated on lines 6-8. + +Scoring: 5 if correct, 2 if line 11 changed incorrectly, otherwise 0. +(But in the rare cases where the correct change was attributed to line +10 or 12, we figured you just misread the line numbers and didn't take +off points.) We ignored any explanations you gave, which was a good thing +in some cases because the explanations were iffy. + + +6. Data directed programming + +I said at least twice in lecture that data-directed programming does NOT +mean using get and put; the book's example of data-directed programming +is just one example of a more general idea. The idea is that instead of +building the specific details of one problem into our procedures, we +write more general procedures that use some auxiliary data structure to +specify the precise problem we're supposed to solve. In this case, the +list of transitions ((1 A 2) (1 B 3) ...) is the data structure that +tells our GENERAL fsm interpreter which SPECIFIC fsm we're using. + +To make that clearer, here is a program for the particular fsm used as +the example in the question, NOT using data-directed programming: + +(define (transition state letter) + (cond ((= state 1) (state1 letter)) + ((= state 2) (state2 letter)) + ((= state 3) (state3 letter)) + ((= state 4) (state4 letter)) )) + +(define (state1 letter) + (cond ((eq? letter 'A) 2) + ((eq? letter 'B) 3) + ((eq? letter 'C) 4) + (else 0) )) + +(define (state2 letter) + (cond ((eq? letter 'A) 1) + (else 0) )) + +... and so on for the other two states. This program has the specific +transition information built into its procedures. If you wanted to +change a transition, you'd have to rewrite some procedure. Some people +did in fact offer solutions like this, and got no credit. Here is the +solution we had in mind: + +(define (transition fsm state letter) + (cond ((null? fsm) 0) + ((and (= state (caar fsm)) + (eq? letter (cadar fsm)) ) + (caddar fsm) ) + (else (transition (cdr fsm) state letter)) )) + +(define (process fsm state wd) + (if (empty? wd) + state + (process fsm (transition fsm state (first wd)) (bf wd)) )) + +This program works not only for the particular fsm diagrammed in the +question, but for ANY fsm, if we give it the appropriate list of +transitions as an argument. + +For some reason that I don't understand, practically everyone returned +(cddar fsm) instead of the correct (caddar fsm). You want the third +ELEMENT of the transition sublist, not a SUBLIST of the transition sublist. +But we didn't take off for that. + +It's perfectly fine if you want to avoid things like "caddar" (pretty hard +to work through, isn't it?) by defining an abstract data type for +transitions. But please don't think that "data-directed programming" +MEANS using abstract data types. The two ideas are quite distinct, even +though we talked about tagged data during the same week as ddp. If +you want to use an abstract data type your program will look like this: + +(define start-state car) +(define arrow-label cadr) +(define end-state caddr) + +(define (transition fsm state letter) + (cond ((null? fsm) 0) + ((and (= state (start-state (car fsm))) + (eq? letter (arrow-label (car fsm)) ) + (end-state (car fsm)) ) + (else (transition (cdr fsm) state letter)) )) + +You could also define selectors like first-transition and rest-transitions +for the fsm list itself, but I wouldn't bother. Car and cdr are clear +enough for a sequence of any number of the same kind of thing, such as a +sequence of transition triples. + +But, speaking of data types, it won't work at all to use car and cdr on +the word we're processing in part B! Car and cdr only work on pairs +(and lists, which are made of pairs), not on words. + +It would indeed be possible to use GET and PUT to implement a data-directed +fsm program. You'd set up the program for a particular fsm by PUTting each +transition, with the start state and letter as the row and column labels, +and the end state as the contents of each cell. This isn't exactly what we +asked for, but we gave full credit if you did that properly. But we gave +no credit at all if you tried to invoke the contents of the cell as a +procedure! If you did that, you were just blindly copying the example from +the book without understanding it. + +Scoring: Having the idea in part A meant using the fsm list to write a +general program. No credit if the letters A, B, and C appeared in your +program (not data directed) nor if you invoked something you found in a +table (totally off the wall). Having the idea in part B meant using the +procedure you wrote in part A! People who tried to do part B from scratch +invariably wrote programs that CDRed down the fsm list once, then lost it +and couldn't process the second letter. If you got part A completely right +but totally messed up part B, that was three points. The other way around +was two points. If you partially messed up both parts, we used our +judgement in accord with the standard five-point formula. + + +7. OOP + +(a) Parents and children. A child class is /a kind of/ the parent class, or +/a specialization of/ the parent class, /not/ a part or subset of the parent. + +Is a keypad a kind of cell phone? NO, a keypad is part of a cell phone. + +Is an office building a kind of building? YES. + +Is a staple a kind of stapler? NO, it's something you put into a stapler. + +Is an arm bone a kind of arm? NO, it's part of the arm. + +Is an arm bone a kind of bone? YES. + +Is an arm bone a kind of person? NO, it's part of a person. + +(b) Class or instance variable. It's a class variable if it's the same for +every instance of the class; it's an instance variable if each instance has +its own value. + +The number of taxis in the city isn't different for each taxi; it's a property +of the entire CLASS of taxis. + +The number of milk cartons in a fridge is different for each fridge; mine has +quite a few because my son and I can't agree about whether to use fat-free +milk or high-fat (2%) milk, so we get both kinds. A fridge in a photographic +studio might be full of film, and have no milk cartons at all. So the number +is different for each INSTANCE of the fridge class. + +Scoring: 1/2 point each, rounded down to an integer. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-3.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-3.pdf new file mode 100644 index 0000000..47a822a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm2/mt2-3.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-1.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-1.pdf new file mode 100644 index 0000000..e79cafe --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-1.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-1.soln.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-1.soln.txt new file mode 100644 index 0000000..174ff1a --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-1.soln.txt @@ -0,0 +1,526 @@ +CS 61A Solutions to sample midterm 3 #1 + +1. Box and pointer. + +(let ((x (list 1 2 3))) + (set-car! x (list 'a 'b 'c)) + (set-car! (cdar x) 'd) + x) + +((a d c) 2 3) is printed. + +X-->[o|o]-->[o|o]-->[o|/] + | | | + | V V + | 2 3 + V + (o|o)-->{o|o}-->[o|/] + | | | + V V V + a d c + +The result of the first set-car! is ((a b c) 2 3); the second set-car! changes +the B to D. (car x) is the pair in (parentheses) in the diagram above, so +(cdar x) is the pair in {braces}. + + +(define x 3) +(define m (list x 4 5)) +(set! x 6) +m + +(3 4 5) is printed. + +M-->[o|o]-->[o|o]-->[o|/] + | | | + V V V + 3 4 5 + +The point of this example is that once (list x 4 5) has been evaluated, it +doesn't matter that the 3 came from X; the list contains the values, not the +expressions that produced the values. So the list M doesn't "know" that X's +value is later changed. + + + +(define x (list 1 '(2 3) 4)) +(define y (cdr x)) +(set-car! y 5) +x + +(1 5 4) is printed. + + Y + | + | + V +X-->[o|o]-->[o|o]-->[o|/] + | | | + V V V + 1 5 4 + +In this example, Y names the same pair as (cdr x). So changing the car of Y +changes the cadr of X, replacing (2 3) with 5. + + + +(let ((x (list 1 2 3))) + (set-cdr! (cdr x) x) + x) + +(1 2 1 2 1 2 1 2 ... is printed. + + +---------+ + | | + V | +X-->[o|o]-->[o|o] + | | + V V + 1 2 + +This example creates a circular list. + + +Scoring: One point per printed representation; one point per diagram. + + + +2. Local state. + +If we call PREV several times, each of the resulting procedures remembers +its own previous invocation. In OOP terminology, PREV represents a class, and +SLOW-SQUARE is an instance of the class. So OLD-RESULT should be an instance +variable. + +Of the four choices offered, the first is the one in which OLD-RESULT is an +instance variable, because the LET happens once per call to PREV, i.e., once +for each instantiation of the class. + +In the second choice, the LET happens only once, when PREV is defined, so +OLD-RESULT would be a class variable. In the third choice, the LET happens +every time an *instance* (such as SLOW-SQUARE) is called, so it's not a state +variable at all, and SLOW-SQUARE would always return #F. + +In the fourth choice, PREV doesn't take an argument! So that can't be right, +and you don't even have to look at the LET. + +Scoring: 4 points, all or nothing. + + +3. Environment diagram. + +There are four frames (including the global one) and three procedures +in the diagram. + +In the global frame, X is bound to 4, BAZ is bound to procedure P1, +and FOO is bound to procedure P3. + +Frame E1 extends the global environment. In it, X is bound to 30 +and * is bound to procedure P2. + +Frame E2 extends E1. In it, Y is bound to 8. + +Frame E3 extends E1. In it, A is bound to 30, and B is bound to 8. + +Procedure P1 is created in the global environment with parameter X +and body (define ...) (lambda ...) + +Procedure P2 is created in E1 with parameters A and B, and body (+ a b). + +Procedure P3 is created in E1 with paremeter Y and body (* x y). + +--------- + +The first expression just adds the X binding to the global environment. + +The second expression creates P1 and binds BAZ to it in the global +environment. + +The third expression invokes BAZ, so it creates E1 with X bound to 30. +[A common error was to bind X to 13, thinking that * means addition +in the expression (* 3 10). But procedure P2 hasn't even been created +yet when (* 3 10) is evaluated, let alone the fact that this expression +is evaluated in the global environment because it was typed at a Scheme +prompt.] Then it evaluates the body of BAZ in environment E1. This +creates P2, binds * to it in E1, creates P3, and returns P3 as the +value from BAZ. Then FOO is bound to that value, P3, in the global +environment. + +The fourth expression computes (* 2 x) in the global environment, +getting 8, and creates E2 with Y bound to 8. [A common mistake was +to use the value 30, in E1, for X and also use P2 for *, thereby +computing the value 32 for Y.] Then, with E2 as the +current environment, it evaluates the body of FOO, which is (* x y). +Since E2 is the current environment, and it extends E1, the symbol * +represents procedure P2 in this expression. Since this is a +user-defined procedure, not a primitive, this creates E3 with A +bound to 30 (the value of X found in E1) and B bound to 8 (the value +of Y found in E2). Then (+ a b) is evaluated in E3, returning the +value 38, which is the value of the entire expression. + +--------- + +Scoring of common mistakes: + + 3 correct + + 2 correct return value 38, but... + E3 extends E2 + E3 variables are named X and Y instead of A and B + E3 binds A to "X" instead of 30 and B to "Y" + E3 left out altogether + P3 right bubble points to E2 + + 1 X=13 in E1 + Y=32 in E2 + E2 extends global environment + In E1, "(* a b)" is bound to "(+ x y)" + The third expression is interpreted as if it were + (define (foo) (baz (* 3 10))) + thereby making FOO a procedure of no arguments that calls BAZ + + 0 P3's right bubble points to the global frame + E1 extends E2 (very strange sequence of events!) + Y=30, as if it were + (define (baz y) (* x y)) + extra/missing frames or procedures except as noted earlier + several errors + + +4. List mutation. + +The easiest way to do a problem like this is to use a LET in which +you give names to every relevant piece of the list structure. Then, +inside the LET, you can mutate the pairs in any old order without +risk of error: + +(define (make-alist! lst) + (if (null? lst) + 'done + (let ((car1 (car lst)) + (cdr1 (cdr lst)) + (car2 (cadr lst)) + (cdr2 (cddr lst))) + (set-car! lst cdr1) + (set-cdr! lst cdr2) + (set-car! cdr1 car1) + (set-cdr! cdr1 car2) + (make-alist! cdr2))) + lst) + +But that's more work than is really needed. If you're clever about +the order in which you do the mutation, you can get by with only one +temporary variable. There are several such solutions; here's one: + +(define (make-alist! lst) + (if (null? lst) + 'done + (let ((tmp (cddr lst))) + (set-cdr! (cdr lst) (cadr lst)) + (set-car! (cdr lst) (car lst)) + (set-car! lst (cdr lst)) + (set-cdr! lst tmp) + (make-alist! tmp))) + lst) + +Both of these solutions use the original first pair as the top-left pair +of the resulting association list; the original second pair becomes the +bottom-left pair. Several people noticed that you can rearrange the +pairs with no temporary variables at all if you reverse those roles, +so that what used to be the second pair becomes the head of the new +association list. Unfortunately, this isn't quite a correct solution, +because the caller of MAKE-ALIST! probably has some variable that still +has the original first pair as its value, so the caller will think that +that first pair is the new a-list. + +Neither of these solutions uses the value returned by recursive calls. +It's also possible to write a solution that does: + +(define (make-alist! lst) + (if (null? lst) + 'done + (let ((tmp (make-alist! (cddr lst)))) + (set-cdr! (cdr lst) (cadr lst)) + (set-car! (cdr lst) (car lst)) + (set-car! lst (cdr lst)) + (set-cdr! lst tmp))) + lst) + +Note that you must check (NULL? LST) *before* you try to take its +CAR or CDR. + +Scoring of typical solutions: + +4 OK +3 Bad/missing base case; + rearranges by mutation but the order isn't quite right; + leaves second pair on top; + uses return value from recursive call but doesn't return a value. +2 No temporary variable (via LET or helper procedure). +1 Uses CONS (or LIST or APPEND, etc). +0 (set! (car lst) ...) or similar confusions. + +Solutions using CONS scored lower than other errors because the problem +explicitly said not to allocate new pairs. It's important that you +understand the difference between allocating a pair and making a new +pointer to an already-existing pair. Although it's true that the old +pairs would be reclaimed, so the total storage requirement of the program +wouldn't increase with solutions using CONS, sometimes it's important not +to allow a delay for garbage collection. For example, if your program is +creating video animation in real time, a garbage collection might bring +the animation to a halt for a substantial time, perhaps half a second. + + +5. Vectors. + +To solve this problem it's important to understand what it's about. The +result (histogram) vector is separate from the argument (scores) vector; the +two vectors have different sizes; there is no simple correspondence between +one element of the result and one element of the argument. Each element of +the result depends on examining *every* element of the argument. The kind of +higher order function strategy that we often use for lists is not appropriate +in this problem. + +Having passed that hurdle, there is an insight about algorithms that helps +to simplify the solution if you see it: Although each element of the result +depends on every element of the argument, each element of the *argument* +contributes to *only one* element of the result. Therefore, a solution that +works by iterating through the elements of the argument can run in Theta(N) +time, whereas a solution that iterates through the elements of the result +will require Theta(N^2) time, and more complicated code. + +Here is the Theta(N) solution: + +(define (histogram scores) + (define (help result i) + (if (< i 0) + result + (begin (vector-set! result + (vector-ref scores i) + (+ (vector-ref result (vector-ref scores i)) 1)) + (help result (- i 1))))) + (help (make-vector (+ (vector-max scores) 1) 0) + (- (vector-length scores) 1))) + +It's important that the call to MAKE-VECTOR initializes every element of the +histogram vector to zero, because we're going to be adding to those values in +the HELP loop. + +You might find it easier to read this slight variant: + +(define (histogram scores) + (define (help result i) + (if (< i 0) + result + (let ((score (vector-ref scores i))) + (vector-set! result + score + (+ (vector-ref result score) 1)) + (help result (- i 1))))) + (help (make-vector (+ (vector-max scores) 1) 0) + (- (vector-length scores) 1))) + +Here's the Theta(N^2) version: + +(define (histogram scores) + (define (count-score score total j) + (cond ((< j 0) total) + ((= (vector-ref scores j) score) + (count-score score (+ total 1) (- j 1))) + (else + (count-score score total (- j 1))))) + (define (help result i) + (if (< i 0) + result + (begin (vector-set! result + i + (count-score i 0 (- (vector-length scores) 1))) + (help result (- i 1))))) + (help (make-vector (+ (vector-max scores) 1)) + (vector-max scores))) + +And, yes, instead of writing COUNT-SCORE as above, you could use +(VECTOR-LENGTH (VECTOR-FILTER ...)) to find the count of students with a +given score. But that would be pretty inefficient (although only by a +constant factor), because VECTOR-FILTER examines every element of the +argument vector twice, and creates a new vector, which you use only long +enough to count its elements, then throw it away. VECTOR-FILTER makes a good +homework problem, but it's not something you would ever really want to use in +vector-based programming. + +It's possible to use the Theta(N^2) algorithm with only one helper procedure, +instead of two, by having the helper take two index arguments, one for each +vector. But it's really, really hard to get that right, and even if you do, +it's really, really hard for anyone else (or you, next week) to read the +resulting program. + + +The first index in a vector is 0; the last is (- (vector-length vec) 1). +Many people lost a point by trying + (vector-ref vec (vector-length vec)) + +People found many ways to make the problem more complicated than necessary, +such as using + (define (helper i) + ... + (set! i (+ i 1)) + (helper i)...) +instead of + (define (helper i) + ... + (helper (+ i 1))...) +This isn't incorrect, but at this late stage in the semester it shows an iffy +understanding of recursion. + +The only two places you can use DEFINE are at the Scheme prompt or at the +beginning of a procedure body. You can't, for example, say + (cond (some-test + (define ...) + ...) + ...) + + +Scoring: + +7 correct. + +6 off-by-one error in calculating vector length or end test. + +5 in Theta(N) algorithm, doesn't initialize result elements to zero. +5 computes vector correctly but doesn't return it. +5 right logic, but a Scheme language error (e.g., misplaced DEFINE). + +4 (VECTOR-REF RESULT INDEX) instead of + (VECTOR-REF RESULT (VECTOR-REF SCORES INDEX)). + +2 No allocation of new vector (result overwrites argument). + +0 Uses lists, or takes car/cdr of a vector. + +There were other, less common errors; generally "has the idea" got 5, while +"has an idea" got 2. + + +6. Parallelism in real life. + +For this question we got several essays trying to justify solutions other +than the obvious ones. For the most part we didn't accept these -- the +problem did say "the answer which BEST describes..." -- with one exception +noted in part (b) below. + +(a) People at tables can't get food; people waiting for food can't get +tables. This is a potential deadlock, and that was the answer we wanted. +It's true that the deadlock might not happen, because some people at +tables may actually have food and might eventually leave, letting the line +continue moving. It depends partly on whether the restaurant servers +believe you when you say "it's okay to serve me because my friend is already +sitting at a table and saving me a seat." Even if they do, a deadlock can +happen if someone comes in alone (so doesn't have a friend to grab a table) +and when that person gets to the front of the line, all the tables are filled +with friends of people behind him/her in line. + +You may think "it's UNFAIR for people who don't have food yet to hog the +tables" or "it's INEFFICIENT for people to sit at tables when they don't +have food yet." But these are technical terms about parallellism errors, +and the particular situation described in the problem is technically a +deadlock. + +(b) There are several inspectors serving several lines in parallel, but +there's only one metal detector, which acts as a single serializer for +all the inspectors. This is inefficiency (too much serialization). + +Some people argued that the metal detector is best viewed as an actual +resource, not as a serializer, and so this is correct, if unfortunate, +serialization of a shared resource. We accepted that reasoning, so we +also accepted "none of the above" as a correct answer. + +(c) You write while your friend researches. This is correct parallelism, +with two processors carrying out parallelizable tasks. + +Some people argued that the tasks *aren't* correctly parallellizable +because the research has to come before the writing. That idea has some +merit for a short paper, but you wouldn't be writing a short paper as a +team anyway; it'd be an individual assignment. We meant that you were +writing one part of the paper while your friend was researching a different +part of the paper. + +Some people said "unfairness" because you have to do the boring writing +while your friend is off doing the interesting research. One of the +nice things about working in groups is that sometimes you're lucky and +your interests complement those of your friend! But even if you would +feel an unfairness in this arrangement, it's not unfair in the technical +sense -- a parallelism unfairness would be if the librarians always get +books for your friend before they get books for you. + +Scoring: One point each. + + +7. Streams. + +The easiest solution is in two steps: First we make a stream of all possible +strings of {\tt OVER} and {\tt UNDER}, and then we filter out the ones that +don't satisfy the condition of having at least one of each: + +(define foo + (cons-stream '() + (interleave (stream-map (lambda (p) (cons 'over p)) foo) + (stream-map (lambda (p) (cons 'under p)) foo)))) + +(define patterns + (stream-filter (lambda (p) (and (member 'over p) (member 'under p))) + foo)) + +You can't combine these two steps; several people tried this: + +(define patterns ;;; wrong! + (stream-filter (lambda ...) + (cons-stream '() (interleave (stream-map ... patterns) + (stream-map ... patterns))))) + +The trouble is that this process will never get started, because the two calls +to stream-map can only operate on patterns that have previously been +generated, and there won't be any of those until something makes it through +the filter. As a result, the variable PATTERNS hasn't been defined when the +calls to stream-map try to use it. + +Another wrong solution was to try to avoid the need for filtering by "priming +the pump" with initial patterns other than the empty one, like this: + +(define patterns ;;; wrong! + (cons-stream '(over under) + (cons-stream '(under over) + (interleave ...)))) + +This indeed gets started correctly, and generates only legal patterns, +but it doesn't generate all of them. In particular, it won't generate +the example shown in the problem: + + (over over under over under under) + +because this pattern, although legal, doesn't end with OVER UNDER or +UNDER OVER. + +Some people, recognizing the problem with that last solution, tried to +get around it by adding words both front and back. That might possibly +work, but the people who tried it wanted to add words at the end with + (cons p 'over) +which of course doesn't make a valid list. + +Another intriguing method involved the use of random numbers to make +a randomly chosen pattern for each element of the stream. It can be +argued that if the random number generator has perfectly well-distributed +results, this approach will eventually generate any desired pattern. +(And, since the number of already-generated patterns is finite, and +the number of not-yet-generated patterns is infinite, the probability +of duplication of patterns is zero! Alas, this doesn't mean it can't +happen. :-) But we didn't accept these solutions because part of the +idea in an infinte stream is that you have to be able to guarantee that +any particular element is reachable in bounded time. + + +Scoring: We graded this one very leniently: + +3 correct +2 interleave correct, filtering missing or incorrect +1 interleave wrong, but a good try +0 not close diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-2.soln.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-2.soln.txt new file mode 100644 index 0000000..759cb3b --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-2.soln.txt @@ -0,0 +1,484 @@ +CS 61A Solutions to sample midterm 3 #2 + +1. Box and pointer. + +(let ((x (list 1 2 3))) + (set-cdr! (car x) 4) + x) + +prints: *** Error: + set-cdr!: wrong type of argument: 1 + +(CAR X) is 1, not a pair, so it has no cdr to mutate. + + +(let ((x (list 1 2 3))) + (set-cdr! x 4) + x) + +(1 . 4) is printed. + +X-->[o|o]--> 4 + | + V + 1 + +Since we are changing the list's cdr to a non-pair, it becomes a "dotted pair." + + +(let ((x (list 1 2 3))) + (set-car! (cdr x) x) + x) + +(1 (1 (1 (1 (1 ... is printed. + + + +------+ + | | + V | +X-->[o|o]-->[o|o]-->[o|/] + | | + V V + 1 3 + +The list's second element is replaced with the list itself, making a circular +list. 3 is still the third element, but the print procedure never reaches it. + + +(define a ((lambda (z) (cons z z)) (list 'a))) +(set-cdr! (car a) '(b)) +a + +((a b) a b) is printed. + +A-->[o|o] + | | + | | + | | + | | + V V + {o|o}-->[o|/] + | | + V V + a b + +Note that the two arrows downward from the first pair point to the same place! +An arrow to a pair points to the entire pair, not just to its car or its cdr. +(By contrast, an arrow *from* a pair *does* come from one half of the pair, +not from the entire pair.) + +The pair in {braces} is the one whose cdr is changed (from being the empty +list) by the set-cdr! invocation. + + +Scoring: One point per printed representation; one point per diagram. + + + +2. Assignment, state. + +(define (make-player room) + (lambda (message) + (set! room (next-room room message)) + room)) + +That's it! There's no need to check for specific messages such as South, +since next-room will take care of that for you. + +Scoring: + +4 correct +3 sets room correctly but doesn't return it +2 domain and range of make-player and of the lambda correct, but + something's wrong with setting room. +1 room is set, but no lambda +0 even worse + + +3. Environment diagram. + + +First of all, in this problem there are two procedures created: + +P1: parameters X and F, body (IF ...) + +P2: parameter Y, body (+ X Y) + + +There are also four environment frames: + +G: the global frame + +E1: has X bound to 3, F bound to #F + +E2: has X bound to 5, F bound to procedure P2 + +E3: has Y bound to 7 + + +Solutions not satisfying the above generally got no points. + +The hard part is how to hook these up. When FOO is defined, a binding +for FOO is made in the global environment. Also, the global environment +is current when the (outer) LAMBDA expression is evaluated, so FOO is P1 +and P1's right bubble points to G. + +By the way, that first expression could have been written as + + (define (foo x f) ...) + +with exactly the same meaning. + +That's all that happens when the first expression is evaluated. +Procedure P2 and frames E1 through E3 are all created during the +evaluation of the second expression. + +First we call FOO with arguments 3 and #F. This creates frame E1, +which extends G, because G is what P1's right bubble points to. + +Now we evaluate the body of P1 (a/k/a FOO), using E1 as the current +environment. The body is the IF expression. F is false, so we must +evaluate (FOO 5 (LAMBDA ...)). + +To evaluate a procedure call we first evaluate all the subexpressions. +In particular, the inner LAMBDA expression is evaluated at this time, +with E1 as the current environment. Therefore, P2's right bubble +points to E1. + +Once we've evaluated the subexpressions, we create a new frame, E2, +binding FOO's parameters to these new arguments. So in E2 the value +of X is 5, and the value of F is procedure P2. Note that this +binding for F is in E2, but the procedure to which F is bound was +created in E1. That's really important, and many groups missed it. + +What environment does E2 extend? Since we are calling P1 (a/k/a FOO), +we extend the environment in P1's right bubble, namely G. This, too, +is a really important point. If you had E2 extend E1, you are using +dynamic scope, not lexical scope, which is correct for Scheme. + +We now evaluate the body of P1, the IF expression, with E2 current. +The value of F is true in this environment (since anything other than +#F is considered true), so we now evaluate (F 7). + +To do that, we make a frame, E3, in which Y is bound to 7. What environment +does E3 extend? The procedure we're calling, P2, was created in E1, so E3 +must extend E1 -- not E2, even though that's the current environment. + +Since E3 extends E1, the relevant value of X is 3, and so the answer +that Scheme prints is 10, which is 3+7. + +The most common wrong answer was 12, which is 5+7. (Only a handful of +papers had any answer other than 10 or 12.) As it turns out, there were +two ways of getting the answer 12, with different scores: + + * Many groups thought that procedure P2 was created in environment E2, + and so E3 would extend E2 even following the lexical scope rule. + This was a relatively mild error, getting 2 points. + + * Many other groups used dynamic scope, getting 1 point. You were + deemed to be using dynamic scope if E3 extended E2 even though P2's + right bubble pointed to E1. You were also deemed to be using + dynamic scope if E3 extended E2, and E2 extended E1, regardless of + where P2 pointed. + + (A few papers had E2 extending E1, but E3 correctly extending E1, + the diagram otherwise correct, and an answer of 10. These groups + were not deemed to be believers in dynamic scope, but merely + careless, getting 2 points.) + +Several groups got the answer 10 despite incorrect diagrams. This was a +surprise, but it turned out that they did it by mixing the substitution +model with the environment model. (Since the expressions in the problem +did not involve mutation, the substitution model does yield the right +value for (FOO 3 #F) even though it's not what Scheme really does.) +More specifically, these solutions had (+ 3 Y) instead of (+ X Y) as the +body of P2. Such papers got 1 point. + +Some papers had P2's right bubble pointing to E3, a frame that didn't +even exist when P2 was created. We don't understand what those groups +were thinking. + +Another zero-point solution was to have bindings to expressions rather +than to values. For example, some papers had a binding in E2 of the form + + F: (lambda (y) (+ x y)) + +It's really important to understand that Scheme's job is to translate +expressions into values, and that only values get into environments. +(This is what it means to say that Scheme uses applicative order +evaluation, rather than normal order.) + +Scoring: + +3 OK +2 lexical scope, but some error +1 dynamic scope, or substitution model +0 gibberish, extra frames, expressions in environments + + +4. List mutation. + +We were surprised at how hard you found this problem. The solution +we wanted is pretty short and simple: + +(define (merge! a b) + (cond ((null? a) b) + ((null? b) a) + ((<= (car a) (car b)) + (set-cdr! a (merge! (cdr a) b)) + a) + (else + (set-cdr! b (merge! a (cdr b))) + b))) + +This solution DEPENDS CRITICALLY on the fact that merge! RETURNS A VALUE. +Most of you got in trouble by forgetting to return a value. + +The easiest way to think about this problem may be to start by writing +a functional (non-mutating) version: + +(define (merge a b) ; Not a solution to the exam problem! + (cond ((null? a) b) + ((null? b) a) + ((<= (car a) (car b)) + (cons (car a) (merge (cdr a) b))) + (else + (cons (car b) (merge a (cdr b)))))) + +There's a stream version of this procedure in the book, and in any case +you should find it easy to invent this. The mutating version has the +SAME STRUCTURE, but instead of calling CONS it has to mutate an +existing pair, and separately return a value. + +One of the most important ideas you can learn is the mathematical +concept of SYMMETRY. In this case, what that means is that you should +notice that merge! treats its two arguments equivalently; if you +interchanged the order of the arguments you should still get the same +answer. Therefore, your program should be symmetrical as well; anything +you do to A should be done in the same way to B. Many people used +asymmetrical kludges, and therefore had incredibly long programs that +didn't work. + +Another good idea to learn is QUIZMANSHIP. Some time around your +11th or 12th cond clause, you ought to stop and think, "They wouldn't +assign something this complicated on an exam." (This is quite +different from the sort of quizmanship in which you try to guess at +answers based on irrelevant factors.) + +Several solutions had cond clauses with complicated conditions such as + (and (< (car a) (car b)) (> (car a) (cadr b))) +There are a few situations in which you really do have to use this +degree of complexity, but they're rare. Really what this means is +that you're not trusting the recursion to do its job with the second +elements of the lists. + +Several solutions rearranged things in a way that would work only if +the second-smallest number is in the other list from the smallest +number. That is, you hook the two cars together and then recursively +deal with the two cdrs. Think about a case like + (merge! (list 1 2 3) (list 4 5 6)) +In this example the result should be the same as if you'd appended +the lists, not the same as if you interleaved them. + +A few people did append the lists, and then sort them by insertion +sort or bubble sort or some such thing. This can work, and we +gave full credit for working solutions of this kind, but you should +be aware that it makes the problem take O(n^2) time instead of +O(n), and it's more complicated to write correctly, too! By +appending the two lists you're losing the valuable information +that each of them is already ordered. + +In a problem about lists, you have to remember that the car and +the cdr of a pair do NOT play symmetrical roles in the representation +of a list. Each car is an element; each cdr is a sublist. In a +list of numbers, each car is a number; no cdr is a number. Therefore, +any solution that interchanges cars and cdrs or tries to mutate a +car of something just can't be right: + (set-car! (car x) ...) + (set-cdr! (car x) ...) + (set-cdr! x (car y)) + (set-car! x (cdr y)) +For solutions of this sort we subtracted three points from what +the score would otherwise be. + +Grading: +7 correct +6 base case error +5 no return value, but it only matters to the ultimate caller +4 no return value, and so the recursion doesn't work +4 rearranges pairs with set-cdr! but incorrectly +3 +2 uses set-car! to rearrange pairs. (Some set-car! solutions are correct.) +1 +0 allocates pairs (calls CONS, LIST, APPEND, etc.) +0 uses set! to rearrange pairs. (Some uses of set! are okay, but they + never actually help the solution.) + +Then subtract 3 points for the cases mentioned in the previous paragraph. + + +5. Vectors. + +There are many ways to do this, but they all share two essential points: +First, there must be a helper procedure that recursively moves through the +vector, changing one element at a time; second, there must be some way to +remember one element (generally the original last element) of the vector, +either through a LET or through an extra argument to the helper. + +Here's a straightforward solution: + +(define (rotate! v) + + (define (help i) + (if (= i 0) + 'this-value-doesnt-matter + (begin (vector-set! v i (vector-ref v (- i 1))) + (help (- i 1))))) + + (let ((temp (vector-ref v (- (vector-length v) 1)))) + (help (- (vector-length v) 1)) + (vector-set! v 0 temp) + v)) + +The last line (with just the V) is there so that ROTATE! returns the vector, +since the return value from VECTOR-SET! is unspecified. + +The elements of a vector of N elements are numbered from 0 to N-1, not from +1 to N. That's why the expression (- (VECTOR-LENGTH V) 1) is used to find +the index of the rightmost element. + +It's very important that this program starts at the right end and works +down to the left end, so that if we are given (A B C D) to rotate, the +intermediate results are + (a b c d) + (a b c c) + (a b b c) + (a a b c) + (d a b c) +If we started at the left end instead, we'd get + (a b c d) + (a a c d) + (a a a d) + (a a a a) ; maybe stop here, or + (d a a a) ; maybe something like this. +There are other ways to organize the program so that left-to-right operation +does produce the desired result. Here's one that works from left to right, +always swapping the chosen element with the last element: + +(define (rotate! v) + + (define (swap v i j) + (let ((temp (vector-ref v i))) + (vector-set! v i (vector-ref v j)) + (vector-set! v j temp))) + + (define (help i) + (if (< i (vector-length v)) + (begin (swap v i (- (vector-length v) 1)) + (help (+ i 1))))) + + (help 0) + v) + +When we ran across this solution in the grading, it took us some time to +convince ourselves that it really works. Here's a trace of intermediate +results: + (a b c d) + (d b c a) + (d a c b) + (d a b c) + (d a b c) + +The problem told you to mutate the given vector, not create a new one. +That rules out any call to MAKE-VECTOR, either directly or through a +helper procedure such as VECTOR-COPY; it also rules out things like + (list->vector (list-rotate (vector->list v))) + +A few students recognized that they should use a LET to save something, +but instead of saving one element, tried to save the entire vector with +something along the lines of + (let ((new-v v)) ...) +If this did what they intended, it would be ruled out by the problem +statement, but in fact it does *not* make a copy of the vector. It just +makes a new variable that's bound to the same (as in EQ?, not EQUAL?) +vector as the original variable V. + + +Scoring: + +7 correct. + +6 indexing off by one (1 to N instead of 0 to N-1). + vector rotated, but not returned. + +4 one element lost (no LET or equivalent). + new vector allocated, but no VECTOR->LIST or LIST->VECTOR. + no base case in recursive helper. + one value propagated by shifting left-to-right. + +2 LIST->VECTOR etc. + no recursion (just two values swapped). + other messed up reorderings (such as reversal). + +0 Total misunderstanding of vectors, such as (CAR V). + +We did not assign scores 1, 3, or 5. + + +6. Concurrency. + +(a) The only possible value is 10. If the first process runs first, +it sets BAZ to 5, and then the second process sets it back to 10. If the +second process runs first, it sets BAZ to 20, and then the first process +sets it back to 10. + +(b) 5: P1 computes baz/2 = 5, then P2 runs completely, then P1 stores 5. + 10: either correct sequential order + 15: P2 loads BAZ once from memory (getting 10), then P1 runs + completely (setting BAZ to 5), then P2 loads BAZ again + (getting 5), adds 10+5, stores 15. + 20: P2 computes baz+baz = 20, then P1 runs completely, then + P2 stores 20. + + +Scoring: + +3 correct +2 (a) correct, (b) missing one value and no wrong ones added +1 (a) correct or (b) correct +0 neither correct + + +7. Streams. + +(define stream-car car) ; unchanged from the stream-only version + +(define (stream-cdr sl) + (if (procedure? (cdr sl)) ; or PROMISE? + (force (cdr sl)) + (cdr sl) )) + +;;;;;;;; or + +(define (stream-cdr sl) + (if (or (pair? (cdr sl)) (null? (cdr l))) + (cdr sl) + (force (cdr sl)) )) + +Scoring: 1 point for stream-car, 3 for stream-cdr. Part credit in the latter +for any attempt that shows understanding of the need to distinguish the two +cases, especially if it's clear that what needs to be distinguished is the +nature of the cdr rather than of the entire argument. + +Comment: Many of you seem to be upset because you never heard of the +predicate PROCEDURE? and therefore couldn't figure out how to do the +test. I'm unsympathetic to this problem, for several reasons: + + 1. You came across PROCEDURE? in the adventure game project, + where it is used in the version of PERSON? that you rewrote. + + 2. You own a copy of the Scheme reference manual, which has + a perfectly good index. + + 3. If you couldn't think of PROCEDURE? you could have used + PAIR? or ATOM? or LIST? to distinguish the two cases. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-3.soln.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-3.soln.txt new file mode 100644 index 0000000..20db87b --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Midterm3/mt3-3.soln.txt @@ -0,0 +1,459 @@ +CS 61A Solutions to sample midterm 3 #3 + +1. Box and pointer. + +(let ((x (list 1 2 3))) + (set-cdr! (cdr x) (cddr x)) + x) + +(1 2 3) is printed. + +X-->[o|o]-->[o|o]==>[o|/] + | | | + V V V + 1 2 3 + +In this example the SET-CDR! call effectively does nothing, since it +replaces the cdr of (cdr x) with the cddr -- the cdr of the cdr -- of X. +The arrow drawn with = instead of - above is the one that's replaced with +itself. + + +(let ((x (list 1 2 3))) + (set-car! x (cddr x)) + x) + +((3) 2 3) is printed. + + +----------------+ + | | + | V +X-->[o|o]-->[o|o]-->[o|/] + | | + V V + 2 3 + +The set-car! invocation changes (car x), i.e., the first element of X. +It's changed to (cddr x), which is a *sublist*, not just an element, of X. +Thus the new first element is not 3, but (3). + + + +(let ((x (list 1 2 3))) + (set-car! (cdr x) (cdr x)) + x) +(1 ((((((((( ... is printed. + + +-+ + | | + | V +X-->[o|o]-->[o|o]-->[o|/] + | | + V V + 1 3 + +Note that the arrow at the top of the diagram points *from the car* of the +second pair, but points *to the entire pair* (because that's how pointers +always work), not just to the cdr, even though that's where the arrowhead +happens to be. + +There's still a 3 in this list, but it'll never be printed. + + + +(let ((x (list 1 2 3 4))) + (set-cdr! (cddr x) (cadr x)) + x) + +(1 2 3 . 2) is printed. + +X-->[o|o]-->[o|o]-->[o|o]--> 2 + | | | + V V V + 1 2 3 + +In this example we change the cdr of a pair (because we're doing SET-CDR!) to +point to a non-pair, (CADR X), the second element of X, which is 2. Thus the +result is an improper list, so there's a dot in the printed version. + +It doesn't matter, in the diagram, whether you have two 2s, as above, or have +two arrows pointing to the same 2. It *does* matter when the thing being +pointed to is a pair; then there's a big difference between two pointer to the +same pair, and two pairs that have the same values in them. + + +Scoring: One point per printed representation; one point per diagram. + + +2. Local state. + +Does Louis's MEMOIZE give wrong answers? YES. + +Explanation: It has one table shared among all memoized functions, +instead of a separate table per function. + +Example: + +[Louis has defined MEMO-FIB, as shown in the question.] + +> (memo-fib 4) +3 +> (define memo-square (memoize (lambda (x) (* x x)))) +> (memo-square 4) +3 + +Since MEMO-FIB and MEMO-SQUARE share the same table, (memo-square 4) +returns the value previously remembered from (memo-fib 4). + +Some students who checked NO explained why the answer is really YES, so +we figured people misread the question, and went by your explanantion +rather than by which choice you checked. + +Pretty much any explanation with a phrase like "a single table" or +"universal table" or "global table" was accepted. (It's not quite right +to say "a table in the global environment"; the table is actually a local +state variable of MEMOIZE.) + +Explanations that merely restate the form of Louis's change to the program +were not accepted: "The program gives wrong answers because Louis has moved +the LET to outside of the LAMBDA." You had to explain what *effect* that +would have on the program's *behavior*. + +The example didn't necessarily have to take the form of a specific Scheme +interaction as above, but did have to assert that two different functions are +memoized. + +Scoring: + +4 correct +2 correct explanation, no/bad example; + iffy explanation (like "global environment" discussed above) +0 bad explanation (including saying that it doesn't give wrong answers) + +No odd scores were assigned. + + +3. Environment diagram. + +Bindings A=8 and B=9 go in the global environment. + +Then comes the LET, which is equivalent to an invocation of the procedure +generated by an implicit LAMBDA: + + ((lambda (a f) (f 5)) + 3 + (lambda (b) (+ a b))) + +As with any procedure invocation, **first all the subexpressions are +evaluated!** This evaluation takes place in the global environment -- we +haven't invoked any procedures yet. + +Thus, two procedures are created whose right bubbles point to the global +environment. Only then do we invoke the (lambda (a f) ...) procedure, which +creates a frame in which A is bound to 3, and F is bound to the +(lambda (b) ...) procedure. That new frame, of course, extends the global +environment. + +With that frame as (the first frame of) the current environment, we can +evaluate the body of the LET, which is (F 5). We find a binding for F in +the current environment; it's the (lambda (b) ...) procedure. So we can +invoke that with the argument 5. + +Since F's right bubble points to the global environment, that's what we +extend with the new frame that binds B=5. So when we evaluate F's body, +which is (+ A B), we find the bindings A=8 and B=5. + +Thus, the final answer is 13. + + +The overwhelmingly most common mistake was to think that the (lambda (b) ...) +procedure's right bubble points to the A=3 frame, so the B=5 frame points +there also, and the final value is 8. You should know, though, that a LET +binding can't depend on another binding in the same LET; for example, if the +problem had been + + (let ((a 3) + (c (+ a b))) + (+ a c)) + +I hope most people would have known that C would be 8+9, using the global +bindings for both A and B. The fact that the computation using A happens +inside a lambda body doesn't change the fact that the LET's binding for A +isn't available to it. + +A few people drew the environment diagram that would give an answer of 8, +but instead wrote 13 as their final answer, which means either that they +copied someone else's final answer or that they *do* know how Scheme +evaluates expressions, but don't make any connection between that and +the environment model. We graded this as if they'd said 8. + +A couple of people had procedure F's right bubble correctly pointing to the +global environment, but nevertheless had the B=5 frame extending the A=3 +frame, using dynamic scope instead of lexical scope. This gave the same +wrong final answer of 8. + +Scoring: + +6 correct. +3 answer was (or should have been) 8, as discussed above. +0 even worse (too many frames, no arrows at all -- there weren't many). + + +4. List mutation + +(define a (list 'x)) +(define b (list 'x)) +(define c (cons a b)) +(define d (cons a b)) + +(eq? a b) => #F + + Each call to LIST generates new pairs (one new pair, in this case, + because each list has only one element). + +(eq? (car a) (car b)) => #T + + Both CARs are the symbol X, and equal symbols are always EQ. + +(eq? (cdr a) (cdr b)) => #T + + Both CDRs are the empty list, and there's only one empty list. + +(eq? c d) => #F + + Each call to CONS generates a new pair. + +(eq? (cdr c) (cdr d)) => #T + + Both CDRs are the pair named B -- the same pair. + +(define p a) +(set-car! p 'squeegee) +(eq? p a) => #T + + P and A are two names for the same pair. Mutating the pair + doesn't change the variable bindings. + +(define q a) +(set-cdr! a q) +(eq? q a) => #T + + This one looks trickier because the pair now points to itself, + but it's really the same as the previous question: Q and A are + two names for the same pair. + +(define r a) +(set! r 'squeegee) +(eq? r a) => #F + + This time we didn't mutate a pair; we changed the binding of + one of the variables. So R and A now name two different things; + A is still a pair, but R is now a symbol. + +Score: 1/2 point each, rounded down to the nearest whole point. + + +5. Vector programming + +(define (ssort! vec) + (define (help start) + (if (= start (vector-length vec)) + vec + (let ((smallest (subvec-min-start vec start))) + (let ((temp (vector-ref vec smallest))) + (vector-set! vec smallest (vector-ref vec start)) + (vector-set! vec start temp) + (help (+ start 1)))))) + (help 0)) + +The key point to understand is that you need to walk through the vector, +bringing the smallest element out to position 0, then the next-smallest to +position 1, and so on, until you run out of elements. Thus we have a helper +procedure with an argument, START, whose value is the position that we're +up to in the vector; it starts at 0 and is increased by 1 on each recursive +invocation. + +The next important point is that you can't exchange two elements without +using a temporary variable to remember one of them, hence the LET that +creates the variable TEMP. There are two nested LETs because the value of +SMALLEST is needed to find the value of TEMP in this solution; I could have +simplified things a little by remembering the other value in the swap instead: + +(define (ssort! vec) + (define (help start) + (if (= start (vector-length vec)) + vec + (let ((smallest (subvec-min-start vec start)) + (temp (vector-ref vec start))) + (vector-set! vec start (vector-ref vec smallest)) + (vector-set! vec smallest temp) + (help (+ start 1)))))) + (help 0)) + +Scoring: + +6 correct +5 trivial error (e.g. base case off by one) +3 right structure, gets swap wrong +2 serious algorithm confusion +0 allocates new vector, uses lists, or incoherent + + +6. Concurrency + +(define (make-mutex) + (let ((in-use #f) + (s (make-serializer))) + (define (the-mutex m) + (cond ((eq? m 'acquire) + (if ((s (lambda () + (if in-use + #t + (begin (set! in-use #t) + #f))))) + (the-mutex 'acquire))) ; retry + ((eq? m 'release) + (set! in-use #f)))) + the-mutex)) + +The structure of the above is just like that of the MAKE-MUTEX in the book, +except that when an atomic test-and-set operation is needed, it's done by +including the (IF IN-USE ...) and the (SET! IN-USE #T) within the same +serialized procedure, rather than by relying on a TEST-AND-SET! primitive. + +Many people found the problem deeply confusing. You learned that +serialization has three levels of abstraction: the hardware support, +the critical section mechanism (mutex) based on the hardware, and +the more abstract level in which procedures are protected rather than +sequences of instructions. So what does it mean to define a mutex +in terms of a serializer? But actually this could happen. Suppose +you are using a language such as Java, with high-level serialization +built in (and presumably implemented using hardware support), to write +an operating system that is supposed to provide a mutex capability to +its users. You would then write something equivalent to what this +problem asks for. What defines an abstraction is its behavior, not +how it's implemented -- this is the whole idea behind abstraction. + +The SICP version uses (LET ((CELL (LIST FALSE))) ...) because their +TEST-AND-SET! tests and modifies a pair, not a variable, mainly so that +it can be an ordinary procedure rather than a special form. In this +version there's no need to use a pair, although it wouldn't be wrong. + +The ugly (IF ((S (LAMBDA () ...))) ...) is necessary because of the way +serializers work: they take a procedure as argument and return a protected +version of that procedure, which must then actually be invoked. +We didn't take off for minor failures in the notation, accepting even +solutions in which the argument to the serializer was an expression to +be evaluated atomically: (IF (S (IF IN-USE ...)) ...) But we didn't +accept solutions in which the serializer was given data, rather than +activity, as its argument. (More on that below.) + +The reason for the nested IFs is a little subtle; the recursive call +to THE-MUTEX to retry the operation if it fails can't be inside the +serialized procedure, because then it'll block waiting for S, which is +held by this process itself -- in effect, setting up a deadlock within a +single process. But we didn't take off points for missing this subtlety. + +Some people used a single global serializer instead of a separate one +for each mutex. At first we considered this a serious error, because +it means that two mutexes can't be acquired at the same time. But then +we realized that the serializer just protects the acquiring of the mutex, +not the critical section that the mutex itself protects, so any mutex +holds the serializer only for a very short time. So we allowed a global +serializer, except in papers that also missed the point in the previous +paragraph. If a mutex can get into a deadlock with itself, while holding +a serializer needed by all the other mutexes, that's serious enough to +lose a point. + +Some solutions never actually tested whether the mutex was in use before +acquiring it. Presumably those people thought that the serializer would +protect the entire critical section, not just the acquiring, so that if +an acquire operation could get into the serializer the mutex must be free. +But that's not the case; the mutex returns to its caller once it has +set its in-use flag, so the caller's critical section is *not* keeping the +serializer busy. Such solutions got at most one point. + +There were a few common zero-point solutions. The strangest were the +ones that called parallel-execute. The job of a mutex is to protect +critical sections against other processes, not to create other processes. + +Another zero-point solution had expressions such as (S CELL) that showed +a lack of understanding of the key fact that a serializer protects +activities, not data. Similarly, no points for anything that included + + (something . args) ;; pfui + +which indicated mindless copying from the MAKE-SERIALIZER in the book +without understanding. Serializers accept as arguments procedures with +any number of arguments, but any particular use of a serializer isn't +going to be that complicated -- and none of these solutions found any +use for the ARGS variable anyway. + +Scoring: +3 OK +2 at least an atomic test-and-set implementation +1 no test-and-set, but some idea +0 way off + + +7. Streams. + +The answer we expected was + +(define all-integers + (cons-stream 0 (interleave integers + (scale-stream -1 integers)))) + +The stream generated by this expression looks like this: + + 0, 1, -1, 2, -2, 3, -3, 4, -4, ... + +You had to understand two key points to get this solution: + +1. You can't have all the integers in size order. A stream must have +a definite first element! There's no smallest negative integer. Some +people tried to REVERSE the stream of integers; that's meaningless. + +2. You can't APPEND-STREAMS two infinite streams. This is explained +in the handout you got in lecture. Since the first stream will never +finish, it's as if the second stream isn't there at all! (A few people +used MERGE, which works for two sorted, increasing streams, but not +in a case like this where one stream is growing up and one growing down.) + +There were many other correct solutions, most of which essentially +reinvented INTERLEAVE. Special mention for the following beautiful +solution (which the student unfortunately didn't get quite right): + +(define zeros-ones (cons-stream 0 (cons-stream 1 zeros-ones))) + +(define all-integers (subtract-streams zeros-ones + (cons-stream 0 all-integers))) + +where subtract-streams is like add-streams with the obvious difference. +Work this out to convince yourself that it really works! + +Scoring: + +4 correct +3 small mistakes, like leaving out zero +2 append-stream etc. +1 stream of streams, like (cons-stream negatives positives) +0 not a stream at all + +We heard from several students who thought that the stream-of-streams +solution was graded too harshly. Here's the reasoning behind this +grading policy: Most errors come from uncertainty about how to +implement an infinite stream successfully. But this error indicates +a misunderstanding about what the stream abstraction is for! Think +about the example of testing whether a number is prime. We create +a stream containing a range of numbers (range 2 14) and then we use +that as an argument to FILTER: + (filter (lambda (number) (= (remainder 15 number) 0)) + (range 2 14)) + +If RANGE returned a stream of streams, then this FILTER wouldn't +work, because the elements of the stream wouldn't be numbers! So, +even though the problem said "a stream containing all the integers" +instead of "a stream containing all the integers, in which each +element is a single integer," it's unreasonable to think that a +stream whose elements aren't numbers would be acceptable. diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/OOP/belowline.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/OOP/belowline.pdf new file mode 100644 index 0000000..5458cba --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/OOP/belowline.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/OOP/ref-man.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/OOP/ref-man.pdf new file mode 100644 index 0000000..05aec70 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/OOP/ref-man.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Therac-25.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Therac-25.pdf new file mode 100644 index 0000000..cbd6860 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/Therac-25.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/mapreduce-osdi04.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/mapreduce-osdi04.pdf new file mode 100644 index 0000000..fce8825 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/mapreduce-osdi04.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/quick.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/quick.pdf new file mode 100644 index 0000000..b91e5f7 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/quick.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/r5rs.pdf b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/r5rs.pdf new file mode 100644 index 0000000..7cce72d --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/r5rs.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/sicp-errata.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/sicp-errata.txt new file mode 100644 index 0000000..1467159 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/sicp-errata.txt @@ -0,0 +1,56 @@ + + + + + Errata for Structure and Interpretion of Computer Programs 2nd + edition + ________________________________________________________________ + + Positive line numbers count from the top of the page or exercise, + negative line numbers count from the bottom. + + Page 45, line -13: Exponent should be n/2, not b/2 + + Page 112, line 2 of exercise 2.30: Square-LIST should be + square-TREE. ("That is, square-tree should behave as follows:") + + Page 118, lines 1-2: Should say "...the product OF THE SQUARES + of the odd integers..." + + Page 176, before procedures rectangular? and polar?: Should say + "rectangular and polar numbers, respectively" + + Page 181, line -5: Should not refer to exercise 3.24, just to + section 3.3.3. + + Page 185, exercise 2.73a: Should ask about VARIABLE?, not + SAME-VARIABLE? + + Pages 246 and 247, figures 3.7 and 3.8: There is an extra ')' at + the end of the code. + + Page 287, figure 3.28: Rightmost box should have +, not * + + Page 324, exercise 3.50: Should refer to section 2.2.1, not + 2.2.3. + + Page 341, line 3 of exercise 3.66: Should say "For example, + APPROXIMATELY how many pairs..." + + Page 375, line 1 of exercise 4.7: Last LET should be LET* + ("...bindings of the let* variables...") + + Last updated 08/09/99 + + + + + + + + + + + + + 374 diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Volume2/word.txt b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/word.txt new file mode 100644 index 0000000..e47aa23 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Volume2/word.txt @@ -0,0 +1,121 @@ + + WORD AND SENTENCE MANIPULATION PROCEDURES + + The first chapter of the textbook deals exclusively with numeric data. + To allow some variety, with interesting examples that aren't about + calculus, we are going to use some additional Scheme procedures that + manipulate linguistic data: words and sentences. A word can be + considered as a string of characters, such as letters and digits. + (Numbers can be treated as words.) A sentence is a string of words + in parentheses. + + + PROCEDURES TO TAKE APART WORDS AND SENTENCES: + + FIRST returns the first character of a word, or + the first word of a sentence + + BUTFIRST returns all but the first character of a word, + or all but the first word of a sentence + + BF same as BUTFIRST + + LAST returns the last character of a word, or + the last word of a sentence + + BUTLAST returns all but the last character of a word, + or all but the last word of a sentence + + BL same as BUTLAST + + Examples: + + > (first 'hello) + h + + > (butlast '(symbolic data are fun)) + (symbolic data are) + + + PROCEDURES TO COMBINE WORDS AND SENTENCES + + WORD arguments must be words; returns the word with + all the arguments strung together + + SENTENCE returns the sentence with all the arguments + (words or sentences) strung together + + SE same as SENTENCE + + Examples: + + > (word 'now 'here) + nowhere + + > (se 'lisp '(is cool)) + (lisp is cool) + + + + 375 + + + + + + + + + + + PREDICATE PROCEDURES + + EQUAL? returns true if its two arguments are the same word + or the same sentence (a one-word sentence is not + equal to the word inside it) + + MEMBER? returns true if the first argument is a member of + the second; the members of a word are its letters + and the members of a sentence are its words + + EMPTY? returns true if the argument is either the empty + word [which can be represented as "" ] or the + empty sentence [which can be represented as '() ] + + + + MISCELLANEOUS + + COUNT returns the number of letters in the argument word, or + the number of words in the argument sentence. + + ITEM takes two arguments: a positive integer N, and a word or + sentence; returns the Nth letter of the word, or the Nth + word of the sentence (counting from 1). + + + + Examples: + + (define (buzz n) + (cond ((member? 7 n) 'buzz) + ((= (remainder n 7) 0) 'buzz) + (else n) )) + + (define (plural wd) + (if (equal? (last wd) 'y) + (word (bl wd) 'ies) + (word wd 's) )) + + + + + + + + + + + + + 376 diff --git a/js/games/nluqo.github.io/~bh/61a-pages/first-day-handout.pdf b/js/games/nluqo.github.io/~bh/61a-pages/first-day-handout.pdf new file mode 100644 index 0000000..d3e3743 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/first-day-handout.pdf Binary files differdiff --git a/js/games/nluqo.github.io/~bh/61a-pages/style.css b/js/games/nluqo.github.io/~bh/61a-pages/style.css new file mode 100644 index 0000000..34e3304 --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/style.css @@ -0,0 +1,54 @@ +h1 { + text-align:center; +} + +h1.subtitle { + font-size: large; +} + +h3 { + font-family: monospace; + font-size: large; + font-weight: normal; +} + +table { + border-width:0px; + border-collapse:collapse; +} + +td { + padding-left:1em; + padding-right:1em; + padding-bottom:0.3em; +} + +table.staff td { + padding-bottom:1em; + vertical-align:top; +} + +table.weekdays td, table.weekdays th { + border:1px solid #ccc; + text-align:center; + padding:0.5em; +} + +table.weekdays th { + padding:1em; +} + +table th.empty { + border-width:0; +} + +.note { + font-size: normal; + font-style: italic; +} + + +hr { + text-align:center; + width:90%; +} \ No newline at end of file |