From 77ffde450e92ffe6527c35ffc2383b17d4c04f68 Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Sun, 23 Oct 2022 12:27:49 -0700 Subject: Rename directory to use GitHub ID --- entries/braxtonhall/types/index.ts | 18 ++++++++++++++++++ entries/braxtonhall/types/test.ts | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 entries/braxtonhall/types/index.ts create mode 100644 entries/braxtonhall/types/test.ts (limited to 'entries/braxtonhall/types') diff --git a/entries/braxtonhall/types/index.ts b/entries/braxtonhall/types/index.ts new file mode 100644 index 0000000..11f4086 --- /dev/null +++ b/entries/braxtonhall/types/index.ts @@ -0,0 +1,18 @@ +type Zero = "😰"; + +type Succ = {prev: N}; + +type Prev = N extends Succ ? P : never; + +type Add = B extends Zero ? A : Succ>>; + +type _Fib = + N extends Zero + ? AccumulatorA + : N extends Succ + ? AccumulatorB + : _Fib, AccumulatorB, Add>; + +type Fib = _Fib>; + +export type {Zero, Succ, Fib}; diff --git a/entries/braxtonhall/types/test.ts b/entries/braxtonhall/types/test.ts new file mode 100644 index 0000000..2ce83e7 --- /dev/null +++ b/entries/braxtonhall/types/test.ts @@ -0,0 +1,19 @@ +import {Zero, Succ, Fib} from "./index"; + +const zero: Zero = "😰"; +const one: Succ = {prev: zero}; +const two: Succ = {prev: one}; +const three: Succ = {prev: two}; +const four: Succ = {prev: three}; +const five: Succ = {prev: four}; +const six: Succ = {prev: five}; +const seven: Succ = {prev: six}; +const eight: Succ = {prev: seven}; + +const fibZero: Fib = zero; +const fibOne: Fib = one; +const fibTwo: Fib = one; +const fibThree: Fib = two; +const fibFour: Fib = three; +const fibFive: Fib = five; +const fibSix: Fib = eight; -- cgit v1.2.3-70-g09d2