Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

or even TMTOWTDI :)

Here in perl5i (https://metacpan.org/module/perl5i):

  func deriv ($f) {
      my $dx = 0.0001;
      func ($x) { ($f->($x + $dx) - $f->($x)) / $dx };
  }
  
  my $cube = func ($x) { $x ** 3 };
  say deriv($cube)->(2);
And also in perl6:

  sub deriv (Code $f) {
      my $dx = 0.0001;
      -> $x { ($f($x + $dx) - $f($x)) / $dx };
  }       
          
  my $cube = -> $x { $x ** 3 };
  say deriv($cube)(2);


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: