Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 1.43 KB

File metadata and controls

19 lines (13 loc) · 1.43 KB

Trace medium

by csharpython @csharpython

Take the Challenge    日本語

The trace of a square matrix is the sum of the elements on its main diagonal. However, it's difficult to calculate the sum with type system. To make things simple, let's return the elements on the main diagonal with union type.

For example:

type Arr = [
  [1,2],
  [3,4]
]
type Test = Trace<Arr> // expected to be 1 | 4

Back Share your Solutions Check out Solutions