Skip to content

Instantly share code, notes, and snippets.

@lnicola
Created June 26, 2014 12:07
Show Gist options
  • Save lnicola/13ecb0d75f155c9293fe to your computer and use it in GitHub Desktop.
Save lnicola/13ecb0d75f155c9293fe to your computer and use it in GitHub Desktop.
import Data.List
ev s = map (\x -> (x, elemIndices x s)) $ nub s
unifyAux [] [] substs = Just substs
unifyAux (x:xs) (y:ys) substs = if snd x == snd y then unifyAux xs ys ((fst x, fst y) : substs) else Nothing
unifyAux _ _ _ = Nothing
unify s1 s2 = unifyAux (ev s1) (ev s2) []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment