On Saturday, 28 July 2012 at 14:36:26 UTC, Ali Çehreli wrote:
On 07/28/2012 06:49 AM, Philip Daniels wrote:
> It seems to
> be something to do with whether the array is static or
dynamic.
Good catch! :) Welcome to D where static arrays (aka
"fixed-length arrays") and dynamic arrays (aka "slice
On 07/28/2012 07:36 AM, Ali Çehreli wrote:
> reduce() is an algorithm that not more than an InputRange.
That should be:
reduce() is an algorithm that _does not require_ more than an InputRange.
(That is also misleading: reduce() requires an "iterable object", which
can be any type of a range,
On 07/28/2012 06:49 AM, Philip Daniels wrote:
> It seems to
> be something to do with whether the array is static or dynamic.
Good catch! :) Welcome to D where static arrays (aka "fixed-length
arrays") and dynamic arrays (aka "slices") are different beasts.
A number of factors are at play her
On Saturday, 28 July 2012 at 10:58:45 UTC, bearophile wrote:
Philip Daniels:
cannot implicitly convert expression (_param_1) of type
WordDatabase.WordTable to int
That error tells you to not use an int as first value for the
reduce. Maybe this is enough to solve your problem.
Bye,
bearophi
Philip Daniels:
cannot implicitly convert expression (_param_1) of type
WordDatabase.WordTable to int
That error tells you to not use an int as first value for the
reduce. Maybe this is enough to solve your problem.
Bye,
bearophile
On Saturday, 28 July 2012 at 08:32:57 UTC, Jonathan M Davis wrote:
void main()
{
auto stuff = ["hello world",
"Goodbye, Shirley",
"Babylon 5 rocks"];
auto result = reduce!"a + b.length"(0L, stuff);
assert(result == join(stuff).length);
}
The first
On Saturday, July 28, 2012 09:58:32 Philip Daniels wrote:
> I have an array of objects that have a size() property. Code to
> sum them manually works fine, as expected:
>
>auto total = 0;
>foreach (wt; _word_tables)
> total += wt.size();
>return total;
>
>
> How can I do this wi
I have an array of objects that have a size() property. Code to
sum them manually works fine, as expected:
auto total = 0;
foreach (wt; _word_tables)
total += wt.size();
return total;
How can I do this with reduce? (BTW I second the old comments and
bugs about not having sum() built