[Issue 12562] New: std.algorithm.mul
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 11 14:32:56 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12562
Issue ID: 12562
Summary: std.algorithm.mul
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
I suggest to add a function "mul" similar to std.algorithm.sum to std.algorithm
that computes the product of the given range:
void main() {
import std.stdio, std.range, std.algorithm, std.bigint;
reduce!((a, b) => a * b)(1, iota(1, 10)).writeln; // 362_880
iota(1, 10).mul.writeln; // The same result.
iota(1, 10).mul(1.0).writeln; // The same result, but of type double.
BigInt[] a;
a.mul.writeln; // Should print 1
}
--
More information about the Digitalmars-d-bugs
mailing list