Skip to Content
JavaScriptで学ぶ関数型プログラミング
book

JavaScriptで学ぶ関数型プログラミング

by Michael Fogus, 和田 祐一郎
January 2014
Intermediate to advanced
352 pages
6h 34m
Japanese
O'Reilly Japan, Inc.
Content preview from JavaScriptで学ぶ関数型プログラミング
105
4.2 他の関数を返す関数
 計算を何度行う必要があるかを知っている場合もありますが、いつ終えるべきかと
いう条件だけを知っている場合もあります。
iterateUntil
関数が持つもう一つの利点
は、この計算がフィードフォワード関数であるということです。つまり、渡された関
数の実行結果が次の関数に引数として渡される(フィードされる)ということです。
この強力なテクニックは
8
章のパイプラインで改めて紹介します。しかしここでは
次節に移り、関数を返す関数について話を進めます。
4.2
他の関数を返す関数
 これまで、
makeAdder
p87
)や
complement
p52
)、そして
plucker
p93
)といった、
実行結果として関数を返す関数をいくつか目にしました。お察しの通り、これらはす
べて高階関数です。本節では関数やクロージャを返す(そして関数やクロージャを引
数にとることもある)高階関数についてより深く説明します。最初に、前節で定義し
repeatedly
関数を実行した例を思い出してください。引数を無視して決まった値
を返す関数を使っていました。
repeatedly(3, function() { return "Odelay!"; });
//=> ["Odelay!", "Odelay!", "Odelay!"]
 定数を返す関数はとても便利です。関数型プログラミングにおけるデザインパター
ンであると言っても差し支えありません。このような関数はよくシンプルに「
k
」と
呼ばれますが、ここでは分かりやすくするために ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

プログラミングRust

プログラミングRust

Jim Blandy, Jason Orendorff, 中田 秀基
ユーザーストーリーマッピング

ユーザーストーリーマッピング

Jeff Patton, 川口 恭伸, 長尾 高弘
データ分析によるネットワークセキュリティ

データ分析によるネットワークセキュリティ

Michael Collins, 中田 秀基, 木下 哲也

Publisher Resources

ISBN: 9784873116600Other