Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active April 26, 2016 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/caa982701d8276c034a029a194c21eca to your computer and use it in GitHub Desktop.
Save dogbert17/caa982701d8276c034a029a194c21eca to your computer and use it in GitHub Desktop.
Attempt to document the sum method in List.pm
=head2 routine sum
Defined as:
multi sub sum($list) returns Numeric:D
multi method sum(List:D:) returns Numeric:D
Usage:
sum LIST
LIST.sum
Returns the sum of all elements in the list or 0 if the list is empty.
Throws an exception if an element can not be coerced into Numeric.
say (1, 3, pi).sum; # 7.14159265358979
say (1, "0xff").sum; # 256
say sum(0b1111, 5); # 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment