123456789101112131415161718192021222324 |
- #!/usr/bin/env scheme-r7rs
- ; This is a library for plotting a function with text
- (define (plot f y-min y-max x-min x-max text-height text-width)
- (define delta-x (/ (- x-max x-min) text-width))
- (define delta-y (/ (- y-max y-min) text-height))
- (let row-loop ((row 0)
- (y y-max))
- (if (< row text-height)
- (let col-loop ((col 0)
- (x x-min))
- (if (< col text-width)
- (begin
- (if (< y (f x))
- (display "*")
- (display " "))
- (col-loop (+ col 1)
- (+ x delta-x)))
- (begin
- (newline)
- (row-loop (+ row 1)
- (- y delta-y))))))))
|