A demo of Union/Find algorithm in ATS


#1

Hi,

I was reading a chapter about type inference and constraint solving in ML.
It mentioned a quick Union/Find algorithm for testing equivalent classes. I
translate the code into ATS, and pasted here at glot.io: Union/Find
https://glot.io/snippets/eiaoq3icf1

Just for fun.


Re: A demo of Union/Find algorithm in ATS
#2

I suggest:

fun{} addr_of{a:t@ype} (pt a): ptr

Casting a pointer(64bit) to an integer(32bit) is a bit dangerous.