This language bar is your friend. Select your favorite languages!

Idiom #201 Euclidean norm

Calculate n, the Euclidean norm of data (an array or list of floating point values).

use Math::GSL::Vector qw();
use Math::GSL::BLAS qw(gsl_blas_dnrm2);
my $data = [5.0, 4.0, 3.0, 2.0, 1.0];
my $n = gsl_blas_dnrm2(Math::GSL::Vector->new($data)->raw);
n = norm2( data )
  data: array of double;
  n := norm(data);

Do you know the best way to do this in your language ?
New implementation...

Idiom created by