Skip to content

grancalavera/nat-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Natural Numbers Toy

From zero to infinity and beyond.

Read the code:

console.log(toString(zero));
console.log(toString(one));
console.log(toString(two));
console.log(toString(three));
console.log(toString(four));
console.log(toString(five));

const plusFive = (x: Nat) => plus(five, x);
console.log(toString(plusFive(one)));
console.log(toString(plusFive(two)));
console.log(toString(plusFive(three)));
console.log(toString(plusFive(four)));
console.log(toString(plusFive(five)));

Run the app:

Zero
Succ ( Zero )
Succ ( Succ ( Zero ) )
Succ ( Succ ( Succ ( Zero ) ) )
Succ ( Succ ( Succ ( Succ ( Zero ) ) ) )
Succ ( Succ ( Succ ( Succ ( Succ ( Zero ) ) ) ) )
Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Zero ) ) ) ) ) )
Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Zero ) ) ) ) ) ) )
Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Zero ) ) ) ) ) ) ) )
Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Zero ) ) ) ) ) ) ) ) )
Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Succ ( Zero ) ) ) ) ) ) ) ) ) )

Compare with the haskell version

Releases

No releases published

Packages

No packages published