SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
「範囲表記」な整数を
   配列で扱う

 2013-02-23 Kansai.pm #15
       岩田 享 / issm
アジェンダ
自己紹介

背景

Array::RangedInt

SYNOPSIS

まとめ



                   2013-02-23 Kansai.pm #15
アジェンダ
自己紹介

背景

Array::RangedInt

SYNOPSIS

まとめ



                   2013-02-23 Kansai.pm #15
おまえだれよ?

岩田 享 / issm(いわた)

http://blog.iss.ms/

@issm, qr/issmx{,2}/

Perl / CoffeeScript / 自転車

  嗜む程度に

個人事業

  とある「商品」を販売 → 発注 → 発送管理
  などするためのシステムを開発するなど
                           2013-02-23 Kansai.pm #15
名古屋の方からきました
(Nagoya.pm というものも存在しているらしいですよ)




                            2013-02-23 Kansai.pm #15
アジェンダ
自己紹介

Textile記法

Text::Textile

拡張性について

応用

まとめ

                 2013-02-23 Kansai.pm #15
本題




     2013-02-23 Kansai.pm #15
アジェンダ
自己紹介

背景

Array::RangedInt

SYNOPSIS

まとめ



                   2013-02-23 Kansai.pm #15
アジェンダ
自己紹介

背景

Array::RangedInt

SYNOPSIS

まとめ



                   2013-02-23 Kansai.pm #15
Array::RangedInt




               2013-02-23 Kansai.pm #15
とあるアプリケーションで
何番が選択されているかを保持

選択されている番号のボタンをアクティヴに




                 2013-02-23 Kansai.pm #15
Array::RangedInt




               2013-02-23 Kansai.pm #15
とあるアプリケーションで
カテゴリに属するすべての番号が選択

→「このカテゴリのすべてを選択」ボタンをア
クティヴに




                    2013-02-23 Kansai.pm #15
Array::RangedInt




               2013-02-23 Kansai.pm #15
とあるアプリケーションで
商品の選択解除でボタンを非アクティヴに

→「このカテゴリのすべてを選択」ボタンを非
アクティヴに




                 2013-02-23 Kansai.pm #15
Array::RangedInt




               2013-02-23 Kansai.pm #15
とあるアプリケーションで
単品ごとの「選択」ボタンと「すべてを選択」
ボタンとの整合性確保が必要

 リスト・ハッシュでがんばろうとしたけど,
 カオス発生

 「整数の範囲」を扱いたい




                 2013-02-23 Kansai.pm #15
そのへんをなんとかする
モジュールを書いてみた




          2013-02-23 Kansai.pm #15
アジェンダ
自己紹介

背景

Array::RangedInt

SYNOPSIS

まとめ



                   2013-02-23 Kansai.pm #15
アジェンダ
自己紹介

背景

Array::RangedInt

SYNOPSIS

まとめ



                   2013-02-23 Kansai.pm #15
Array::RangedInt
https://github.com/issm/p5-Array-RangedInt

「『範囲表記』な整数」を要素にもち,ごにょ
ごにょするためのモジュール

要素の例

 1

 2-5

 -5:-2 ( -5--2 でも可)
                                  2013-02-23 Kansai.pm #15
Array::RangedInt
隣接する整数群は「範囲」としてまとめられる

 (1, 2, 3, 4, 6, 8, 9, 10) -> (‘1-4’, 6, ’8-10’)

「範囲」を扱う特性上...

 必ず順序付けされている

 重複した値を持たない




                                       2013-02-23 Kansai.pm #15
アジェンダ
自己紹介

背景

Array::RangedInt

SYNOPSIS

まとめ



                   2013-02-23 Kansai.pm #15
アジェンダ
自己紹介

背景

Array::RangedInt

SYNOPSIS

まとめ



                   2013-02-23 Kansai.pm #15
コンストラクタ
 ->new( @args ) / ->parse( $text )
$ari = Array::RangedInt->new( 1, 3, ‘5-10’ )

$ari = Array::RangedInt->parse( ‘1,3,5-10’ )



                    1, 3, 5-10




                                          2013-02-23 Kansai.pm #15
要素を追加する
 ->add(@args)
$ari->add( 2, 15, ’21-25’ )




            1, 2, 3, 5-10, 15, 21-25




                                       2013-02-23 Kansai.pm #15
要素を追加する
 ->add(@args)
$ari->add( 2, 15, ’21-25’ )




            1, 2, 3, 5-10, 15, 21-25


              1-3, 5-10, 15, 21-25


                                       2013-02-23 Kansai.pm #15
要素を削除する
 ->remove(@args)
$ari->remove( 3, 8, ‘18-22’ )



           1-3,   5-10,    15,   21-25
             3      8      18-20,21-22




                                         2013-02-23 Kansai.pm #15
要素を削除する
 ->remove(@args)
$ari->remove( 3, 8, ‘18-22’ )



           1-3,   5-10,    15,   21-25
             3      8      18-20,21-22

           1-2, 5-7, 9-10, 15, 23-25


                                         2013-02-23 Kansai.pm #15
shift!
 ->shift()
$ari->shift()



           1-2, 5-7, 9-10, 15, 23-25




                                       2013-02-23 Kansai.pm #15
shift!
 ->shift()
$ari->shift()



           1-2, 5-7, 9-10, 15, 23-25


                     got: 1
             2, 5-7, 9-10, 15, 23-25

                                       2013-02-23 Kansai.pm #15
pop!
 ->pop()
$ari->pop()



              2, 5-7, 9-10, 15, 23-25




                                        2013-02-23 Kansai.pm #15
pop!
 ->pop()
$ari->pop()



              2, 5-7, 9-10, 15, 23-25


                     got: 25
              2, 5-7, 9-10, 15, 23-24

                                        2013-02-23 Kansai.pm #15
含んでいる?
 ->includes( @args )
$ari->includes( 2 )   # 1

$ari->includes( 2, 5, 7 ) # 1

$ari->includes( 2, 3, 4 )   # 0

$ari->includes( ‘5-7’, ’23-24’ )   # 1

$ari->includes( ‘5-7’, ’20-25’ )   # 0


            2, 5-7, 9-10, 15, 23-24

                                         2013-02-23 Kansai.pm #15
配列のサイズを取得する
 ->size()
$ari->size()       # 9




               2, 5-7, 9-10, 15, 23-24
               1     3   2   1    2




                                         2013-02-23 Kansai.pm #15
文字列として
 ->stringify()
$ari->stringify()




           ’2,5-7,9-10,15,23-24’




                                   2013-02-23 Kansai.pm #15
配列として
 ->dump()
my @a = $ari->dump()   # as array

my $a = $ari->dump()   # as arrayref



       ( 2, 5 .. 7, 9 .. 10, 15, 23 .. 24 )
                         or
       [ 2, 5 .. 7, 9 .. 10, 15, 23 .. 24 ]


                                         2013-02-23 Kansai.pm #15
アジェンダ
自己紹介

背景

Array::RangedInt

SYNOPSIS

まとめ



                   2013-02-23 Kansai.pm #15
アジェンダ
自己紹介

背景

Array::RangedInt

SYNOPSIS

まとめ



                   2013-02-23 Kansai.pm #15
まとめ
Array::RangedInt ってモジュールを書いた
 「範囲表記」な整数をそのまま扱う
 範囲をともなう整数の集合の扱いを多少ラ
 クに
 とても素直なコーディング
   工夫の余地大あり
TODO
 overload 使ってより配列っぽくできる?
 メモリサイズや速度の比較とか
                        2013-02-23 Kansai.pm #15
ご静聴ありがとうございました!
https://github.com/issm/p5-Array-RangedInt




                                    2013-02-23 Kansai.pm #15
Q?




     2013-02-23 Kansai.pm #15

Contenu connexe

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

2013 02-23 Kansai.pm #15 LT