:
यह इस तरह कोड लिखने की अनुमति देता है। इसके लिए सी ++ 11 की आवश्यकता है (हालांकि यह एमएसवीसी 2010 में काम करेगा) और बूस्ट। पुस्तकालय के साथ आप इस तरह LINQ प्रश्नों लिख सकते हैं:
struct student_t
{
std::string last_name;
std::vector<int> scores;
};
std::vector<student_t> students =
{
{"Omelchenko", {97, 72, 81, 60}},
{"O'Donnell", {75, 84, 91, 39}},
{"Mortensen", {88, 94, 65, 85}},
{"Garcia", {97, 89, 85, 82}},
{"Beebe", {35, 72, 91, 70}}
};
auto scores = LINQ(from(student, students)
from(score, student.scores)
where(score > 90)
select(std::make_pair(student.last_name, score)));
for (auto x : scores)
{
printf("%s score: %i\n", x.first.c_str(), x.second);
}
कौन सा होगा उत्पादन:
Omelchenko score: 97
O'Donnell score: 91
Mortensen score: 94
Garcia score: 97
Beebe score: 91
स्रोत
2012-06-07 12:04:46
क्या आपका मतलब मोनैड (IENumerable <> और विस्तार विधियों का सेट) है? क्या इसका मतलब इसका भाषा पहलू है? क्या आपका मतलब LINQ-to-SQL है? – yfeldblum
वैसे LINQ-SQL भाग वह हिस्सा है जो मैं वास्तव में चाहता हूं, लेकिन यह LINQ की भाषा और monads पर निर्भर करता है। –