Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GoのIteratorに詳しくなってしまう

Shuya Inada
September 03, 2024

 GoのIteratorに詳しくなってしまう

Shuya Inada

September 03, 2024
Tweet

More Decks by Shuya Inada

Other Decks in Programming

Transcript

  1. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. Go ͷ iterator ʹ
 ৄ͘͠ͳͬͯ͠·͏ Go1.23 ϦϦʔεʹ͍ͭͯ @inatonix / Ҵా म໵
  2. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ͜ͷൃදΛ௨ͯ͡ 1.iteratorΛͲͷΑ͏ʹॻ͚͹͍͍͔งғؾ͕෼ ͔ͬͯɺ໌೔͔Βॻ͘ΠςϨʔγϣϯॲཧΛ iteratorʹͨ͘͠ͳΔ 1.range over funcͷத਎ʹ͍ͭͯงғؾ͕Θ ͔ͬͯɺGoͷ಺෦࣮૷ʹײँͰ͖Δ 2
  3. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ࣗݾ঺հ 3 @inatonix / Ҵాम໵ גࣜձࣾGROWTH VERSE VPoT ಘҙ෼໺͸GoͱAI ௚ۙ4࿈ଓ golang.tokyo ։࠵ͯ͠·͢
  4. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ΞδΣϯμ 4 1. ࠓճͷΞοϓσʔτʹ͍ͭͯ 1. iteratorΛͲͷΑ͏ʹ࣮૷͢Δ͔ 1. iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔
  5. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ࠓճͷΞοϓσʔτʹ͍ͭͯ 5 ͷΑ͏ʹͯ͠ɺrangeͷޙʹؔ਺Λஔ͚ΔΑ͏ʹ ͳͬͨʢrange over funcʣ
  6. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ࠓճͷΞοϓσʔτʹ͍ͭͯ 6 rangeͷޙʹ͓͚Δfunction͸ɺiteratorͱݺͿ 1. ஋Λฦ͞ͳ͍ 2. 1͚ͭͩฦ͢ 3. 2ͭฦ͢ ※ K, Vͷܕ͸೚ҙ iteratorͱͯ͠ஔ͘͜ͱͷͰ͖Δؔ਺
  7. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ࠓճͷΞοϓσʔτʹ͍ͭͯ 7 ԿΛૂͬͨΞοϓσʔτ͔ 1. genericsͱ૬ੑͷྑ͍ΠςϨʔγϣϯͷ࡞੒ 1. ͋ΒΏΔσʔλߏ଄ͷΠςϨʔγϣϯͷඪ४Խ ϓϩϙʔβϧ͸ͪ͜Β https://github.com/golang/go/issues/61405
  8. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 8 ࠓճͷΞοϓσʔτʹ͍ͭͯ iteratorʹ͍ͭͯ͸ɺgenericsొ৔౰͔࣌Βٞ࿦ʹ্͕͍ͬͯ·ͨ͠ https://github.com/golang/go/discussions/47203 എܠͷྺ࢙ʹؔͯ͠ࢀߟɿtenntenn͞ΜͷεϥΠυ https://docs.google.com/presentation/d/1oY8pIpcB9t0C7siyQvj-ha5PLHTP_pdD-LA9uL2CaTU/ edit#slide=id.g2e2dd6da94f_0_184
  9. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 9 ࠓճͷΞοϓσʔτʹ͍ͭͯ ʮordered mapͱ͔͕ΑΓѻ͍΍͘͢ͳΔͬͯͲ͏͍͏͜ͱ..?ʯ ͜ͷΑ͏ͳiter.Seq2Λฦؔ͢਺ʹ ͢ΔͱɺAll()Λfor rangeͷޙʹஔ ͚ΔΑ͏ʹͳΓɺ ࣗલͷߏ଄ମ΋ɺslice΍mapͱಉ ༷ʹͯ͠ΠςϨʔγϣϯ͢Δ͜ͱ ͕Ͱ͖ΔΑ͏ʹͳ͍ͬͯΔɻ https://github.com/rsc/omap/blob/ 40dad5c0c0fb2f7b45318fa732252 edfd450083b/omap.go ※ίʔυத਎ͷৄࡉͳղઆ͸ޙ΄Ͳ
  10. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. iteratorΛͲͷΑ͏ʹ࣮૷͢Δ͔ 10 Ҿ਺1ͭͷܗࣜ yieldʢҾ਺ʹ͍ͯ͠Δͷؔ਺ʣΛݺͿͨͼʹ for .. range ͷม਺ͱͯ͠ల։͞Ε͍ͯ͘ ΋ͪΖΜyieldͱ͍͏ؔ਺໊͸ԿͰ΋OK
  11. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 11 panic!! forจͷதͰbreak͕ೖΔͱ.. iteratorΛͲͷΑ͏ʹ࣮૷͢Δ͔ forϧʔϓʹ੍ޚߏจ͕͋Δ৔߹
  12. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 12 ΠςϨʔγϣϯͷऴྃΛද͢bool iteratorΛͲͷΑ͏ʹ࣮૷͢Δ͔
  13. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 13 ΠςϨʔγϣϯͷऴྃΛද͢bool yieldͷฦΓ஋͸ΠςϨʔγϣϯऴ ྃΛ൑ఆͯ͘͠Ε͍ͯΔbool ͦΕΛiteratorଆͰ্ख͘ϋϯυϦ ϯάͯ͋͛͠Δඞཁ͕͋Δ ͜ΕͰpanicճආ iteratorΛͲͷΑ͏ʹ࣮૷͢Δ͔
  14. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 14 ͖ͬ͞ͷomap iteratorΛͲͷΑ͏ʹ࣮૷͢Δ͔
  15. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 15 ʮiter.SeqXܕͷ஋Λฦͤ͹ɺrange͕ΠςϨʔγϣϯͯ͠ ͘ΕΔ͜ͱ͸Θ͔ͬͨʯ ʮGo͸಺෦తʹiteratorΛͲΜͳܗʹม׵͍ͯ͠ΔͷͩΖ ͏ʁiterator͸ɺखͰॻ͍ͨϧʔϓͱಉ༷ͷύϑΥʔϚϯε ʹͳΔͷͩΖ͏͔ʁʯ → ཧ࿦্͸YES ͲͷΑ͏ʹม׵͞Ε͍͔ͯ͘ॱΛ௥ͬͯઆ໌ ࣍ͷ࿩୊
  16. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 16 sliceͷBackwardؔ਺Λϕʔεʹઆ໌ ͜ͷؔ਺͸ɺsliceΛٯॱͰऔΓग़ͤΔiteratorΛ࡞Δ iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔ https://go.dev/wiki/RangefuncExperiment
  17. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 17 iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔
  18. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 18 एׯ෼͔ΓͮΒ͍Ͱ͕͢ɺॻ͖Լ͢ͱ͜Μͳײ͡ iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔
  19. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 19 ΠϯϥΠϯల։ iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔
  20. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 20 iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔ ʮΠϯϥΠϯల։ʯʁ ؔ਺ݺͼग़͠ͷίʔυΛݺͼग़͠ݩʹల։͢Δ͜ͱͰɺؔ਺ݺͼग़͠ͷ ΦʔόϔουΛ࡟ݮ͠ߴ଎Խ͢ΔίϯύΠϥͷख๏
  21. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 21 ͞ΒʹΠϯϥΠϯల։ iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔
  22. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 22 ୤Ծ૝Խ iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔
  23. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 23 ͞ΒʹΠϯϥΠϯల։ iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔
  24. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 24 ෆཁͳม਺ͳͲΛഉআ(SSAతͳ؍఺͔Βʣ https://zenn.dev/tenntenn/books/d168faebb1a739/viewer/2edb6d iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔
  25. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. 25 ࠷ऴతʹ͸ɺී௨ͷϧʔϓॲཧʹม׵ iterator͸ͲͷΑ͏ʹॲཧ͞Ε͍ͯΔ͔
  26. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ·ͱΊ 26 - ΠςϨʔγϣϯॲཧΛ៉ྷʹɾඪ४తʹ͔͚ΔΑ͏ʹͳͬͯ خ͍͠ - ༷ʑͳඪ४ϥΠϒϥϦ͕ࠓޙiteratorΛฦ͢Α͏ͳϝιου Λ௥Ճͯ͘͠ΕΔͷͰɺ࢖͏ଆͱͯ͠͸rangeͷޙʹஔͩ͘ ͚Ͱ࢖͑Δ͜ͱ΋ଟ͘ͳΔ - yieldॲཧͷฦΓ஋ʹ͍ͭͯཧղ͓͚ͯ͠͹ɺϥΠϒϥϦఏ ڙऀଆͱͯ͠΋σʔλߏ଄ʹରͯ͠ඪ४Խ͞Εͨiteratorॲ ཧΛ࣮ࢪͰ͖Δ - iteratorΛ࢖ͬͨॲཧ͸ɺ࣮ࡍʹ͸खͰॻ͍ͨϧʔϓͷΑ͏ ʹม׵͞Ε͍ͯΔ
  27. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ·ͱΊ 27 iteratorɺͲΜͲΜ࢖͍·͠ΐ͏ʂ
  28. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ʲPRʳاۀ঺հ 28 ސ٬ͷ੒௕Λਅʹ࣮ݱ͠ɺ೔ຊશମΛ੒௕ͤ͞Δɻ ೔ຊاۀ͕ɺੈքΛ੮ר͢Δࠃͱͯ͠੒௕͠ଓ͚ΔͨΊ ͜Ε·Ͱͷۀք͝ͱͷσʔλऩूɾ෼ੳͷ஌ݟ࣮੷Λݩʹ AIͱσʔλαΠΤϯςΟετ͕αϙʔτ͠·͢ɻ ೔ຊͷ͋Γͱ͋ΒΏΔاۀɾ૊৫͕͢΂ͯͷσʔλΛ ༗ޮతʹ׆༻͠ɺاۀڝ૪ྗΛ࠷େԽͰ͖ΔΑ͏ʹ σʔλ׆༻ͷϓϩϑΣογϣφϧͱͯ͠ɻ اۀͷ੒௕Λਅʹ࣮ݱͰ͖ΔੈքΛ໨ࢦͯ͠ɻ גࣜձࣾGROWTH VERSE
  29. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ʲPRʳاۀ঺հ ୅දऔక໾CEOͷ౉෦ʹՃ͑ɺ2024೥1݄ΑΓɺ୅දऔక໾CTOͱͯ͠ೆ໺ɺऔ క໾CFOͱͯ͠ॾ෌͕ࢀը ౉෦஌ത ୅දऔక໾CEO SalesforceΛ͸͡Ίͱͨ͠֎ ࢿܥSaaSاۀʹͯӦۀ͓Α ͼӦۀ੹೚ऀͱͯ͠ɺ೔ຊ๏ ਓͷۀ੷֦େʹߩݙɻ ಛʹCRMྖҬɺMarTechྖҬ ʹ஌ݟΛ࣋ͭɻ ex ex ex ೆ໺ॆଇ ୅දऔక໾CTO ڠձൃ଍͔࣌Βͷ೔ຊσΟʔ ϓϥʔχϯάڠձཧࣄɻ ϔϧεέΞελʔτΞοϓྦྷ ܭ1200ສDLͷFiNCΞϓϦͷ CTOɾCEOΛܦݧɻ ϓϩμΫτ։ൃɾAI΁ͷ஌ݟ Λ࣋ͭɻ ؂ࠪ๏ਓɺϋϯζΦϯܕίϯαϧͰ ͷܦݧΛ׆͔͠ɺࣄۀձࣾͷIPO੹ ೚ऀͱͯ͠౦ূάϩʔεࢢ৔΁ͷ্ ৔Λ࣮ݱɻެೝձܭ࢜ͱͯ͠ܦӦ؅ ཧମ੍ͷߏஙɺ౤ࢿɾM&AʹՃ͑ɺ ܦӦίϯαϧλϯτͱͯ͠੒௕ઓུ ͷࡦఆɾ࣮ߦɺ৽نࣄۀ։ൃͳͲͷ ྖҬͰܦݧΛ༗͢Δɻ ॾ෌ܓี औక໾CFO ex ex ex 29
  30. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. ʲPRʳاۀ঺հ 30 2004 2021 2022 2023 2024 2025 2026 2000 2001 ૑ۀ ࢿຊࢀը ϛμεΩϟϐλϧ͕ࢿຊࢀը શ໘తͳܦӦࢧԉΛड͚ɺୈೋ૑ۀظΛܴ͑Δ AIMSTAR ։ൃ։࢝ AIMSTAR ϦϦʔε ৽ܦӦମ੍ ൃ଍ γϦʔζA ࢿۚௐୡ ʢ5.1ԯԁʣ CDP/MAπʔϧͰഓͬͨϊ΢ϋ΢Λϕʔεʹ౷߹AIϓϥοτϑΥʔϜͷࢢ৔ Λૂ͏ɻ ɾ໊ࣾมߋ ɾܦӦମ੍࡮৽ ɾ౷߹AIϓϥοτϑΥʔϜ΁
  31. 2024 GROWTH VERSE Co., Ltd. All rights reserve. This presentation

    is for informational purposes only. GROWTH VERSE Co., Ltd. makes no warranties, express or implied, in this summary. Thank you.