| 이전 주제 보기 :: 다음 주제 보기 |
| 글쓴이 |
메시지 |
유.강민
가입: 2011년 3월 22일 올린 글: 38
|
올려짐: 2011년11월11일 1:54 주제: 숙제 6-3,4 테스트셋 생성기입니다. |
|
|
이게 도움이 될지는 모르겠지만 일단 공유해봅니다.
사용법은 _testN 함수에 테스트할 횟수와 생성될 crazy2의 길이를 인자로 주면 각 테스트에 대해 성공여부를 출력해줍니다.
| 코드: |
let _ = Random.self_init()
let rec _testGenerator n =
let rNum = Random.int n in
if rNum = 0 then NIL
else begin
let rNum = Random.int 3 in
if rNum = 2 then ONE (_testGenerator (n-1))
else if rNum = 1 then ZERO (_testGenerator (n-1))
else MONE (_testGenerator (n-1))
end
let _test n =
let a = (_testGenerator n) in
let b = (_testGenerator n) in
((crazy2val (crazy2add (a,b))) =
(crazy2val a) + (crazy2val b))
let _testN n' n =
for a = 0 to n'-1
do (print_string (if (_test n) then "success: #" else "failure: #");
print_int a; print_string "\n") done
| [/code] |
|
| 위로 |
|
 |
김태훈10
가입: 2011년 10월 15일 올린 글: 21
|
올려짐: 2011년11월13일 17:47 주제: |
|
|
| 감사합니다~ |
|
| 위로 |
|
 |
kkhseed
가입: 2011년 9월 27일 올린 글: 21
|
올려짐: 2011년11월13일 19:01 주제: |
|
|
큰 도움이 되었습니다. 감사합니다 _________________ //강기환 |
|
| 위로 |
|
 |
|