On Saturday, 12 May 2012 at 03:42:10 UTC, Ary Manzana wrote:
On 5/12/12 3:40 AM, Mehrdad wrote:
On Friday, 11 May 2012 at 20:20:36 UTC, Jonathan M Davis wrote:
That's definitely an example of something that depends on your
background. std.algorithm.any does _exactly_ what it would do
in a
functional language.
Well, I know some FP (Scheme/newLISP) but they don't have an
"any"
function. I don't know about F#, but my guess would be that it
would do
the same thing as C# would (for obvious reasons).
Are you thinking of a language in particular that has D's
behavior? Or
is this just a guess?
Ruby has any?:
http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-any-3F
And it's the best of the two worlds: given a block (a lambda)
it works like D. Give no lambda and it just returns true if the
enumerable has any elements.
Ruby wins again. :-P
This is in fact the exact behaviour of .NET's Any (on
IEnumerable). This is a library thing, not a language thing.