Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
【Go言語】range
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Tomoki Ota
August 30, 2024
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
【Go言語】range
Tomoki Ota
August 30, 2024
More Decks by Tomoki Ota
See All by Tomoki Ota
アーキテクチャの価値
tomo1227
0
130
アーキテクチャとビジネスロジック
tomo1227
0
130
【Go言語】テスト
tomo1227
0
100
【Go言語】クロージャ
tomo1227
0
350
【Go言語】イテレータ
tomo1227
0
120
【Go言語】エラーハンドリング
tomo1227
0
100
AIに淘汰されないようにするには?
tomo1227
0
110
【Go言語】break
tomo1227
0
110
【Go言語】反復処理
tomo1227
0
88
Other Decks in Programming
See All in Programming
速習iPhone Duo対応
yuukiw00w
1
650
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
350
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
3
360
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
560
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
150
海上で動くGoサーバー: goroutineとchannelでさばく航行データストリーム
atsuki_seo
0
730
Are APIs Still Relevant in the AI Era?
soyuka
0
270
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
150
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
130
一人だけ、Kiroが静止する日
hideg
0
120
What We Talk About When We Talk About XP
m_seki
2
660
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.3k
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
570
KATA
mclloyd
PRO
35
15k
Embracing the Ebb and Flow
colly
88
5.2k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Designing Powerful Visuals for Engaging Learning
tmiket
1
570
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
660
Transcript
Tomoki Ota ʲGoݴޠʳrange
Goʹɺdowhileͳ͘ for͔͠ଘࡏ͠ͳ͍ɻ
rangeͱʁ ͷίϐʔ rangeͷධՁ rangeʹ͓͚ΔϙΠϯλ ΞδΣϯμ 3
rangeͱʁ
rangeͱʁ 5 ༷ʑͳσʔλߏʹରͯ͠ɺ෮ॲཧΛߦ ͏ͷʹศརͳํ๏ ΠϯσοΫεऴྃঢ়ଶΛѻ͏ඞཁ͕ͳ͍
rangeͱʁ 6 range͕͍͔ʹͯ͠ΛׂΓͯΔ͔Λ͍ͬͯͳ͍ͱ όάΛى͜͢ݪҼͱͳΓ͔Ͷͳ͍ʂ
จࣈྻ ྻ ྻͷϙΠϯλ εϥΠε Ϛοϓ ड৴νϟωϧ rangeͰ͑Δσʔλߏ
rangeͷ͍ํ
rangeͷ͍ํ
rangeͷ͍ํ
for _ := range s {} ίϯύΠϧΤϥʔ = Λ͓͏ʂ rangeͷ͍ํ
ͷίϐʔ
ͷίϐʔ 13 [{1100} {1200} {1300}]ʹͳΒͳ͍ʂ
GOͰೖ͞ΕΔͷ શͯίϐʔͰ͋Δ
ͷίϐʔ 15 ߏମΛฦؔ͢ͷ݁ՌΛೖ͢Δͱɺͦͷߏମͷίϐʔ͕ߦΘΕΔ ϙΠϯλΛฦؔ͢ͷ݁ՌΛೖ͢ΔͱɺϝϞϦΞυϨεͷίϐʔ͕ߦΘΕΔ (64bitΞʔΩςΫνϟͰΞυϨε64bitͱͳΔɻ)
ͷίϐʔ 16 εϥΠεͷΠϯσοΫεΛ༻͍ͯཁૉʹΞΫηε͢Δ ैདྷͷfor range ϙΠϯλΛ༻͢Δ
εϥΠεͷΠϯσοΫεΛ༻͍ͯཁૉʹΞΫηε͢Δ ैདྷͷfor 17
εϥΠεͷΠϯσοΫεΛ༻͍ͯཁૉʹΞΫηε͢Δ range 18
ϙΠϯλΛ༻͢Δ 19
ϙΠϯλΛ༻͢Δ 20 εϥΠεܕΛมߋ͢Δඞཁ͕͋Δ͕ɺৗʹՄೳͱݶΒͳ͍ ੑೳΛॏࢹ͢Δ߹ɺϙΠϯλͷεϥΠεΛ෮ॲཧ͢Δ͜ͱ༧ଌՄೳੑʹ͔͚ΔͨΊ CPUʹͱͬͯޮ͕ѱ͘ͳΔՄೳੑ͕͋Δ
rangeͷධՁ
rangeͷධՁ 22 range͕ࣜඞਢ
23 for i, v := range exp rangeͷධՁ
24 rangeͷධՁ
25 rangeͷධՁ
26 rangeͷධՁ rangeΛͬͨ࣌ʹ༩͑ΒΕ͕ͨࣜ ։࢝લʹ1͚ͩධՁ͞ΕΔɻ srange͕͏Ұ࣌มʹίϐʔ͞ΕΔɻ
27 rangeͷධՁ(νϟωϧ) rangechΛධՁͯ͠ɺҰ࣌มʹίϐʔ͠ɺ ͦͷνϟωϧͷཁૉʹରͯ͠ɺ෮ॲཧΛߦ͏ɻ ch = ch2ʹؔΘΒͣɺrangech2Ͱͳ͘ ch1ʹରͯ͠ɺ෮ॲཧΛଓ͚Δɻ ch =
ch2ɺchʹ2ͭͷνϟωϧΛೖ͍ͯ͠ΔͷͰɺ ͜ͷίʔυͷޙͰclose(ch)Λݺͼग़͢ͱɺ1ͭͰͳ͘ɺ 2ͭͷνϟωϧ͕Ϋϩʔζ͞ΕΔɻ
28 rangeͷධՁ(ྻ)
29 rangeͷධՁ(ྻ)
30 ࠷ޙͷཁૉͷ࣮ࡍͷͷදࣔํ๏ ΠϯσοΫεΛ͏ํ๏ ྻͷϙΠϯλΛ͏ํ๏
31 ΠϯσοΫεΛ༻͢Δ
32 ྻͷϙΠϯλΛ༻͢Δ
rangeʹ͓͚ΔϙΠϯλ
rangeʹ͓͚ΔϙΠϯλ 34 ΩϟογϡʹཁૉΛૠೖ͢ΔϩδοΫΛ࣮͍ͯ͠Δ
35 rangeʹ͓͚ΔϙΠϯλ
36 rangeʹ͓͚ΔϙΠϯλ
37 rangeʹ͓͚ΔϙΠϯλ
38 ղܾํ๏1 ϩʔΧϧมΛ༻͢Δํ๏
39 ղܾํ๏2 εϥΠεͷΠϯσοΫεΛͬͯɺ֤ཁૉΛࢀর͢ΔϙΠϯλΛ֨ೲ͢Δํ๏