Correct functional implementation on Binomial Heap
问题 I am reading Binomial Heap in Purely Functional Data Structures. The implementation of insTree function confused me quite much. Here are the set of codes datatype Tree = Node of int * Elem.T * Tree list fun link (t1 as Node (r, x1, c1), t2 as Node (_, x2, c2)) = if Elem.leq (x1, x2) then Node (r+1, x1, t2::c1) else Node (r+1, x2, t1::c2) fun rank (Node (r, x, c)) = r fun insTree (t, []) = [t] | insTree (t, ts as t' :: ts') = if rank t < rank t' then t::ts else insTree (link (t, t'), ts') My