Video: Generic Programming Galore using D @ Strange Loop 2011
bearophile
bearophileHUGS at lycos.com
Tue Apr 24 15:02:38 PDT 2012
Famous:
> bearophile:
>> Do you mean the min of a single item is the item itself?
>
> Yes.
>
>> This is right, but this case is better (more handy) left as
>> function overload to ask for the min of a single given
>> iterable.
>
> Would this transparantly work for an item and a set consisting
> of one item?
I think min(A,B,...) is the min between two or more items.
While min(A) is the min of the items of the iterable A.
This means:
min([1,2,3]) => 1
min([[1,2,3], [1,2,4]]) => [1,2,3]
min([[1,2,3]]) => [1,2,3]
It works with with two ore more items, and with a iterable that
contains one or more items.
In theory if you call min(1) it's able to see 1 is not an
iterable, so it must be a single item, so it is the min. But I
think this is a confusing special casing, that's better to avoid.
Bye,
bearophile
More information about the Digitalmars-d-announce
mailing list