HW4 === ------------------------------------------------ To run oaklisp, you can invoke ~bap/bin/oaklisp on a UNM CS Linux machine. ------------------------------------------------ To load a file you must go eg (load "foo.oak") to the Oaklisp prompt. Files must have the .oak extension. ------------------------------------------------ To put a copy on your own machine, fetch http://www.cs.unm.edu/~bap/teach/F2002/CS451/hw/4/oaklisp-runtime-and-docs.tgz or to be minimal just the two files http://www.cs.unm.edu/~bap/teach/F2002/CS451/hw/4/oaklisp-runtime-and-docs/oaklisp http://www.cs.unm.edu/~bap/teach/F2002/CS451/hw/4/oaklisp-runtime-and-docs/oakworld.bin and put "oaklisp" in /usr/local/bin/ and "oakworld.bin" in /usr/lib/oaklisp/, and invoke the "oaklisp" executable directly. Documentation Language manual: http://www.cs.unm.edu/~bap/teach/F2002/CS451/hw/4/oaklisp-runtime-and-docs/lang.pdf Implementation manual for the curious: http://www.cs.unm.edu/~bap/teach/F2002/CS451/hw/4/oaklisp-runtime-and-docs/lim.pdf ------------------------------------------------ Assignment ------------------------------------------------ Define a new "sequence type", ie a subtype of SEQUENCE, which handles the following operations: NTH (SETTER NTH) LENGTH APPEND APPEND! PRINT (any others you feel it really should) It should listen to (FLUID PRINT-LENGTH), which can also be denoted using the syntax #*PRINT-LENGTH, to abbreviate the output if appropriate. It should be a coercable type, and you should define code (ADD-METHOD ((COERCER YOUR-TYPE) (LIST-TYPE) LIS) ...) to let people convert lists to your new sequence representation. So its definition should start something like this: (define new-seq-type (make coercable-type '(ivars you use) (list sequence object))) You should define two sequence types: CHUNK-SEQ This is for warm-up. It is a really simple representation, just a list of "chunks" where each chunk is a simple vector of elements. The entire sequence is all the elements in the chunks, in order. When you convert a list to this, you can make one big chunk. But when you append two of them, just chain the chunks together instead of copying. So this type is very efficient for appending, at least if the two seq's are not very fragmented. and YOUR-FANCY-SEQ This is implemented as either a skip list or a splay tree. Your choice. (Or some other similarly advanced data structure if you prefer. But if so, please document particularly well.) Here is an example showing how CHUNK-SEQ might be tested a bit: http://www.cs.unm.edu/~bap/teach/F2002/CS451/hw/4/chunk-test.oak Be sure your implementation can handle empty sequences, ie zero elements. ---------------------------------------------------------------- CHUNK-SEQ due 8am, Mon Nov 4. FANCY-SEQ (including also CHUNK-SEQ in the same handin) due 3pm Wed Nov 6. Please comment reasonably. Points for readability and conciseness. Hand your code in by running the script ~bap/bin/hw-handin your-cs451-hw.oak on a CS machine. It will generate a time stamp which you should save.