daily pastebin goal
6%
SHARE
TWEET

Untitled

a guest Mar 18th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
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