2013-07-13 kyoto.pm #5 lt
TRANSCRIPT
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::RangedInthttps://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::RangedIntRange::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-253 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-253 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-241 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 程度 ><
TODOA::RI オブジェクトを引数に
overload 使って A::RI 同士の演算を実装集合の加算・減算みたいに
メモリサイズや速度の計測・比較とか
2013-07-13 Kyoto.pm #5
ご静聴ありがとうございました!https://github.com/issm/p5-Array-RangedInt
2013-07-13 Kyoto.pm #5
Q?