#lang scheme
;; Jesse McGinnis
;; Assignment 9, Q1
;; compress.ss
;; global hash table
(define ht (make-hash))
;; compress : # ->
;; reads from input, and displays the compressed version
(define (compress)
(define (my-compress val)
(define next (peek-char))
(cond
[(eof-object? next) (void)]
[(char-whitespace? next) (display next) (read-char) (my-compress val)]
[else
(local [(define word (read))]
(cond
[(hash-ref ht word false) (display (hash-ref ht word false)) (my-compress val)]
[else (display word) (hash-set! ht word val) (my-compress (add1 val))]))]))
(my-compress 0))