Skip to content

Instantly share code, notes, and snippets.

@hades2510
Created November 3, 2022 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hades2510/f8f567dfc86bc025a34c887cca4e0133 to your computer and use it in GitHub Desktop.
Save hades2510/f8f567dfc86bc025a34c887cca4e0133 to your computer and use it in GitHub Desktop.
type PartialByteXOR<LHS extends Bit[], RHS extends Bit[]> = LHS extends [
infer LHSU extends Bit,
...infer LHSR extends Bit[]
]
? RHS extends [infer RHSU extends Bit, ...infer RHSR extends Bit[]]
? [BitXor<LHSU, RHSU>, ...PartialByteXOR<LHSR, RHSR>]
: []
: [];
type ByteXOR<LHS extends Byte, RHS extends Byte> = LHS extends [
infer LHSU extends Bit,
...infer LHSR extends Bit[]
]
? RHS extends [infer RHSU extends Bit, ...infer RHSR extends Bit[]]
? [BitXor<LHSU, RHSU>, ...PartialByteXOR<LHSR, RHSR>]
: []
: [];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment