Advertisement
tinyevil

Untitled

Dec 3rd, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1.  
  2. def find_new_bindings(bindings, e1, e2):
  3. e1 = normalize(bindings, e1)
  4.  
  5. progress = false
  6.  
  7. if e1 is Var:
  8. bindings.add(e1, e2)
  9. return true
  10.  
  11. if (e1 is Apply) and (e2 is Apply):
  12. progress |= find_new_bindings(bindings, e1.head, e2.head)
  13. progress |= find_new_bindings(bindings, e1.arg, e2.arg)
  14. return progress
  15.  
  16. if (e1 is Multiname) and (e2 is Multiname):
  17. if not intersects(e1, e2):
  18. error "doesnt match"
  19.  
  20. return false
  21.  
  22. def normalize(bindings, e):
  23. if e in bindings:
  24. return bindings[e]
  25. return e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement