Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.37 KB | None | 0 0
  1.  sub excepcionNegativo(Real $x) {
  2.      die "negative" if $x < 0;
  3.      $x.sqrt;
  4.  }
  5.  
  6.  for 5, -3 -> $n {
  7.      say "La raiz cuadrada del numero $n es: ", excepcionNegativo($n);
  8.  
  9.      CATCH {
  10.          when 'negative' {
  11.              say "No se puede calcular raiz cuadrada del numero $n"
  12.          }
  13.          default {
  14.              say "Hola";
  15.          }
  16.      }
  17.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement