Groups
Conversations
All groups and messages
Send feedback to Google
Help
Training
Sign in
Groups
tw.bbs.comp.lang.perl
Conversations
About
info
Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Learn more
[Raku] Range sum method
1 view
Skip to first unread message
Kang-min Liu
unread,
May 28, 2020, 10:27:37 AM
5/28/20
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
https://github.com/rakudo/rakudo/blob/master/src/core.c/Range.pm6#L630
昨天正好意識到,以 `+` 算符去將一串數字 1..$n 加總起來時:
my $sum = [+] 1..$n;
其實不必做 n-1 次加法,而是有個公式解: n(n+1)/2
稍後看了一下 Rakudo 源碼,發現此公式解已經實做在其中了。
😎 Cool
0 new messages