And interestingly enough Perl version can be almost the same, only without declarations:
use POSIX;
sub pk
{
print "$_[0]\n";
return ( \&pk, \&fabs )[ $_[0] / 1000 ]( $_[0] + 1 );
}
pk( 1 );