[Issue 12272] New: and(), or(), xor() to compose predicates
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 27 03:14:01 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12272
Summary: and(), or(), xor() to compose predicates
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2014-02-27 03:14:00 PST ---
In Java8 there are functions like and() or() xor() that are handy to compose
predicates:
Predicate<String> startsWithJ = (n) -> n.startsWith("J");
Predicate<String> fourLetterLong = (n) -> n.length() == 4;
names.stream().filter(startsWithJ.and(fourLetterLong))
In D:
auto startsWithJ = (string n) => n.startsWith("J");
auto fourLetterLong = (string n) => n.length == 4;
names.filter!(and!(startsWithJ, fourLetterLong))
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list