diff options
Diffstat (limited to 'entries/braxtonh/types')
-rw-r--r-- | entries/braxtonh/types/index.ts | 18 | ||||
-rw-r--r-- | entries/braxtonh/types/test.ts | 19 |
2 files changed, 0 insertions, 37 deletions
diff --git a/entries/braxtonh/types/index.ts b/entries/braxtonh/types/index.ts deleted file mode 100644 index 11f4086..0000000 --- a/entries/braxtonh/types/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -type Zero = "😰"; - -type Succ<N> = {prev: N}; - -type Prev<N> = N extends Succ<infer P> ? P : never; - -type Add<A, B> = B extends Zero ? A : Succ<Add<A, Prev<B>>>; - -type _Fib<N, AccumulatorA, AccumulatorB> = - N extends Zero - ? AccumulatorA - : N extends Succ<Zero> - ? AccumulatorB - : _Fib<Prev<N>, AccumulatorB, Add<AccumulatorA, AccumulatorB>>; - -type Fib<N> = _Fib<N, Zero, Succ<Zero>>; - -export type {Zero, Succ, Fib}; diff --git a/entries/braxtonh/types/test.ts b/entries/braxtonh/types/test.ts deleted file mode 100644 index 2ce83e7..0000000 --- a/entries/braxtonh/types/test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import {Zero, Succ, Fib} from "./index"; - -const zero: Zero = "😰"; -const one: Succ<typeof zero> = {prev: zero}; -const two: Succ<typeof one> = {prev: one}; -const three: Succ<typeof two> = {prev: two}; -const four: Succ<typeof three> = {prev: three}; -const five: Succ<typeof four> = {prev: four}; -const six: Succ<typeof five> = {prev: five}; -const seven: Succ<typeof six> = {prev: six}; -const eight: Succ<typeof seven> = {prev: seven}; - -const fibZero: Fib<typeof zero> = zero; -const fibOne: Fib<typeof one> = one; -const fibTwo: Fib<typeof two> = one; -const fibThree: Fib<typeof three> = two; -const fibFour: Fib<typeof four> = three; -const fibFive: Fib<typeof five> = five; -const fibSix: Fib<typeof six> = eight; |