Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.61 KB | None | 0 0
  1. object Drugie extends App{
  2.  
  3.  
  4.     def p(a:Int):Boolean={
  5.         a % 2 == 0
  6.     }
  7.      def q(a:Int):Boolean={
  8.         a % 3 == 0
  9.     }
  10.  
  11.     def and[A](p: A=>Boolean, q: A=>Boolean): A=>Boolean ={
  12.         (x:A) => (p(x) && q(x))
  13.     }
  14.  
  15.     def or[A](p: A=>Boolean, q: A=>Boolean): A=>Boolean ={
  16.         (x:A) => (p(x) || q(x))
  17.     }
  18.  
  19.     def not[A](p: A=>Boolean): A=>Boolean ={
  20.         (x:A) => !(p(x))
  21.     }
  22.     def imp[A](p: A=>Boolean, q: A=>Boolean): A=>Boolean = {
  23.         (x:A) => (!(p(x)) || q(x))
  24.     }
  25.  
  26.     and(p, q)(3)
  27.     or(p,q)(3)
  28.     not(p)(3)
  29.     imp(p,q)(4)
  30.     imp(p,q)(1)
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement