Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
forループを越えて / beyond for loop
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Shunsuke Watanabe
October 12, 2018
Programming
0
530
forループを越えて / beyond for loop
#SurviveJS05 発表資料
高階関数を活用してコードを読みやすくする話です
Shunsuke Watanabe
October 12, 2018
Tweet
Share
More Decks by Shunsuke Watanabe
See All by Shunsuke Watanabe
いますぐ {id: number;} をやめろ
craftgear
1
320
Reactハンズオン 01 入門編 コード部分抜粋 / React Handson 01 components (excerpt)
craftgear
1
560
Reactハンズオン 02 redux編 コード部分抜粋 / React Handson 02 redux (excerpt)
craftgear
0
550
Reactハンズオン 01 入門編 コード部分抜粋 / React Handson 01 components (excerpt)
craftgear
0
650
Reactで作るDrupalサイト
craftgear
0
460
大阪Node学園 七時限目 「ゼロからはじめるnode.js」
craftgear
1
420
大阪Node学園 六時限目 「generator小咄」
craftgear
1
340
大阪Node学園四時限目 "This crazy testless world"
craftgear
1
340
Other Decks in Programming
See All in Programming
atmaCup #23でAIコーディングを活用した話
ml_bear
4
720
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
12
7.1k
CSC307 Lecture 11
javiergs
PRO
0
580
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
850
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
230
AIに仕事を丸投げしたら、本当に楽になれるのか
dip_tech
PRO
0
170
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
380
AHC061解説
shun_pi
0
280
あなたはユーザーではない #PdENight
kajitack
4
290
SourceGeneratorのマーカー属性問題について
htkym
0
110
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
410
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
3
380
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
A designer walks into a library…
pauljervisheath
210
24k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4k
Paper Plane
katiecoart
PRO
0
47k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Building Applications with DynamoDB
mza
96
6.9k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
190
Transcript
forϧʔϓΛ͑ͯ ลढ़ี ˏcraftgear
ߴ֊ؔͬͯ ͝ଘͰ͔͢ʁ
ߴ֊ؔͱ ͨͱ͑ɺ
ؔΛҾʹऔΔ ؔ $('#button').click( e => { console.log(e); } );
ؔΛΓͱ͠ ͯฦؔ͢ const createCounter = () => { var number
= 0; return () => { number++; return number; }; }
Array.map(fn)
forϧʔϓͰͳ ͯ͘mapϝιο υΛ͏ཧ༝
ίʔυ ͷ ҙਤ
const a = [1,2,3].map(fn)
Γaͷܕ ྻͰɺ ཁૉ̏
ྻͷ֤ཁૉ ʹରͯ͠fnΛ ࣮ߦ͍ͯ͠Δ
ԿΛΓ͍ͨ ͔fnͷதΛ ಡΊΘ͔Δ
Θ͔Γ͍͢ ί ʔ υ ɺॏཁɻ
ϝϯς͕༰қ ฏͳίʔυ ϨϏϡʔ
fnΛΓग़ ͯ͠ςετ
࣭ ্
UIߏங ʹศར
const dummyTodos = [ { id: 1, title: 'aaaa', done:
true }, { id: 2, title: 'aaaa', done: false }, ]; const TodoList = ({ todos }) => ( <div> {todos.map(todo => ( <TodoItem key={todo.id} {...todo} /> ))} </div> );
map͚ͩ ͡Όͳ͍
map(f) filter(f) reduce(f, init) forEach(f) ྻ [n] [n] [n] [n]
Γ [n] [<= n] initͱಉܕ ͳ͠
some(f) every(f) findIndex(f) find(f) ྻ [n] [n] [n] [n] Γ
ਅِ ਅِ ཁૉҰͭ
༻্ͷҙ
filterʹ͢fn͕ฦ͢ ਅِͰ͋Δ͜ͱ -1falseʹͳΒͳ͍
[].some [].every ৗʹtrue ʮۭڏʹਅʯ
ඇಉظॲཧ Promise.all()Ͱ
reduce ΄Ͳ΄Ͳʹ
chainingͱ compositionͰ ֦͕Δੈք
const double = v => v * 2 const over5
= v => v > 5 const a = [1,2,3] .map(double) .filter(over5)
import * as R from 'ramda'; const doubleOver5 = R.compose(
R.filter(over5), R.map(double) );
const b = doubleOver5([2, 3, 4]); const c = doubleOver5(
{a: 1, b: 2, c: 3} );
࣮ԋ
Thank You!