Back to Type Challenges

README.Ja

questions/35191-medium-trace/README.ja.md

latest1.5 KB
Original Source
<!--info-header-start--><h1>Trace </h1><blockquote><p>by csharpython <a href="https://github.com/csharpython" target="_blank">@csharpython</a></p></blockquote><p><a href="https://tsch.js.org/35191/play/ja" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.md" target="_blank"></a> </p><!--info-header-end-->

行列において、トレースは主対角成分の総和です。 それを型システムを使って求めたいです。 しかし、型で数を足すのは難しいため、代わりに主対角成分のユニオン型を求めてください。

例:

ts
type Arr = [
  [1,2],
  [3,4]
]
type Test = Trace<Arr> // expected to be 1 | 4
<!--info-footer-start-->

<a href="../../README.ja.md" target="_blank"></a> <a href="https://tsch.js.org/35191/answer/ja" target="_blank"></a> <a href="https://tsch.js.org/35191/solutions" target="_blank"></a> <!--info-footer-end-->