Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Numerics;
- using System;
- using revision;
- public class Program
- {
- static void Main(String[] args)
- {
- // Quantifiers (All , Any, Contains) => return boolean var
- var lst = new List<int> { -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- //Console.WriteLine(lst.Any(x => x < 0));
- //Console.WriteLine(lst.All(x => x > 0));
- //Console.WriteLine(lst.Contains(5));
- // Partitioning (Skip, SkipWhile, Take, TakeWhile, Chunck)
- var result = lst.Skip(4).Take(4);
- result = lst.SkipWhile(x => x < 0);
- result = lst.TakeWhile(x => x < 0);
- //foreach(int x in result) Console.WriteLine(x);
- var chunks = lst.Chunk(3);
- //foreach (var chunk in chunks)
- //{
- // foreach (var item in chunk)
- // {
- // Console.Write($"{item} ");
- // }
- // Console.WriteLine();
- //}
- // Set Operations (Distinct, DistinctBy, Except, ExceptBy, Intersect, IntersectBy, Union, UnionBy)
- var A = new List<int> { 1, 1, 2, 3, 3, 4, 5, 6 };
- var B = new List<int> { 4, 5, 6, 7, 8, 9 };
- var C = A.Union(B);
- C = A.Intersect(B);
- C = A.Except(B);
- C = A.Distinct();
- foreach (int x in C) Console.WriteLine(x);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement