Commit 672d786a authored by Giuseppe Castagna's avatar Giuseppe Castagna
Browse files

Merge branch 'master' of gitlab.math.univ-paris-diderot.fr:beppe/occurrence-typing

parents 954b5363 b37a18b5
<html>
<head>
<title></title>
<script type="text/javascript" src="examples.js"></script>
</head>
<body>
</body>
</html>
"use strict";
var ENil;
(function (ENil) {
ENil[ENil["NIL"] = 0] = "NIL";
})(ENil || (ENil = {}));
;
function isEmpty3(x) {
if (x.kind == 1) {
return true;
}
else if (x.kind == 2 && x.children == ENil.NIL) {
return true;
}
else if (x.kind == 2) {
return false;
}
else {
return x.isEmpty();
}
}
isEmpty3({ kind: 2, children: ENil.NIL });
function foo() {
if (Math.random() < .5) {
return ENil.NIL;
}
else {
return { node: { kind: 1 }, next: ENil.NIL };
}
}
isEmpty3({ kind: 2, children: foo() });
function or_(x, y) {
return x || y;
}
var nn = or_(false, false);
function not_(x) {
return !x;
}
function and_(x, y) {
return x || y;
}
;
var l = and_(false, true);
console.log(l);
/** install the tsc compiler (through a package or with npm) and
transpile to js with tsc --strict examples.ts
then open the file examples.html in chrome or firefox and open the
JS console to test the functions
**/
enum ENil { NIL };
type EList = ENil | { node : ENode; next : EList };
......@@ -41,3 +46,28 @@ function foo ():EList {
isEmpty3({ kind : 2, children : foo() });
function or_ (x : true, y : boolean ) : true ;
function or_ (x : false, y : true) : true;
function or_ (x : false, y : false) : false;
function or_ (x : boolean, y : boolean) : boolean {
return x || y;
}
let nn : false = or_(false, false);
function not_ (x : true) : false;
function not_ (x : false) : true;
function not_ (x : boolean) : boolean {
return !x;
}
function and_ (x : false, y : boolean ) : false ;
function and_ (x : true, y : true) : true;
function and_ (x : true, y : false) : false;
function and_ (x : boolean, y : boolean) : boolean {
return x || y;
};
let l : false = and_(false, true);
console.log(l);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment