On Friday, 11 May 2012 at 23:51:47 UTC, Mehrdad wrote:
On Friday, 11 May 2012 at 21:53:06 UTC, Jonathan M Davis wrote:
I know that haskell has such a function, and there were a number of complaints previously that we _didn't_ have an any function which does exactly what std.algorithm.any now does. It's a very functional approach to use predicates like that and I get the impression that it's common in other functional languages based on other's comments. The only one off the top of my head that I _know_ has such a function though is haskell.


Again, I know enough FP to know what predicates are, and of
course, this is common in functional languages.

Even Scheme has a 'there-exists?' function just for this purpose.

I wasn't saying having "such a function" is weird -- I was just
asking if you know of any languages in which the NAME is "any()",
since I would've imagined it to be something more intuitive like
"exists()" or "contains" or "has" or whatever.
(I was giving C# as an example, because C# uses "Any()" to mean,
"are there any elements in this list?", NOT with the meaning D
uses.)

In .NET 3.5, and later, 'Any()' has an overload that takes a predicate so it behaves identical to 'any' in Haskell and D.

public static bool Any<TSource>(
        this IEnumerable<TSource> source,
        Func<TSource, bool> predicate
)

The Exists method is an older construct with a more limited application (List vs IEnumerable)

Reply via email to