SlideShare a Scribd company logo
1 of 54
Arrows in Perl
2011.12.10 hiratara
d.hatena.ne.jp/hiratara

twitter.com/hiratara



Perl
d.hatena.ne.jp/hiratara

twitter.com/hiratara



Perl
Perl

Haskell
Perl

Haskell
Perl

Haskell
Perl

Haskell
10/18 YAPC::Asia 2011

Monads in Perl
  Perl Monad

  Future
  (        JSDeferred)
10/18 YAPC::Asia 2011

Monads in Perl
  Perl Monad

  Future
  (        JSDeferred)
10/18 YAPC::Asia 2011

Monads in Perl
  Perl Monad

  Future
  (        JSDeferred)
Data::Monad

my $result = Data::Monad::Base::Sugar::for {
    pick my $x => sub { scalar_list 1 .. 100 };
    pick my $y => sub { scalar_list $x .. 100 };
    pick my $z => sub {
     scalar_list $y .. ($x + $y > 100 ? 100 : $x + $y)
    };
    satisfy { $x**2 + $y**2 == $z**2 };
    yield { $x, $y, $z }
};
return    >>=

return :: a -> m a
>>= :: m a -> (a -> m b) -> m b
return               >>=
ma       mb         mb       mc        ma        mc

     f        >=>        g        ==     f >=> g
a         b         b        c         a        c

ma                  ma       mb        ma        mb
 return       >=>        f        ==         f
a                   a        b         a         b
(2)

                              2



     fmap                return   join

fmap :: a -> b -> (m a -> m b)
join :: m (m a) -> m a
(3)
η⊗id           id⊗η
I⊗M              M⊗M            M⊗I

                     μ
      λ                     ρ

                 M
(                 )
              0×id                   id×0
(*, n)               (0, n) (n, 0)              (n, *)

                              (+)
         π’                             π

                          n
(            )
       fmap return              return
id.fmap            fmap.fmap               fmap.id

                         join
       id                             id

                    fmap
(            )
       fmap return              return
id.fmap            fmap.fmap               fmap.id

                         join
       id                             id

                    fmap
Arrows

John Hughes   2000
Monad    Arrow


                 (Haskell    )
                                 mb

                             f
                         a
Arrows

                         f :: m b c   b
                     a
Arrows

arr >>> first                    ↝

arr :: a -> b -> (a ↝ b)

>>> :: (a ↝ b) -> (b ↝ c) -> (a ↝ c)

first :: (a ↝ b) -> (a × c ↝ b × c)
Arrow
        package Arrow;

        sub arr {
        	 my ($class, $code) = @_;
        	 die "not implemented";
        }

        sub first {
        	 my $self = shift;
        	 die "not implemented";
        }

        sub next {
        	 my ($self, $arrow) = @_;
        	 die "not implemented";
        }
first
     a↝b       a   b

     >>>

     arr           ↝


a          f   b           a      arr f :: a ↝ b
                                                    b

               g   arr   arr f >>> arr g :: a ↝ c
                                                        arr g :: b ↝ c

    g.f
               c                                    c
first
           Arrow ↝

           a                    c   a×c

f :: a↝b             g :: c↝d         f *** g :: a×c↝b×d




           b                    d   b×d
(f *** g) >>> (f’ *** g’)   (f >>> f’) *** (g >>> g’)


      f           g                f          g




       f’         g’               f’        g’
(f *** g) >>> (f’ *** g’)   (f >>> f’) *** (g >>> g’)


      f           g                f          g




       f’         g’               f’        g’
premonoidal category

 f ⋉ id = first f     a×b          a×b
 id ⋊ f = second f
                        f ⋉ id
                     a’×b            (f>>>f’) ⋉ id

                        f’ ⋉ id

                     a’’×b        a’’×b
premonoidal category

 f ⋉ id = first f     a×b          a×b
 id ⋊ f = second f
                        f ⋉ id
                     a’×b            (f>>>f’) ⋉ id

                        f’ ⋉ id

                     a’’×b        a’’×b
central

 f *** g ≡ first f >>> second g
 first f >>> second - = second - >>> first f
 first - >>> second f = second f >>> first -
           f central

 arr f   central

 f |x g ≡ first f >>> second (arr g)
 (                                     10.2)
Freyd category

                     premonoidal category


(central        central          )

           a -> b            Arrow a ↝ b
     arr              Freyd category
first   (   )
second              ***
 sub second {
 	 my $self = shift;
 	 my $swap = (ref $self)->arr(sub { $_[1], $_[0] });
 	 $swap->next($self->first)->next($swap);
 }



 sub parallel {
 	 my ($self, $arrow) = @_;
 	 $self->first->next($arrow->second);
 }

                     fst f >>> snd g
                       id        g
               C            C        D

                       f             id
               A              B            B
&&&
     sub split {
     	 my ($self, $arrow) = @_;
     	 (ref $self)->arr(sub {
     	 	 my $args = [@_];
     	 	 $args, $args;
     	 })->next($self->parallel($arrow));
     }

            A                                         A
                                                                  arr id
                                         arr id
                                                  arr <id, id>
     f                 g             A       arr π
                                                     A×A     arr π’
                                                                           A
            f &&&g               f                                             g
                                                          f *** g
                                             arr π               arr π’
B
    arr π
            B×C   arr π’
                           C         B               B×C                   C
(1):


Perl
f : A×B → C×D
(1):


first :: a × b × c -> d × e
 -> (a × b × c × y × z -> d × e × y × z)
                        5
(1):
 f                              (@v1 )
     sub first {
     	 my $self = shift;
     	 (ref $self)->arr(sub {
     	 	 my (@v1, @v2) = @_;
     	 	 $self->(@v1), @v2;
     	 });
     }




                 first              2
(A × B) × (C × D)
package Arrow::Subroutine;
use parent qw/Arrow/;

sub arr {
	 my ($class, $code) = @_;
	 bless $code, $class;
}

sub first {
	 my $self = shift;
	 (ref $self)->arr(sub {
	 	 my ($v1, $v2) = @_;
	 	 [$self->(@$v1)], $v2;
	 });
}

sub next {
	 my ($self, $arrow) = @_;
	 (ref $self)->arr(sub { $arrow->($self->(@_)) });
}
my $arr3 = Arrow::Subroutine->arr(sub { 3 });
my $arr4 = Arrow::Subroutine->arr(sub { 4 });
my $arrow_add = Arrow::Subroutine->arr(sub {
	 $_[0]->[0] + $_[1]->[0];
});
my $arr3_plus_4 = $arr3->split($arr4)->next($arrow_add);

print $arr3_plus_4->(), "n";


               3
                          π

         ()
               3 &&& 4               +
                         Int×Int             Int
                          π’
               4
(2):


              >>> arr

first
first
       a   π    a×c      π’    c


   f               f×return        return


           π              π’
   mb          mb×mc           mc
                  φ

               m(b×c)
package Arrow::Kleisli;
use parent qw/Arrow/;

sub _safe_name($) {
    my $name = shift;
    $name =~ s|::|__|g;
    return "__$name";
}

sub new_class {
    my $class = shift;
    my ($monad) = @_;

    my $class_name = "$class::" . _safe_name($monad);
    unless ($class_name->isa($class)) {
        no strict qw/refs/;
        @{"$class_name::ISA"} = ($class);
        *{"$class_name::monad"} = sub { $monad };
        *{"$class_name::new_class"} = sub {
            die "Don't call the new_class() method from sub classes.";
        };
    }

    return $class_name;
}

sub monad { die "Implement this method in sub classes" }
...
sub new {
	 my ($class, $kleisli) = @_;
	 bless $kleisli, $class;
}

sub arr {
	 my ($class, $code) = @_;
	 $class->new(sub {
	 	 $class->monad->unit($code->(@_));
	 });
}

sub next {
	 my ($self, $arrow) = @_;
	 (ref $self)->new(sub {
	 	 my @v = @_;
	 	 $self->(@v)->flat_map($arrow);
	 });
}
sub first {
	 my $self = shift;
	 my $class = (ref $self);
	 my $monad = $class->monad;

	   $class->new(sub {
	   	 my ($args1, $args2) = @_;
	   	 $monad->sequence(
	   	 	 $self->(@$args1)->map(sub {[@_]}),
	   	 	 $monad->unit(@$args2)->map(sub {[@_]}),
	   	 );
	   });
}
arr 10
                              arr π

     ()
          arr 10 &&& arr 2             div
                             Int×Int         Int
                              arr π’
            arr 2




div :: Int×Int ↝ Int = Int×Int → Maybe Int
my $class = Arrow::Kleisli->new_class('Data::Monad::Maybe');
my $arrow10 = $class->arr(sub { 10 });
my $arrow2 = $class->arr(sub { 2 });
my $arrow_div = $class->new(sub {
	 $_[1][0] == 0 ? nothing : just ($_[0][0] / $_[1][0]);
});
my $arrow10_div_2 = $arrow10->split($arrow2)-
>next($arrow_div);

my $maybe = $arrow10_div_2->();
print $maybe->is_nothing ? 'NOTHING' : $maybe->value;
print "n";
Arrows

Stream            Arrows
:
Arrows

 mm        join       return
                  m            id



           >>>         arr
 ↝⊗↝              ↝            Hom
(            )

            arr⊗id              id⊗arr
Hom⊗↝                ↝⊗↝                   ↝⊗Hom

                          >>>
        λ                              ρ

                      ↝
Arrows

first

LL       Arrows
http://d.hatena.ne.jp/m-hiyama/20111107/1320624410
Arrows in perl

More Related Content

What's hot

Python decorators
Python decoratorsPython decorators
Python decoratorsAlex Su
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python TricksBryan Helmig
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6garux
 
Python decorators (中文)
Python decorators (中文)Python decorators (中文)
Python decorators (中文)Yiwei Chen
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionosfameron
 
Decorators in Python
Decorators in PythonDecorators in Python
Decorators in PythonBen James
 
Python легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачиPython легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачиMaxim Kulsha
 
Pyimproved again
Pyimproved againPyimproved again
Pyimproved againrik0
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisaujihisa
 
Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smartlichtkind
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.VimLin Yo-An
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perlgarux
 
Python Fundamentals - Basic
Python Fundamentals - BasicPython Fundamentals - Basic
Python Fundamentals - BasicWei-Yuan Chang
 
Climbing the Abstract Syntax Tree (PHP UK 2018)
Climbing the Abstract Syntax Tree (PHP UK 2018)Climbing the Abstract Syntax Tree (PHP UK 2018)
Climbing the Abstract Syntax Tree (PHP UK 2018)James Titcumb
 
Climbing the Abstract Syntax Tree (Midwest PHP 2020)
Climbing the Abstract Syntax Tree (Midwest PHP 2020)Climbing the Abstract Syntax Tree (Midwest PHP 2020)
Climbing the Abstract Syntax Tree (Midwest PHP 2020)James Titcumb
 
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)James Titcumb
 

What's hot (20)

Python decorators
Python decoratorsPython decorators
Python decorators
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python Tricks
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
 
Python decorators (中文)
Python decorators (中文)Python decorators (中文)
Python decorators (中文)
 
Get on with Field API
Get on with Field APIGet on with Field API
Get on with Field API
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures edition
 
Decorators in Python
Decorators in PythonDecorators in Python
Decorators in Python
 
Arrays in php
Arrays in phpArrays in php
Arrays in php
 
Python легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачиPython легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачи
 
PHP 5.4
PHP 5.4PHP 5.4
PHP 5.4
 
Pyimproved again
Pyimproved againPyimproved again
Pyimproved again
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisa
 
Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smart
 
Part 7
Part 7Part 7
Part 7
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
 
Descobrindo a linguagem Perl
Descobrindo a linguagem PerlDescobrindo a linguagem Perl
Descobrindo a linguagem Perl
 
Python Fundamentals - Basic
Python Fundamentals - BasicPython Fundamentals - Basic
Python Fundamentals - Basic
 
Climbing the Abstract Syntax Tree (PHP UK 2018)
Climbing the Abstract Syntax Tree (PHP UK 2018)Climbing the Abstract Syntax Tree (PHP UK 2018)
Climbing the Abstract Syntax Tree (PHP UK 2018)
 
Climbing the Abstract Syntax Tree (Midwest PHP 2020)
Climbing the Abstract Syntax Tree (Midwest PHP 2020)Climbing the Abstract Syntax Tree (Midwest PHP 2020)
Climbing the Abstract Syntax Tree (Midwest PHP 2020)
 
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
 

Similar to Arrows in perl

循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなしMasahiro Honma
 
Functional Programming in PHP
Functional Programming in PHPFunctional Programming in PHP
Functional Programming in PHPpwmosquito
 
13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)Roman Brovko
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기JangHyuk You
 
Functional perl
Functional perlFunctional perl
Functional perlErrorific
 
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsTaking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsDavid Golden
 
Зависимые типы в GHC 8. Максим Талдыкин
Зависимые типы в GHC 8. Максим ТалдыкинЗависимые типы в GHC 8. Максим Талдыкин
Зависимые типы в GHC 8. Максим ТалдыкинЮрий Сыровецкий
 
Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Workhorse Computing
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongersbrian d foy
 
Document Classification In PHP
Document Classification In PHPDocument Classification In PHP
Document Classification In PHPIan Barber
 
Introduction to Monads in Scala (2)
Introduction to Monads in Scala (2)Introduction to Monads in Scala (2)
Introduction to Monads in Scala (2)stasimus
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language TriviaNikita Popov
 
AA Section 8-1
AA Section 8-1AA Section 8-1
AA Section 8-1Jimbo Lamb
 
Rのスコープとフレームと環境と
Rのスコープとフレームと環境とRのスコープとフレームと環境と
Rのスコープとフレームと環境とTakeshi Arabiki
 
PHP record- with all programs and output
PHP record- with all programs and outputPHP record- with all programs and output
PHP record- with all programs and outputKavithaK23
 

Similar to Arrows in perl (18)

循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなし
 
Math::Category
Math::CategoryMath::Category
Math::Category
 
Functional Programming in PHP
Functional Programming in PHPFunctional Programming in PHP
Functional Programming in PHP
 
Sigma type
Sigma typeSigma type
Sigma type
 
13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)13 - Scala. Dependent pair type (Σ-type)
13 - Scala. Dependent pair type (Σ-type)
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
 
Functional perl
Functional perlFunctional perl
Functional perl
 
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsTaking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order Functions
 
Зависимые типы в GHC 8. Максим Талдыкин
Зависимые типы в GHC 8. Максим ТалдыкинЗависимые типы в GHC 8. Максим Талдыкин
Зависимые типы в GHC 8. Максим Талдыкин
 
Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
Document Classification In PHP
Document Classification In PHPDocument Classification In PHP
Document Classification In PHP
 
Introduction to Monads in Scala (2)
Introduction to Monads in Scala (2)Introduction to Monads in Scala (2)
Introduction to Monads in Scala (2)
 
Key pat1 1-53
Key pat1 1-53Key pat1 1-53
Key pat1 1-53
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language Trivia
 
AA Section 8-1
AA Section 8-1AA Section 8-1
AA Section 8-1
 
Rのスコープとフレームと環境と
Rのスコープとフレームと環境とRのスコープとフレームと環境と
Rのスコープとフレームと環境と
 
PHP record- with all programs and output
PHP record- with all programs and outputPHP record- with all programs and output
PHP record- with all programs and output
 

More from Masahiro Honma

レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)Masahiro Honma
 
すべてが@__kanになる
すべてが@__kanになるすべてが@__kanになる
すべてが@__kanになるMasahiro Honma
 
Types and perl language
Types and perl languageTypes and perl language
Types and perl languageMasahiro Honma
 
カレーとHokkaidopm
カレーとHokkaidopmカレーとHokkaidopm
カレーとHokkaidopmMasahiro Honma
 
モナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gzモナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gzMasahiro Honma
 
モナモナ言うモナド入門
モナモナ言うモナド入門モナモナ言うモナド入門
モナモナ言うモナド入門Masahiro Honma
 
Hachioji.pm in Machida の LT
Hachioji.pm in Machida の LTHachioji.pm in Machida の LT
Hachioji.pm in Machida の LTMasahiro Honma
 
ウヰスキーとPSGI
ウヰスキーとPSGIウヰスキーとPSGI
ウヰスキーとPSGIMasahiro Honma
 
モデルから知るGit
モデルから知るGitモデルから知るGit
モデルから知るGitMasahiro Honma
 
YAPCレポートの舞台裏
YAPCレポートの舞台裏YAPCレポートの舞台裏
YAPCレポートの舞台裏Masahiro Honma
 
Stateモナドの解説 後編
Stateモナドの解説 後編Stateモナドの解説 後編
Stateモナドの解説 後編Masahiro Honma
 
Stateモナドの解説 中編
Stateモナドの解説 中編Stateモナドの解説 中編
Stateモナドの解説 中編Masahiro Honma
 
Stateモナドの解説 前編
Stateモナドの解説 前編Stateモナドの解説 前編
Stateモナドの解説 前編Masahiro Honma
 

More from Masahiro Honma (20)

レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)レンズ (ぶつかり稽古の没プレゼン)
レンズ (ぶつかり稽古の没プレゼン)
 
すべてが@__kanになる
すべてが@__kanになるすべてが@__kanになる
すべてが@__kanになる
 
Types and perl language
Types and perl languageTypes and perl language
Types and perl language
 
Currying in perl
Currying in perlCurrying in perl
Currying in perl
 
カレーとHokkaidopm
カレーとHokkaidopmカレーとHokkaidopm
カレーとHokkaidopm
 
モナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gzモナモナ言うモナド入門.tar.gz
モナモナ言うモナド入門.tar.gz
 
モナモナ言うモナド入門
モナモナ言うモナド入門モナモナ言うモナド入門
モナモナ言うモナド入門
 
Perl saved a lady.
Perl saved a lady.Perl saved a lady.
Perl saved a lady.
 
Levenshtein Automata
Levenshtein AutomataLevenshtein Automata
Levenshtein Automata
 
20120526 hachioji.pm
20120526 hachioji.pm20120526 hachioji.pm
20120526 hachioji.pm
 
Hachioji.pm in Machida の LT
Hachioji.pm in Machida の LTHachioji.pm in Machida の LT
Hachioji.pm in Machida の LT
 
ウヰスキーとPSGI
ウヰスキーとPSGIウヰスキーとPSGI
ウヰスキーとPSGI
 
モデルから知るGit
モデルから知るGitモデルから知るGit
モデルから知るGit
 
YAPCレポートの舞台裏
YAPCレポートの舞台裏YAPCレポートの舞台裏
YAPCレポートの舞台裏
 
Git入門
Git入門Git入門
Git入門
 
AnyEvent and Plack
AnyEvent and PlackAnyEvent and Plack
AnyEvent and Plack
 
Stateモナドの解説 後編
Stateモナドの解説 後編Stateモナドの解説 後編
Stateモナドの解説 後編
 
Stateモナドの解説 中編
Stateモナドの解説 中編Stateモナドの解説 中編
Stateモナドの解説 中編
 
Stateモナドの解説 前編
Stateモナドの解説 前編Stateモナドの解説 前編
Stateモナドの解説 前編
 
定理3
定理3定理3
定理3
 

Recently uploaded

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Recently uploaded (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Arrows in perl

  • 8.
  • 9. 10/18 YAPC::Asia 2011 Monads in Perl Perl Monad Future ( JSDeferred)
  • 10. 10/18 YAPC::Asia 2011 Monads in Perl Perl Monad Future ( JSDeferred)
  • 11. 10/18 YAPC::Asia 2011 Monads in Perl Perl Monad Future ( JSDeferred)
  • 12. Data::Monad my $result = Data::Monad::Base::Sugar::for { pick my $x => sub { scalar_list 1 .. 100 }; pick my $y => sub { scalar_list $x .. 100 }; pick my $z => sub { scalar_list $y .. ($x + $y > 100 ? 100 : $x + $y) }; satisfy { $x**2 + $y**2 == $z**2 }; yield { $x, $y, $z } };
  • 13. return >>= return :: a -> m a >>= :: m a -> (a -> m b) -> m b return >>=
  • 14. ma mb mb mc ma mc f >=> g == f >=> g a b b c a c ma ma mb ma mb return >=> f == f a a b a b
  • 15. (2) 2 fmap return join fmap :: a -> b -> (m a -> m b) join :: m (m a) -> m a
  • 16. (3)
  • 17. η⊗id id⊗η I⊗M M⊗M M⊗I μ λ ρ M
  • 18. ( ) 0×id id×0 (*, n) (0, n) (n, 0) (n, *) (+) π’ π n
  • 19. ( ) fmap return return id.fmap fmap.fmap fmap.id join id id fmap
  • 20. ( ) fmap return return id.fmap fmap.fmap fmap.id join id id fmap
  • 21.
  • 23. Monad Arrow (Haskell ) mb f a Arrows f :: m b c b a
  • 24. Arrows arr >>> first ↝ arr :: a -> b -> (a ↝ b) >>> :: (a ↝ b) -> (b ↝ c) -> (a ↝ c) first :: (a ↝ b) -> (a × c ↝ b × c)
  • 25. Arrow package Arrow; sub arr { my ($class, $code) = @_; die "not implemented"; } sub first { my $self = shift; die "not implemented"; } sub next { my ($self, $arrow) = @_; die "not implemented"; }
  • 26. first a↝b a b >>> arr ↝ a f b a arr f :: a ↝ b b g arr arr f >>> arr g :: a ↝ c arr g :: b ↝ c g.f c c
  • 27. first Arrow ↝ a c a×c f :: a↝b g :: c↝d f *** g :: a×c↝b×d b d b×d
  • 28. (f *** g) >>> (f’ *** g’) (f >>> f’) *** (g >>> g’) f g f g f’ g’ f’ g’
  • 29. (f *** g) >>> (f’ *** g’) (f >>> f’) *** (g >>> g’) f g f g f’ g’ f’ g’
  • 30. premonoidal category f ⋉ id = first f a×b a×b id ⋊ f = second f f ⋉ id a’×b (f>>>f’) ⋉ id f’ ⋉ id a’’×b a’’×b
  • 31. premonoidal category f ⋉ id = first f a×b a×b id ⋊ f = second f f ⋉ id a’×b (f>>>f’) ⋉ id f’ ⋉ id a’’×b a’’×b
  • 32. central f *** g ≡ first f >>> second g first f >>> second - = second - >>> first f first - >>> second f = second f >>> first - f central arr f central f |x g ≡ first f >>> second (arr g) ( 10.2)
  • 33. Freyd category premonoidal category (central central ) a -> b Arrow a ↝ b arr Freyd category
  • 34. first ( )
  • 35. second *** sub second { my $self = shift; my $swap = (ref $self)->arr(sub { $_[1], $_[0] }); $swap->next($self->first)->next($swap); } sub parallel { my ($self, $arrow) = @_; $self->first->next($arrow->second); } fst f >>> snd g id g C C D f id A B B
  • 36. &&& sub split { my ($self, $arrow) = @_; (ref $self)->arr(sub { my $args = [@_]; $args, $args; })->next($self->parallel($arrow)); } A A arr id arr id arr <id, id> f g A arr π A×A arr π’ A f &&&g f g f *** g arr π arr π’ B arr π B×C arr π’ C B B×C C
  • 37. (1): Perl f : A×B → C×D
  • 38. (1): first :: a × b × c -> d × e -> (a × b × c × y × z -> d × e × y × z) 5
  • 39. (1): f (@v1 ) sub first { my $self = shift; (ref $self)->arr(sub { my (@v1, @v2) = @_; $self->(@v1), @v2; }); } first 2 (A × B) × (C × D)
  • 40. package Arrow::Subroutine; use parent qw/Arrow/; sub arr { my ($class, $code) = @_; bless $code, $class; } sub first { my $self = shift; (ref $self)->arr(sub { my ($v1, $v2) = @_; [$self->(@$v1)], $v2; }); } sub next { my ($self, $arrow) = @_; (ref $self)->arr(sub { $arrow->($self->(@_)) }); }
  • 41. my $arr3 = Arrow::Subroutine->arr(sub { 3 }); my $arr4 = Arrow::Subroutine->arr(sub { 4 }); my $arrow_add = Arrow::Subroutine->arr(sub { $_[0]->[0] + $_[1]->[0]; }); my $arr3_plus_4 = $arr3->split($arr4)->next($arrow_add); print $arr3_plus_4->(), "n"; 3 π () 3 &&& 4 + Int×Int Int π’ 4
  • 42. (2): >>> arr first
  • 43. first a π a×c π’ c f f×return return π π’ mb mb×mc mc φ m(b×c)
  • 44. package Arrow::Kleisli; use parent qw/Arrow/; sub _safe_name($) { my $name = shift; $name =~ s|::|__|g; return "__$name"; } sub new_class { my $class = shift; my ($monad) = @_; my $class_name = "$class::" . _safe_name($monad); unless ($class_name->isa($class)) { no strict qw/refs/; @{"$class_name::ISA"} = ($class); *{"$class_name::monad"} = sub { $monad }; *{"$class_name::new_class"} = sub { die "Don't call the new_class() method from sub classes."; }; } return $class_name; } sub monad { die "Implement this method in sub classes" } ...
  • 45. sub new { my ($class, $kleisli) = @_; bless $kleisli, $class; } sub arr { my ($class, $code) = @_; $class->new(sub { $class->monad->unit($code->(@_)); }); } sub next { my ($self, $arrow) = @_; (ref $self)->new(sub { my @v = @_; $self->(@v)->flat_map($arrow); }); }
  • 46. sub first { my $self = shift; my $class = (ref $self); my $monad = $class->monad; $class->new(sub { my ($args1, $args2) = @_; $monad->sequence( $self->(@$args1)->map(sub {[@_]}), $monad->unit(@$args2)->map(sub {[@_]}), ); }); }
  • 47. arr 10 arr π () arr 10 &&& arr 2 div Int×Int Int arr π’ arr 2 div :: Int×Int ↝ Int = Int×Int → Maybe Int
  • 48. my $class = Arrow::Kleisli->new_class('Data::Monad::Maybe'); my $arrow10 = $class->arr(sub { 10 }); my $arrow2 = $class->arr(sub { 2 }); my $arrow_div = $class->new(sub { $_[1][0] == 0 ? nothing : just ($_[0][0] / $_[1][0]); }); my $arrow10_div_2 = $arrow10->split($arrow2)- >next($arrow_div); my $maybe = $arrow10_div_2->(); print $maybe->is_nothing ? 'NOTHING' : $maybe->value; print "n";
  • 49. Arrows Stream Arrows
  • 50. : Arrows mm join return m id >>> arr ↝⊗↝ ↝ Hom
  • 51. ( ) arr⊗id id⊗arr Hom⊗↝ ↝⊗↝ ↝⊗Hom >>> λ ρ ↝

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. &amp;#x3010;5&amp;#x5206;&amp;#x3011;\n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. &amp;#x3010;10&amp;#x5206;&amp;#x3011;\n
  25. \n
  26. &amp;#x9EC4;&amp;#x8272;&amp;#x306E;&amp;#x90E8;&amp;#x5206;&amp;#x304C;&amp;#x95A2;&amp;#x6570;&amp;#x3067;&amp;#x306F;&amp;#x306A;&amp;#x304F;&amp;#x578B;&amp;#x306A;&amp;#x306E;&amp;#x304C;&amp;#x30DD;&amp;#x30A4;&amp;#x30F3;&amp;#x30C8;&amp;#x3002;\n
  27. \n
  28. \n
  29. &amp;#x7D50;&amp;#x5408;&amp;#x5247;&amp;#x3092;&amp;#x6E80;&amp;#x305F;&amp;#x3059;&amp;#x3088;&amp;#x3046;&amp;#x306A;&amp;#x5B9A;&amp;#x7FA9;&amp;#x3092;&amp;#x3057;&amp;#x3066;&amp;#x304A;&amp;#x3044;&amp;#x305F;&amp;#x65B9;&amp;#x304C;&amp;#x53B3;&amp;#x5BC6;&amp;#x3060;&amp;#x3057;&amp;#x4F7F;&amp;#x3044;&amp;#x3084;&amp;#x3059;&amp;#x3044;\n
  30. \n
  31. &amp;#x3010;15&amp;#x5206;&amp;#x3011;\n
  32. \n
  33. &amp;#x4EFB;&amp;#x610F;&amp;#x306E;&amp;#x30A2;&amp;#x30ED;&amp;#x30FC;&amp;#x306B;&amp;#x5BFE;&amp;#x3057;&amp;#x3066;&amp;#x540C;&amp;#x3058;&amp;#x5B9F;&amp;#x88C5;&amp;#x304C;&amp;#x5229;&amp;#x7528;&amp;#x53EF;&amp;#x80FD;&amp;#x3002;&amp;#x62BD;&amp;#x8C61;&amp;#x5316;&amp;#x306E;&amp;#x52B9;&amp;#x529B;&amp;#x3002;\n
  34. &amp;#x4EFB;&amp;#x610F;&amp;#x306E;&amp;#x30A2;&amp;#x30ED;&amp;#x30FC;&amp;#x306B;&amp;#x5BFE;&amp;#x3057;&amp;#x3066;&amp;#x540C;&amp;#x3058;&amp;#x5B9F;&amp;#x88C5;&amp;#x304C;&amp;#x5229;&amp;#x7528;&amp;#x53EF;&amp;#x80FD;&amp;#x3002;&amp;#x62BD;&amp;#x8C61;&amp;#x5316;&amp;#x306E;&amp;#x52B9;&amp;#x529B;&amp;#x3002;\n
  35. \n
  36. \n
  37. \n
  38. &amp;#x3010;20&amp;#x5206;&amp;#x3011;\n
  39. \n
  40. \n
  41. \n
  42. &amp;#x30E2;&amp;#x30CA;&amp;#x30C9;&amp;#x3092;&amp;#x578B;&amp;#x30D1;&amp;#x30E9;&amp;#x30E1;&amp;#x30FC;&amp;#x30BF;&amp;#x3068;&amp;#x3057;&amp;#x3066;&amp;#x6271;&amp;#x3046;&amp;#x305F;&amp;#x3081;&amp;#x306E;&amp;#x304A;&amp;#x307E;&amp;#x3058;&amp;#x306A;&amp;#x3044;\n
  43. return&amp;#x3084;bind&amp;#x3092;arrow&amp;#x306E;&amp;#x8A00;&amp;#x8449;&amp;#x306B;&amp;#x7FFB;&amp;#x8A33;&amp;#x3057;&amp;#x3066;&amp;#x308B;&amp;#x3060;&amp;#x3051;\n
  44. &amp;#x3055;&amp;#x3063;&amp;#x304D;&amp;#x306E;&amp;#x56F3;&amp;#x3092;&amp;#x5143;&amp;#x306B;&amp;#x5B9F;&amp;#x88C5;&amp;#x3002;map&amp;#x306E;&amp;#x8FBA;&amp;#x308A;&amp;#x306F;&amp;#x578B;&amp;#x3092;&amp;#x305D;&amp;#x308D;&amp;#x3048;&amp;#x308B;&amp;#x304A;&amp;#x307E;&amp;#x3058;&amp;#x306A;&amp;#x3044;\n
  45. &amp;#x3010;25&amp;#x5206;&amp;#x3011;&amp;#x3088;&amp;#x304F;&amp;#x3042;&amp;#x308B;0&amp;#x9664;&amp;#x7B97;&amp;#x306E;&amp;#x4F8B;\n
  46. &amp;#x3088;&amp;#x304F;&amp;#x3042;&amp;#x308B;0&amp;#x9664;&amp;#x7B97;&amp;#x306E;&amp;#x4F8B;\n
  47. \n
  48. &amp;#x4E0A;&amp;#x306F;&amp;#x81EA;&amp;#x5DF1;&amp;#x95A2;&amp;#x624B;&amp;#x570F;&amp;#x3002;&amp;#x4E0B;&amp;#x306F;Profunctor&amp;#x306E;&amp;#x570F;&amp;#x3002;&amp;#x4E0B;&amp;#x306E;&amp;#x65B9;&amp;#x304C;&amp;#x9065;&amp;#x304B;&amp;#x306B;&amp;#x96E3;&amp;#x3057;&amp;#x304F;&amp;#x3066;&amp;#x3088;&amp;#x304F;&amp;#x308F;&amp;#x304B;&amp;#x3089;&amp;#x306A;&amp;#x3044;&amp;#x3002;&amp;#x7279;&amp;#x306B; &amp;#x2297;&amp;#x306E;&amp;#x5B9A;&amp;#x7FA9;\n
  49. \n
  50. \n
  51. \n
  52. \n