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
それ NArray でできるよ
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
tmaeda
February 08, 2014
Technology
11k
18
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
それ NArray でできるよ
tmaeda
February 08, 2014
More Decks by tmaeda
See All by tmaeda
アクターモデルの話
tmaedax
7
1.8k
Jupyter(主にnotebook)のご紹介
tmaedax
1
1.4k
VoiceText Web APIでのGolang利用事例のご紹介
tmaedax
2
2.3k
AngularJSのご紹介
tmaedax
12
6.6k
静的型付き関数型言語のススメ
tmaedax
3
1.6k
Other Decks in Technology
See All in Technology
AI de Idea
kawaguti
PRO
2
110
アプリログインとWeb認証基盤をつなぐ ASWebAuthenticationSession 作法
shimastripe
1
320
2026-09-11 【Snowflake World Tour Tokyo 2026】Snowflakeを起点に、AI Agentが自律稼働し続ける未来へ / Driving AI Agents with Snowflake
civitaspo
0
400
Amazon Quick on DesktopがIAM Identity Centerで動かない理由
yukiogawa
0
190
AI時代、データエンジニアが一番おもろい
genshun9
0
580
10Xに技術的負債をもたらした「2つの境界の歪み」その構造と解消への営み
10xinc
0
1.9k
目の前の楽しいが人生を変える - コミュニティの螺旋の歩き方と楽しむコツ / change your life
soudai
PRO
4
600
越境するなら専門用語を使うな高校校歌 / If you wanna cross border, you shouldn't use jargon
vtryo
0
140
DEFCON34-Write-up_HYCu-MYCu
daikiokazaki
0
160
Spring BootからQuarkusへの移行
tatsuya1bm
2
120
安心して変更できるWebフロントエンドの作り方
pirosikick
4
2.5k
SREは、MCPとAutopilotをこう使え!
kazumax55
2
800
Featured
See All Featured
Everyday Curiosity
cassininazir
0
320
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
850
Statistics for Hackers
jakevdp
799
230k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.9k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
540
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
330
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
Embracing the Ebb and Flow
colly
88
5.2k
Transcript
ͦΕ/"SSBZͰ Ͱ͖ΔΑ 札幌中央区RRuubbyy会議0011 22001144年22月88日 @@ttmmaaeeddaa
!UNBFEB
!UNBFEB w3VCZྺ͏ʹͳΓ·͢ɻ
!UNBFEB w3VCZྺ͏ʹͳΓ·͢ɻ (C)Ωϟϓςϯཌྷ
!UNBFEB w3VCZྺ͏ʹͳΓ·͢ɻ (C)Ωϟϓςϯཌྷ
!UNBFEB wͦͷੲຊΛॻ͍ͨΓ͠·ͨ͠ɻ
!UNBFEB wաڈճ΄Ͳࡳຈ3VCZձٞͰ3BJMTͷ͓Λ͞ ͖ͤͯ·ͨ͠ɻ
!UNBFEB w ג ͑ʹ͠ςοΫͰͲͬΓ3VCZͰࣄ͕Ͱ͖ ͯͤͰ͢ɻ
ࠓޚࣾͷϏδωε Ͱ͝׆༻͍͚ͨͩΔ /"SSBZ ͷ͝ఏҊͰ͢ɻ
/"SSBZʁ ॳࣖ ໊લ͙Β͍ฉ͍ͨࣄ͋Δ ͬͨ͜ͱ͋Δ Α͘͏
/"SSBZ wాதণ͞Μ࡞ͷ3VCZ༻ଟ࣍ݩྻܭࢉ ϥΠϒϥϦɻ wओʹେྔͷܭࢉΛߴʹॲཧ͢Δ͜ͱΛ తʹ࡞ΒΕͨͷɻ http://magazine.rubyist.net/?0006-RLR
ͲΕ͙Β͍͍͔ʁ ྻཁૉ ඵ ྻʹ͔Β·ͰͷཚΛ֨ೲ͠ɺͦͷ߹ܭɺฏۉɺࢄɺ࠷େɺ࠷খΛٻΊΔͷʹ͔͔ͬͨ߹ܭඵ 3VCZ /"SSBZ .BD#PPL"JS*OUFM$PSFJ()[
ͲΕ͙Β͍͍͔ʁ ྻཁૉ ඵ ྻʹ͔Β·ͰͷཚΛ֨ೲ͠ɺͦͷ߹ܭɺฏۉɺࢄɺ࠷େɺ࠷খΛٻΊΔͷʹ͔͔ͬͨ߹ܭඵ 3VCZ /"SSBZ .BD#PPL"JS*OUFM$PSFJ()[ ഒ ߴ
ͲΕ͙Β͍͍͔ʁ ྻཁૉ ඵ ྻʹ͔Β·ͰͷཚΛ֨ೲ͠ɺͦͷ߹ܭɺฏۉɺࢄɺ࠷େɺ࠷খΛٻΊΔͷʹ͔͔ͬͨ߹ܭඵ 3VCZ /"SSBZ .BD#PPL"JS*OUFM$PSFJ()[ ഒ ߴ Ͱɾ͢ɾ͕ʜ
ඵ ඵ ඵ
ສ݅Ҏ ্ͷܭࢉΛΑ ͘ඞཁͱ͢Δ ਓʙʁ ඵ ඵ ඵ
ͰɺͲΜͳ ʹখͯ͘͞ ͍͍ͷͰɺද ܭࢉΛΑ͘ඞ ཁͱ͢Δ ਓʙʁ
ͱ͍͏Θ͚Ͱɺࠓ /"SSBZͷ໘ΑΓ ɺදܭࢉػೳʹ ண͓ͨ͠Λ͠·͢ɻ
ྫ͑ɺ͜Μͳද
ྫ͑ɺ͜Μͳද ߦશମͷ߹ܭʁ
&YDFMͩͱʁ
3VCZඪ४ͷ"SSBZͩͱʁ a = [[1,2,3], [4,5,6], [7,8,9]] => [[1, 2, 3],
[4, 5, 6], [7, 8, 9]] a[1].inject(:+) => 15
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15 JOUܕͷ ºͷ࣍ݩ ྻΛ༻ҙͯ͠
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15 ࢝·ΓͰɺ ͣͭ૿Ճ͢ΔͰ ຒΊΔ
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15 ศ্ٓɺԣ࣠ΛY࣠ɺ ॎ࣠ΛZ࣠ͱݺͼ·͢ Αɻ Y Z
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15 Y࣠શ෦ɺ Z࣠൪ɺ Λऔಘ ศ্ٓɺԣ࣠ΛY࣠ɺ ॎ࣠ΛZ࣠ͱݺͼ·͢ Αɻ Y Z
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15 ͦΕΛ߹ܭ
·ͱΊΔͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1].sum => 15
/"SSBZͷಛ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1].sum => 15 ͪΌΜͱºͷܗ Ͱදࣔͯ͘͠ΕΔ
/"SSBZͷಛ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1].sum => 15 ૢ࡞શͯNBQɻ ࣗͰNBQ JOKFDUͳͲΛॻ ͘ඞཁͳ͍ɻ
ൺͯΈ·͠ΐ͏ x࣠ํͷ߹ܭ Array a[1].inject(:+) NArray na[true, 1].sum
ൺͯΈ·͠ΐ͏ x࣠ํͷ߹ܭ Array a[1].inject(:+) NArray na[true, 1].sum /"SSBZͷํ͕ײత Ͱ͕͢ɺ "SSBZͰ
·ͩڐͤΔϨϕϧ
Z࣠ํͷ߹ܭ ͬͯΈ·͠ΐ͏
ྫ͑ɺ͜Μͳද "ྻશମͷ߹ܭʁ
&YDFMͩͱʁ
3VCZඪ४ͷ"SSBZͩͱʁ a = [[1,2,3], [4,5,6], [7,8,9]] => [[1, 2, 3],
[4, 5, 6], [7, 8, 9]] a.map{|row| row[0]}.inject(:+) => 12
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[0, true] => NArray.int(3): [ 1, 4, 7 ] na[0, true].sum => 12
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[0, true] => NArray.int(3): [ 1, 4, 7 ] na[0, true].sum => 12 Y࣠൪ɺ Z࣠શ෦ Λऔಘ Y Z
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[0, true] => NArray.int(3): [ 1, 4, 7 ] na[0, true].sum => 12 ͦΕΛ߹ܭ
·ͱΊΔͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[0, true].sum => 12
ൺͯΈ·͠ΐ͏ x࣠ํͷ߹ܭ y࣠ํͷ߹ܭ Array a[1].inject(:+) a.map{|row| row[0]}. inject(:+) NArray na[true,
1].sum na[0, true].sum
ൺͯΈ·͠ΐ͏ x࣠ํͷ߹ܭ y࣠ํͷ߹ܭ Array a[1].inject(:+) a.map{|row| row[0]}. inject(:+) NArray na[true,
1].sum na[0, true].sum "SSBZͩͱɺྻͷ߹ܭͷͱ͖ͷίʔυͱશ͘ର শੑ͕ͳ্͍ʹɺগͯ͘͠Կ͍ͬͯΔͷ͔ Θ͔Γʹ͍͘Ͱ͢Ͷ
͜͜·Ͱͷ·ͱΊ w/"SSBZͰදΛදͱͯ͠ѻ͑·͢ɻ wૢ࡞શͯNBQJOKFDUʹ૬͢ΔͷͰɺࣗ ͰNBQJOKFDUΛॻ͘ඞཁ͕͋Γ·ͤΜɻ
ͬͱෳࡶͳྫ ͬͯΈ·͠ΐ͏
ूܭද࡞͍ͬͯͩ͘͞Ҋ݅
ूܭද࡞͍ͬͯͩ͘͞Ҋ݅ Α͋͘Γ·͢ΑͶʁ
ͷখܭΛٻΊΔʹʁ
3VCZඪ४ͷ"SSBZͰߟ͑ Δͷ͏ࢭΊ·ͯ͠ʜ
/"SSBZͰ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] na[true, [0,1]].sum(1) => NArray.int(3): [ 5, 7, 9 ]
/"SSBZͰ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] na[true, [0,1]].sum(1) => NArray.int(3): [ 5, 7, 9 ] Y࣠શ෦ɺ Z࣠൪ͱ൪ Λऔಘ Y Z
/"SSBZͰ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] na[true, [0,1]].sum(1) => NArray.int(3): [ 5, 7, 9 ] ͦΕΛZ࣠ํʹ ߹ܭ
ͪͳΈʹ na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3
], [ 4, 5, 6 ] ] na[true, [0,1]].sum(0) na[true, [0,1]].sum(1) na[true, [0,1]].sum => NArray.int(2): [ 6, 15 ] => NArray.int(3): [ 5, 7, 9 ] => 21
ͪͳΈʹ na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3
], [ 4, 5, 6 ] ] na[true, [0,1]].sum(0) na[true, [0,1]].sum(1) na[true, [0,1]].sum => NArray.int(2): [ 6, 15 ] => NArray.int(3): [ 5, 7, 9 ] => 21 TVN ͩͱɺ Y࣠ํʹ߹ܭ͞Εͯ
ͪͳΈʹ na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3
], [ 4, 5, 6 ] ] na[true, [0,1]].sum(0) na[true, [0,1]].sum(1) na[true, [0,1]].sum => NArray.int(2): [ 6, 15 ] => NArray.int(3): [ 5, 7, 9 ] => 21 TVN ͩͱɺ Z࣠ํʹ߹ܭ͞Εͯ
ͪͳΈʹ na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3
], [ 4, 5, 6 ] ] na[true, [0,1]].sum(0) na[true, [0,1]].sum(1) na[true, [0,1]].sum => NArray.int(2): [ 6, 15 ] => NArray.int(3): [ 5, 7, 9 ] => 21 TVNͩͱɺ શํʹ ߹ܭ͞Ε·͢
ͭ·Γɺ͜ͷลશ෦ɺTVN ͰٻΊΒΕΔΘ͚Ͱ͢ʂ TVN TVN TVN
͜Μͳߟ͑ํ ͋Γ·͢ɻ
͍ͭ͘ͷ࣠Ͱྨ͞Εͨ දͰ͠ΐ͏͔ʁ
͍ͭ͘ͷ࣠Ͱྨ͞Εͨ දͰ͠ΐ͏͔ʁ ੈͷ࣠
͍ͭ͘ͷ࣠Ͱྨ͞Εͨ දͰ͠ΐ͏͔ʁ ੑผͷ࣠
͍ͭ͘ͷ࣠Ͱྨ͞Εͨ දͰ͠ΐ͏͔ʁ ళͷ࣠
ͱ͍͏͜ͱɺ࣍ݩ ͷදͰ࣋ͭํ͕ࣗવ ͳͷͰʁ
͜Μͳײ͡ "ళ #ళ $ళ
உ ঁ ººͷදʢۭؒ
na = NArray.int(3, 2, 2).indgen!(1, 1) => NArray.int(3,2,2): [ [
[ 1, 2, 3 ], [ 4, 5, 6 ] ], [ [ 7, 8, 9 ], [ 10, 11, 12 ] ] ] /"SSBZͰදݱ͢Δͱʁ
na[0, 0, 0] => 1 na[0, 1, 0] => 4
na[0, 0, 1] => 7 Λऔಘͯ͠Έ·͠ΐ͏ "ళ உ "ళ ঁ "ళ உ
ͷશ෦ʁ na[true, true, 0] => NArray.int(3,2): [ [ 1, 2,
3 ], [ 4, 5, 6 ] ] na[true, true, 0].sum => 21 ళશ෦ ੑผશ෦
உੑͷશ෦ʁ na[true, 0, true] => NArray.int(3,2): [ [ 1, 2,
3 ], [ 7, 8, 9 ] ] na[true, 0, true].sum => 30 ళશ෦ ੈશ෦ உੑ
ͬͱศརʹʂ w/"SSBZԿ࣍ݩͷσʔλͰѻ͑Δ w͍͍ͪͪͱྻͷΠϯσοΫεΛ಄Ͱߟ͑ͯ ରԠ͚ͮΔͷ໘ͳͷͰɺͦ͜Λਓʹ༏͍͠ײ ͡ͷϥούʔΛඃͤͯ͋͛Δͱɺҙͷͷ࣠ ͰσʔλΛཧͰ͖Δശ͕Ͱ͖͕͋Γ·͢ɻ
cube = Cube.new([ {key: :mise, values: ["Aళ", "Bళ", "Cళ"]}, {key:
:sedai, values: ["10","20"]}, {key: :sei, values:["உ","ঁ"]} ]) # ళA, 20, ঁʹ20Λઃఆ cube.set( { mise: "Aళ", sedai: "20", sei: "ঁ" }, 20) # ళA, 20, ঁͷΛऔಘ cube.get( { mise: "Aళ", sedai: "20", sei: "ঁ" }) => 20 # 10ͷΛऔಘ cube.get( { sedai: "10"} ) => NArray.int(3,2): [ [ 1, 2, 3 ], [ 7, 8, 9 ] ]
·ͱΊ w/"SSBZҙͷͷ࣠ͷσʔλΛࣗ༝ʹѻ͑ ·͢ɻ w/"SSBZͦͷσʔλۭؒͷதͷ͖ͳॴͷ σʔλʹॊೈʹΞΫηεͰ͖·͢ɻ w&YDFM͙Β͍ΧδϡΞϧʹ/"SSBZΛ͍·͠ ΐ͏ʂ
ࢀߟ wϚχϡΞϧ IUUQOBSSBZSVCZGPSHFPSHJOEFYIUNMKB w3VCZٯҾ͖Ϩγϐ Ϩγϐ wOVNQZؔͷࢿྉ
ͥͻޚࣾͷϏδωε ͝׆༻͍ͩ͘͞ɻ