Brian Alliet Programming Language Theory syntax.scm: A few syntax-rules that aid in writing other syntax-rules match.scm: A simple syntax-rules based pattern matching facility prelude.scm: A bunch of handy functions (many based on functions in the Haskell Prelude) hw7-parta.scm: Language 3.5 with functions as denoted values. hw7-partb.scm: Language 3.7 with begin and arrays. You need all 4 files loaded to run the two languages (and the eopl libraries) > ,load syntax.scm > ,load match.scm > ,load prelude.scm > ,load hw7-parta.scm or hw7-partb.scm hw7-partb.scm implements array using "native procedures". Native procedures are expressions in the target language that are actually real scheme procedures. When a native procedure is called the scheme procedure is called with whatever arguments were passed. This simplifies the implementation because new primitives don't have to be added or the grammar modified. The "array" procedure takes 1 argument, the length of an array to create. "get" takes 2 arguments. the array and an index. "put" takes 3, the array, index, and value. "length" takes 1, the array. Here is fill and sum in the new language: letrec sum (a,p) = if zero?(-((length a),p)) then 0 else +((get a p),(sum a +(p,1))) fill (a,n,p) = if zero?(-((length a),p)) then a else begin (put a p n); (fill a +(n,1) +(p,1)) end in (sum (fill (array 10) 100 0) 0) The array can be an argument to these functions because it is an expressed value like anything else. I didn't implement arrays as denoted values. I wasn't sure how fill and sum could possibly take an array as an argument when arrays aren't expressed values. I suppose one possible way would be something like: letarray 5 begin (put,0,10); (get,0) end where letarray would create an array on the stack and get and put could only access the highest level array. I didn't get a chance to implement that though. -Brian