0
기본적으로 노드와 2 개의 하위 힙에서 힙을 만드는 기능이 필요합니다. 힙 표현은SML 값 제한 - 힙
datatype 'a heap = Empty | Heap of int * 'a * 'a heap * 'a heap
합니다 (단점에서 INT는 노드의 순위를 나타냅니다) 다음과 내 기능입니다 : 내가 makeHeap를 호출 할 때
fun makeHeap x h1 h2 = Heap ((rank h1)+1, x, h1, h2)
프로그램의 comipiles하지만, 내가 얻을 대신 힙의 이상한 값 : 당신은 카레 형태로 makeHeap
를 정의하지만, tupled 인수를 호출 한
makeHeap(#"c", Empty, Empty);
stdIn:72.1-72.29 Warning: type vars not generalized because of
value restriction are instantiated to dummy types (X1,X2,...)
val it = fn
: (char * ?.X1 heap * ?.X2 heap) heap
-> (char * ?.X1 heap * ?.X2 heap) heap
-> (char * ?.X1 heap * ?.X2 heap) heap