Next You can't get there from here 35

Squares

        sub calculates_squares {
          my $code = shift;
          ... returns true if and only if $code is a function
              for computing squares ...
        }
        sub halts {
          my ($source_code, $input) = @_;
          my $newcode = 'sub { my $n = shift;
                                my $f = eval "CODE";
                                $f->("INPUT");
                                return $n * $n;
                               }';
          $newcode =~ s/CODE/$source_code/;
          $newcode =~ s/INPUT/$input/;
          return calculates_squares($newcode);
        }        

Next Copyright © 2005 M. J. Dominus