Sha256: eb5868c90c941253417d179244c61066c0872296d196f91e01784879ebf97b01
Contents?: true
Size: 428 Bytes
Versions: 323
Compression:
Stored size: 428 Bytes
Contents
package Example; use strict; use warnings; use List::Util 'sum'; sub new { my ($class, $to) = @_; return bless { to => $to }, $class; } sub sum_of_squares { my $self = shift; return sum map { $_ ** 2 } 1..$self->{to}; } sub square_of_sums { my $self = shift; return (sum 1..$self->{to}) ** 2; } sub difference { my $self = shift; return $self->square_of_sums - $self->sum_of_squares; } 1;
Version data entries
323 entries across 323 versions & 1 rubygems