Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://rawgithub.com/freethenation/unify.js/master/lib/unify.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  
</body>
</html>
 
//var unify = require('unify');
var variable = unify.variable;
var isNum = function(o){return typeof(o) == "number";};
var expr1 = unify.box([variable("X", isNum),1]);
var expr2 = unify.box(["string",1]);
var expr3 = unify.box([1,1]);
if (expr1.unify(expr2)) {
  console.log("Unification successful! X=" + expr1.get("X").toString());
}
else {
  console.log("Unification unsuccessful!");
}
if (expr1.unify(expr3)) {
  console.log("Unification successful! X=" + expr1.get("X").toString());
}
else {
  console.log("Unification unsuccessful!");
}
//The following should be written to the console
//Unification unsuccessful!
//Unification successful! X=1
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers