
# sburke@cpan.org    Time-stamp: "2005-08-19 01:09:27 ADT"
# desc{  Perl implementation of a Y operator  }
#        around a recursive function that figures out factorials:

print
sub {
  my $n = $_[0];
  sub {
    # Y operator
    my $fact = $_[0];
    $fact->$fact($n);
  }->(
    sub {
      # factorial function:
      my($self, $k) = @_;
      die if $k < 1;
      $k == 1
        ? 1
        : ($k * $self->($self, $k-1))
    }
  )
}->(
  # Number we want the factorial of:
  10
);

