

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An assignment for creating a symbol table class in lisp. The assignment involves designing and implementing the class, including functions for adding and accessing elements. The provided code demonstrates the usage of these functions.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Due Thursday, October 30, 2003^1
(a) add (symboltable name category type value) - returns a symbol table with the name, category, type, and value fields added; if name is already in the symbol table, returns nil (b) entry (symboltable name) - returns the category, type and value associated with name; if name is not in the symbol table, returns nil (c) category (symboltable name) - returns the category associated with name; if name is not in the symbol table, returns nil (d) type (symboltable name) - returns the type associated with name; if name is not in the symbol table, returns nil (e) value (symboltable name) - returns the value associated with name; if name is not in the symbol table, returns nil
Test your class using the following sequence of calls.
(setq test2st (add nil ’h ’var ’int 0)) (setq areast (add nil ’x ’var ’int 0)) (setq areast (add areast ’y ’var ’int 1)) (setq areast (add areast ’z ’var ’int 2)) (setq test2st (add test2st ’area ’method ’int (list ’(x y) areast ’(: (= z (* 2 (+ (+ (* x y) (* x h)) (* y h)))) (return z))))) (setq mainst (add nil ’a ’var ’int 0)) (setq mainst (add mainst ’b ’var ’int 1)) (setq mainst (add mainst ’s ’var ’int 2)) (setq test2st (add test2st ’Main ’method ’void (list ’() mainst ’(: (: (: (: (= a 3) (= b 4)) (= h 5)) (= s (apply area (@ a b)))) (print s))))) (setq st (add nil ’Test2 ’class ’Test2 test2st)) (entry test2st ’h) (entry test2st ’area) (entry mainst ’b) (entry st ’Main) (category areast ’y) (category mainst ’y) (type st ’Test2) (type st ’class) (value mainst ’s) (value areast ’area)
(^1) No penalty will be assessed for turning this assignment in on Tuesday, November 4, but no assignments will be accepted later than that.
input n; i := 1; while (i <= n) loop i := i + 1; end loop; output i;
Assuming that the input file contains the integers 3 and 4 (i.e., the list <3, 4>), use the denotational semantics of Core to trace the interpretation of the program.