Skip to content

Latest commit

 

History

History
59 lines (39 loc) · 1 KB

tpl.readme.md

File metadata and controls

59 lines (39 loc) · 1 KB

About

Assorted digital logic gates and ops for boolean values to compose complex logic in a more functional manner, e.g. for DSL or simulation purposes. Truth tables and references are provided in the doc strings of each function.

Also see @thi.ng/binary for binary versions of most of the ops provided by this package.

{{meta.status}}

{{repo.supportPackages}}

{{repo.relatedPackages}}

{{meta.blogPosts}}

Installation

{{pkg.install}}

{{pkg.size}}

Dependencies

{{pkg.deps}}

{{repo.examples}}

API

{{pkg.docs}}

import { nand } from "@thi.ng/dlogic";

// XOR construction only using NAND gates
const xor = (a: boolean, b: boolean) => {
    const ab = nand(a,b);
    return nand(nand(a, ab), nand(b, ab));
};

xor(false, false)
// false
xor(false, true)
// true
xor(true, false)
// true
xor(true, true)
// false