Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
リストが日付順に並べられているときに、リストに x オブジェクトが連続して含まれている場合に true を返す linq クエリのヘルプが必要です。
このように:
myList.InARow(x => x.Correct, 3)
プロパティ correct == true を持つ行が 3 つある場合、true を返します。
これを行う方法がわからない。
更新日:
myList.Aggregate(0, (result, x) => (result >= 3) ? result : (x.Correct ? result + 1 : 0), result => result >= 3);
一般化されたバージョン:
myList.Aggregate(0, (result, x) => (result >= length) ? result : (filter(x) ? result + 1 : 0), result => result >= length);