Last active
April 26, 2016 21:11
-
-
Save dogbert17/caa982701d8276c034a029a194c21eca to your computer and use it in GitHub Desktop.
Attempt to document the sum method in List.pm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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