SlideShare a Scribd company logo
1 of 44
Download to read offline
Array::RangedInt
2013-07-13 Kyoto.pm #5
岩田 享 / issm
2013-07-13 Kyoto.pm #5
自己紹介
背景
Array::RangedInt
SYNOPSIS
まとめ
アジェンダ
2013-07-13 Kyoto.pm #5
自己紹介
背景
Array::RangedInt
SYNOPSIS
まとめ
アジェンダ
2013-07-13 Kyoto.pm #5
おまえだれよ?
岩田 享 / issm(いわた)
http://blog.iss.ms/
@issm, qr/issmx{,2}/
Perl / CoffeeScript / 自転車
嗜む程度に
個人事業
とある「商品」を販売 → 発注 → 発送管理
などするためのシステムの開発・保守
2013-07-13 Kyoto.pm #5
名古屋(の近く)からきました
2013-07-13 Kyoto.pm #5
自己紹介
Textile記法
Text::Textile
拡張性について
応用
まとめ
アジェンダ
Minecraft がおもしろすぎて
おしごとするのがつらい
2013-07-13 Kyoto.pm #5
本題
2013-07-13 Kyoto.pm #5
自己紹介
背景
Array::RangedInt
SYNOPSIS
まとめ
アジェンダ
2013-07-13 Kyoto.pm #5
自己紹介
背景
Array::RangedInt
SYNOPSIS
まとめ
アジェンダ
2013-07-13 Kyoto.pm #5
Array::RangedInt
2013-07-13 Kyoto.pm #5
とあるアプリケーションで
何番が選択されているかを保持
選択されている番号のボタンをアクティヴに
2013-07-13 Kyoto.pm #5
Array::RangedInt
2013-07-13 Kyoto.pm #5
カテゴリに属するすべての番号が選択
→「このカテゴリのすべてを選択」ボタンをア
クティヴに
とあるアプリケーションで
2013-07-13 Kyoto.pm #5
Array::RangedInt
2013-07-13 Kyoto.pm #5
商品の選択解除でボタンを非アクティヴに
→「このカテゴリのすべてを選択」ボタンを非
アクティヴに
とあるアプリケーションで
2013-07-13 Kyoto.pm #5
Array::RangedInt
2013-07-13 Kyoto.pm #5
単品ごとの「選択」ボタンと「すべてを選択」
ボタンとの整合性確保が必要
リスト・ハッシュでがんばろうとしたけど,
カオス発生
「整数の範囲」を扱いたい
とあるアプリケーションで
2013-07-13 Kyoto.pm #5
そのへんをなんとかする
モジュールを書いてみた
(2012年の暮れに)
2013-07-13 Kyoto.pm #5
自己紹介
背景
Array::RangedInt
SYNOPSIS
まとめ
アジェンダ
2013-07-13 Kyoto.pm #5
自己紹介
背景
Array::RangedInt
SYNOPSIS
まとめ
アジェンダ
2013-07-13 Kyoto.pm #5
Array::RangedInt
https://github.com/issm/p5-Array-RangedInt
「『範囲表記』な整数」を要素にもち,ごにょ
ごにょするためのモジュール
要素の例
1
2-5
-5:-2 ( -5--2 でも可)
2013-07-13 Kyoto.pm #5
Array::RangedInt
隣接する整数群は「範囲」として扱う
(1, 2, 3, 4, 6, 8, 9, 10) -> (‘1-4’, 6, ’8-10’)
「範囲」を扱う特性上...
必ず順序付けされている
重複した値を持たない
2013-07-13 Kyoto.pm #5
Array::RangedInt
Range::Object::DigitString
似てる?
私のほしいメソッドが足りない
2013-07-13 Kyoto.pm #5
自己紹介
背景
Array::RangedInt
SYNOPSIS
まとめ
アジェンダ
2013-07-13 Kyoto.pm #5
自己紹介
背景
Array::RangedInt
SYNOPSIS
まとめ
アジェンダ
2013-07-13 Kyoto.pm #5
コンストラクタ
->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-07-13 Kyoto.pm #5
要素を追加する
->add(@args)
$ari->add( 2, 15, ’21-25’ )
1, 2, 3, 5-10, 15, 21-25
2013-07-13 Kyoto.pm #5
要素を追加する
->add(@args)
$ari->add( 2, 15, ’21-25’ )
1, 2, 3, 5-10, 15, 21-25
1-3, 5-10, 15, 21-25
2013-07-13 Kyoto.pm #5
要素を削除する
->remove(@args)
$ari->remove( 3, 8, ‘18-22’ )
1-3, 5-10, 15, 21-25
3 8 18-20,21-22
2013-07-13 Kyoto.pm #5
要素を削除する
->remove(@args)
$ari->remove( 3, 8, ‘18-22’ )
1-2, 5-7, 9-10, 15, 23-25
1-3, 5-10, 15, 21-25
3 8 18-20,21-22
2013-07-13 Kyoto.pm #5
shift!
->shift()
$ari->shift()
1-2, 5-7, 9-10, 15, 23-25
2013-07-13 Kyoto.pm #5
shift!
->shift()
$ari->shift()
2, 5-7, 9-10, 15, 23-25
got: 1
1-2, 5-7, 9-10, 15, 23-25
2013-07-13 Kyoto.pm #5
pop!
->pop()
$ari->pop()
2, 5-7, 9-10, 15, 23-25
2013-07-13 Kyoto.pm #5
pop!
->pop()
$ari->pop()
2, 5-7, 9-10, 15, 23-24
got: 25
2, 5-7, 9-10, 15, 23-25
2013-07-13 Kyoto.pm #5
含んでいる?
->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-07-13 Kyoto.pm #5
配列のサイズを取得する
->size()
$ari->size() # 9
2, 5-7, 9-10, 15, 23-24
1 3 2 1 2
2013-07-13 Kyoto.pm #5
文字列として
->stringify()
$ari->stringify()
’2,5-7,9-10,15,23-24’
2013-07-13 Kyoto.pm #5
配列として
->dump()
my @a = $ari->dump() # as array
my $a = $ari->dump() # as arrayref
( 2, 5 .. 7, 9 .. 10, 15, 23 .. 24 )
[ 2, 5 .. 7, 9 .. 10, 15, 23 .. 24 ]
or
2013-07-13 Kyoto.pm #5
自己紹介
背景
Array::RangedInt
SYNOPSIS
まとめ
アジェンダ
2013-07-13 Kyoto.pm #5
自己紹介
背景
Array::RangedInt
SYNOPSIS
まとめ
アジェンダ
2013-07-13 Kyoto.pm #5
まとめ
Array::RangedInt ってモジュールを書いた
「範囲表記」な整数をそのまま扱う
範囲をともなう整数の集合の扱いを多少ラ
クに
とても素直(愚直)なコーディング
工夫の余地大あり
2013-07-13 Kyoto.pm #5
まとめ
Kansai.pm #15 での LT からの進展
bugfix 程度 ><
TODO
A::RI オブジェクトを引数に
overload 使って A::RI 同士の演算を実装
集合の加算・減算みたいに
メモリサイズや速度の計測・比較とか
2013-07-13 Kyoto.pm #5
ご静聴ありがとうございました!
https://github.com/issm/p5-Array-RangedInt
2013-07-13 Kyoto.pm #5
Q?

More Related Content

Similar to 2013-07-13 Kyoto.pm #5 LT

Building Static Website With Github And Jekyll
Building Static Website With Github And JekyllBuilding Static Website With Github And Jekyll
Building Static Website With Github And Jekyll
Yoji Shidara
 

Similar to 2013-07-13 Kyoto.pm #5 LT (9)

#crazy-js Quiz
#crazy-js Quiz#crazy-js Quiz
#crazy-js Quiz
 
最近僕が使うようになったPerl 5.10以降の新しいやつ
最近僕が使うようになったPerl 5.10以降の新しいやつ最近僕が使うようになったPerl 5.10以降の新しいやつ
最近僕が使うようになったPerl 5.10以降の新しいやつ
 
Node-RED のフローを isaax で配信してみた
Node-RED のフローを isaax で配信してみたNode-RED のフローを isaax で配信してみた
Node-RED のフローを isaax で配信してみた
 
Indy(Invokedynamic) and Bytecode DSL and Brainf*ck
Indy(Invokedynamic) and Bytecode DSL and Brainf*ckIndy(Invokedynamic) and Bytecode DSL and Brainf*ck
Indy(Invokedynamic) and Bytecode DSL and Brainf*ck
 
Building Static Website With Github And Jekyll
Building Static Website With Github And JekyllBuilding Static Website With Github And Jekyll
Building Static Website With Github And Jekyll
 
Retina対応 CSSスプライトを自動化しよう sprity版(東区フロントエンド勉強会 2015年 第2回) 補足資料
Retina対応 CSSスプライトを自動化しよう sprity版(東区フロントエンド勉強会 2015年 第2回) 補足資料Retina対応 CSSスプライトを自動化しよう sprity版(東区フロントエンド勉強会 2015年 第2回) 補足資料
Retina対応 CSSスプライトを自動化しよう sprity版(東区フロントエンド勉強会 2015年 第2回) 補足資料
 
MySQLerの7つ道具
MySQLerの7つ道具MySQLerの7つ道具
MySQLerの7つ道具
 
シェルスクリプトワークショップ資料 - 上級者向け「シェル芸」
シェルスクリプトワークショップ資料 - 上級者向け「シェル芸」シェルスクリプトワークショップ資料 - 上級者向け「シェル芸」
シェルスクリプトワークショップ資料 - 上級者向け「シェル芸」
 
MySQLのGIS機能とか超入門 ~MyNA会2018年7月
MySQLのGIS機能とか超入門 ~MyNA会2018年7月MySQLのGIS機能とか超入門 ~MyNA会2018年7月
MySQLのGIS機能とか超入門 ~MyNA会2018年7月
 

2013-07-13 Kyoto.pm #5 LT