Append Example
First, remove all of the write functions from filter-code.ss.
Then create the module append-capture.ss:
#lang scheme
(provide append |hello counter| |int hello counter| |inc hello counter|)
(define |hello counter| 0)
(define (|int hello counter|)
(set! |hello counter| 0))
(define (|inc hello counter|)
(set! |hello counter|
(add1 |hello counter|)))
(define (append x y)
(begin (set! |hello counter| (add1 |hello counter|))
(cond
[(empty? x) y]
[else (cons (first x) (append (rest x) y))])))
Then in the options.ss file, you will need to include this module when you load the code:
(language scheme)
(loadcode assignfile.filt.ss)
(modules "append-capture.ss")
Now any test run with these options will increment the counter by n+1 every time append is called with a list of length n as its first argument.
--
SteveT - 22 Apr 2009
Topic revision: r1 - 2009-04-21
- SteveT