이종혁
가입: 2010년 9월 6일 올린 글: 11
|
올려짐: 2010년10월28일 19:33 주제: 숙제 5-1 test set입니다 |
|
|
실제 테스트셋은 아니고요 테스트셋 랜덤 제너레이터입니다
(test n m)을 부르면 단어가 n개이고 빈도수의 범위가 1~m인 데이터가 생성됩니다 생성된 데이터는 입력에 직접 넣을 수 있는 form으로 출력이 되고 마지막에 vlencode에 넣어서 실행까지 해줍니다
코드: |
(define (test n m)
(define (f x)
(cond ((< x 10) (string (integer->char (+ 48 x))))
(else (string-append (f (quotient x 10)) (string (integer->char (+ 48 (remainder x 10))))))
)
)
(define (make_list l)
(cond ((eq? l 0) `())
(else (cons (cons (f (+ (- n l) 1)) (+ (random m) 1)) (make_list (- l 1))))
)
)
(define (list_print lst)
(cond ((not (null? lst))
(display " (cons \"")
(display (car (car lst)))
(display "\" ")
(display (cdr (car lst)))
(display ")")
(list_print (cdr lst))
)
)
)
(define word_freq_list (make_list n))
(display "(list")
(list_print word_freq_list)
(display ")")
(newline)
(vlencode word_freq_list)
) |
|
|