Back to Type Challenges

README.Ja

questions/00017-hard-currying-1/README.ja.md

latest2.8 KB
Original Source
<!--info-header-start--><h1>Currying 1 </h1><blockquote><p>by Anthony Fu <a href="https://github.com/antfu" target="_blank">@antfu</a></p></blockquote><p><a href="https://tsch.js.org/17/play/ja" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.md" target="_blank"></a> <a href="./README.zh-CN.md" target="_blank"></a> </p><!--info-header-end-->

この課題ではTypeScript 4.0が推奨されます

カリー化とは、複数の引数を取る関数を、それぞれの 1 つの引数を取る関数の列に変換するテクニックです。

例えば:

ts
const add = (a: number, b: number) => a + b
const three = add(1, 2)

const curriedAdd = Currying(add)
const five = curriedAdd(2)(3)

Currying に渡された関数は複数の引数を持つ場合があり、正しく型を付ける必要があります。

この課題では、カリー化された関数は一度に 1 つの引数しか受け付けません。すべての引数が代入されたら、その結果を返す必要があります。

<!--info-footer-start-->

<a href="../../README.ja.md" target="_blank"></a> <a href="https://tsch.js.org/17/answer/ja" target="_blank"></a> <a href="https://tsch.js.org/17/solutions" target="_blank"></a> <hr><h3>関連する課題</h3><a href="https://github.com/type-challenges/type-challenges/blob/main/questions/00014-easy-first/README.ja.md" target="_blank"></a> <a href="https://github.com/type-challenges/type-challenges/blob/main/questions/00016-medium-pop/README.ja.md" target="_blank"></a> <a href="https://github.com/type-challenges/type-challenges/blob/main/questions/00462-extreme-currying-2/README.md" target="_blank"></a> <!--info-footer-end-->