What's missing from Phobos for Orbit (package manager)
Walter Bright
newshound2 at digitalmars.com
Thu Feb 14 01:46:32 PST 2013
On 2/14/2013 12:12 AM, Jacob Carlborg wrote:
> On 2013-02-13 21:19, Walter Bright wrote:
>
>> The any in std.algorithm is defined:
>>
>> --------------
>> bool any(alias pred, Range)(Range range);
>>
>> Returns true if and only if a value v satisfying the predicate pred can
>> be found in the forward range range. Performs Ο(r.length) evaluations of
>> pred.
>> --------------
>>
>> I see that as very different from !empty.
>
> But if you use a predicate that always returns true that would be basically the
> same. At least for arrays.
>
> int[] a = [];
> assert(a.any!(e => true) == false);
>
> int[] b = [3, 4, 5];
> assert(b.any!(e => true) == true);
I don't understand why one would go around the horn to just check for !empty.
More information about the Digitalmars-d
mailing list