박제상
가입: 2018년 9월 18일 올린 글: 12
|
올려짐: 2018년9월21일 1:02 주제: 함수 타입 질문입니다. |
|
|
문제 2-3번에서
exception EmptyHeap
let rank h = match h with
| EMPTY -> -1
| NODE(r,_,_,_) -> r
let shake (x,lh,rh) =
if (rank lh) >= (rank rh)
then NODE(rank rh+1, x, lh, rh)
else NODE(rank lh+1, x, rh, lh)
let findMin h = match h with
| EMPTY -> raise EmptyHeap
| NODE(_,x,_,_) -> x
let insert(x,h) = merge(h, NODE(0,x,EMPTY,EMPTY))
let deleteMin h = match h with
| EMPTY -> raise EmptyHeap
| NODE(_,x,lh,rh) -> merge (lh,rh)
라고 되어있는데 코드 상에
fun insert (x, h) = ...
and deleteMin EMPTY = ...
and merge = ...
and insert = ...
형태로 코딩해도 되나요? interpreter에 함수 타입 검사를 하면 잘 나오긴 합니다.
감사합니다. |
|