Skip to content

Instantly share code, notes, and snippets.

View ogzhanolguncu's full-sized avatar
🎯
Focusing

Oğuzhan Olguncu ogzhanolguncu

🎯
Focusing
View GitHub Profile
@ogzhanolguncu
ogzhanolguncu / type-level-alu.ts
Created October 26, 2023 07:45
ALU(Arithmetic Logic Unit) written in type-level Typescript
export type Expect<T extends true> = T;
export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <
T
>() => T extends Y ? 1 : 2
? true
: false;
type NotGate<T extends number> = T extends 1 ? 0 : 1;
type AndGate<T extends number, K extends number> = [T, K] extends [1, 1]
? 1