이태영
가입: 2011년 9월 19일 올린 글: 34
|
올려짐: 2011년10월28일 2:58 주제: 작년 게시판의 과제 5-1번 test set generator입니다. |
|
|
작년 게시판 질문들을 검색하다가 발견했습니다. (test n m)에 n, m값을 넣어서 입력하면 1부터 n까지의 자연수로 이루어진 n개의 "단어"와, 각 단어마다 1부터 m까지의 랜덤한 빈도수를 가지는 단어*빈도수 쌍의 리스트를 만들어 구현된 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)
)
|  |
|