SHARE
TWEET

Functional Programming - 06. Reverse And Exclude(2)

gabi11 May 26th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7.  
  8. namespace CSharpAdvanced
  9. {
  10.  
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             var numbers = Console.ReadLine()
  16.                 .Split()
  17.                 .Select(int.Parse)
  18.                 .ToList();
  19.  
  20.             int n = int.Parse(Console.ReadLine());
  21.  
  22.             Predicate<int> divisibleBy = x => x % n != 0;
  23.  
  24.             Func<IEnumerable<int>, IEnumerable<int>> reverseFunc = x => x = x.Reverse();
  25.  
  26.             Console.WriteLine(string.Join(" ", reverseFunc(numbers).Where(x => divisibleBy(x))));
  27.         }
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top