2010/7/31 ltの虎@ll tiger
Post on 13-Sep-2014
2.227 views
DESCRIPTION
2010/7/31のLTの虎のスライド。PostgreSQL上でPerl6を動かすPL/Parrot & PL/Perl6の紹介です。TRANSCRIPT
それPL/PERL6でできるよ
奥野 晃裕 @choplin
エレファントカシマシタ12010年7月31日土曜日
自己紹介
奥野 晃裕
@choplin Bioinformatician @Perl -‐> Web & DB programmer@Server Side JavaScript一年目@フォルシア株式会社
okuno.a.aaあっとgmail.com
22010年7月31日土曜日
みなさんPerl使ってますか?
32010年7月31日土曜日
言わずと知れたLLの雄 Perlですが
42010年7月31日土曜日
遂に出ました!
52010年7月31日土曜日
Usable Perl6こと
Rakudo Star
62010年7月31日土曜日
7
もうビルドしましたか?
72010年7月31日土曜日
Perl6のいいところ
色々ありますが、、、
•Smart Match•Junction•etc.
82010年7月31日土曜日
ねんがんのおぶじぇくとしこうをてにいれたぞ!
92010年7月31日土曜日
class Mammal { has $.name;} class Human is Mammal { method speak() { say “$.name the Perl6 Monger”; }}my $dankogai = Human.new(name => ‘Dan’);$dankogai.speak(); #Dan the Perl6 Monger
Cool!102010年7月31日土曜日
でも最近流行ってますよね
112010年7月31日土曜日
関数型言語
122010年7月31日土曜日
そんなっ・・・!10年も待ったのにっ・・・!
132010年7月31日土曜日
Perl7?
142010年7月31日土曜日
否152010年7月31日土曜日
162010年7月31日土曜日
17
そんな貴方に
172010年7月31日土曜日
それ = 非手続き型プログラミング
PL/Perl6でできるよ!
182010年7月31日土曜日
PL/Perl6ってなに?
•PL = Procedural Language•PostgreSQL内の手続き言語
•PostgreSQLの関数をPerl6で書ける!
192010年7月31日土曜日
PL/Perl6ってなに?•PL/Parrot (by Jonathan "Duke" Leto ) 上で動いています
PostgreSQL
プログラマーPL/Perl6PL/Parrot
202010年7月31日土曜日
21
PL/Perl6はLLです
$psql -‐C “CREATE FUNCTION hello() RETURNS text AS $$ return ‘hello’ $$ LANGUAGE plperl6; SELECT hello();”
ワンライナーだってできるよ!
hello()-‐-‐-‐-‐-‐-‐-‐hello
212010年7月31日土曜日
SQL : Functional Oriented (?)
+Perl6 : Object Oriented
PL/Perl6を使うと
222010年7月31日土曜日
正確には関係代数です
232010年7月31日土曜日
非手続き型という ということで
242010年7月31日土曜日
25
SQLを使うと
252010年7月31日土曜日
Map逐次処理だって
262010年7月31日土曜日
CREATE FUNCTION perl_array() RETURNS text AS $$ my $ary = "1\t2\t3\t4"; return $ary.join('\t');$$ LANGUAGE plperl6;
CREATE FUNCTION perl_factorial(integer) RETURNS integer AS $$ my $ret = 1; for 1..@_[0] { $ret *= $_ } return $ret;$$ LANGUAGE plperl6;
SELECT perl_factorial(elem)FROM( SELECT CAST(unnest(string_to_array(perl_array(), '\t')) AS integer AS elem)array;
272010年7月31日土曜日
Reduce集約処理だって
282010年7月31日土曜日
CREATE FUNCTION perl_array() RETURNS text AS $$ my $ary = "1\t2\t3\t4"; return $ary.join('\t');$$ LANGUAGE plperl6;
SELECT CASE mod(col, 2) WHEN 0 THEN 'odd' WHEN 1 THEN 'even' END AS mod ,count(col)FROM( SELECT CAST(unnest(string_to_array(perl_array(), '\t')) AS integer) AS elem)arrayGROUP BY mod
292010年7月31日土曜日
302010年7月31日土曜日
ちなみにPerl6単体でやると
map {factorial($_)}, @array;
my @tmp = map {%count{$_}++}, (map {($_ % 2) ?? 'even' !! 'odd'}, @ary);
逐次
集約
312010年7月31日土曜日
32
さらに
322010年7月31日土曜日
33
Rakudo StarにLWP::SimpleとJSON::Tiny
がついてきたので332010年7月31日土曜日
CREATE FUNCTION twitter_public_timeline() RETURNS text AS $$ use LWP::Simple; use JSON::Tiny; my $url = 'http://api.twitter.com/1/statuses/public_timeline.json'; my $lwp = LWP::Simple.new; my $content = $lwp.get($url); my $json = from-‐json($content); my @ary; for $json.values -‐> $post{ @ary.push($post<text>) } return @ary.join("\t");$$ LANGUAGE plperl6;
SELECT twitter_public_timeline();
たとえばこんなこと
342010年7月31日土曜日
35
動かない・・・psql:twitter.sql:31: server closed the connection unexpectedly This probably means he server terminated abnormally before of while processing the request.psql:twiter.sql:31: connection to server was lost
マルチバイト文字?
352010年7月31日土曜日
362010年7月31日土曜日
CREATE FUNCTION twitter_public_timeline() RETURNS text AS $$ use LWP::Simple; use JSON; my $url = 'http://api.twitter.com/1/statuses/public_timeline.json'; my $content = get($url); my $json = decode_json($content); my @ary; for my $post (@{ $json }){push(@ary, $post-‐>{text})} return join "\t", @ary;$$ LANGUAGE plperlu;
SELECT twitter_public_timeline;
動かなかったのPerl5で
372010年7月31日土曜日
38
動いた!$psql -f twitter_perl5.sql twitter_public_timeline------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- putzz pensei qe era minaa :X (@piconn live on http://twitcam.com/1ezjg) Ok el #TL esta demasiado X.. chao pescao! おおうちめちゃ勉強してる(/_;)こええー Royal Links in Vegas Simulates British Open Venues http://bit.ly/bBJcIT Calling my sister & i'm scared. "a necessidade de se manter um histórico é a de poder reler, vererros e corrigi-los...e pq é engraçado reler as lezeras de sempre ^^" será que isso é a esperança do meu curso de fotografia indo embora? ): alhamdulillah uang 50 rb dr gd. Q gue yg ilang entah berantah,skr dganti berkali lipat dr gd. Q jg,terima kasih Allah :) ドッカンドッカンwwwwwww RT @amochoco: しょーこうをどけー! Jahatttt gak boleh ijin...hikss How To Make Money Blogging... Big Money http://bit.ly/aIkMuu 今から3分 朝起きてから,今日は二度寝をしなかった!!!部屋も片付けられたし,午後はレポートをがんばろう。 こちらこそご注文ありがとうございました!何かあればお気軽にご質問下さい♪ 発送時にまたご連絡差し上げます! RT @9_kumi_3:
@NaluHawaii メール確認しました。同封の件、めっちゃ嬉しいです!!すごく親切に色々要望をきいてくださり感謝してます♪本当にありがとうご kasih gue kelinci dong.. sinceramente, eu acho que eu vou chorar quando Hannah Montanaacabar... eu sou muuuuuito apaixonada por essa série... Photo: manhattan skyline http://tumblr.com/xxwel6auo Shit playin cards drinkin what's up???!! mission accomplished.!!(20 rows)
Perl5サイコー!382010年7月31日土曜日
ついでに
392010年7月31日土曜日
http://leto.net/dukeleto.pl/2010/06/rakudo-‐perl-‐6-‐in-‐your-‐postgresql-‐database.html
実はまだ引数を取れないというオチでしめようと思っていたのですが!!?
402010年7月31日土曜日
http://groups.google.com/group/plparrot/browse_thread/thread/7aebe2e5a043e175
昨日直りました!!Leto ++, Moritz Lenz++
412010年7月31日土曜日
それ もう もうすぐ
PL/Perl6でできるよ!
まとめ
422010年7月31日土曜日
まとめ乗るしかない!
SQLのビッグウェーブに!432010年7月31日土曜日
ご静聴ありがとうございました
See more about PL/Parrot and PL/Perl6
http://pl.parrot.org/http://github.com/leto/plparrothttp://groups.google.com/group/plparrot
442010年7月31日土曜日