Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object Drugie extends App{
- def p(a:Int):Boolean={
- a % 2 == 0
- }
- def q(a:Int):Boolean={
- a % 3 == 0
- }
- def and[A](p: A=>Boolean, q: A=>Boolean): A=>Boolean ={
- (x:A) => (p(x) && q(x))
- }
- def or[A](p: A=>Boolean, q: A=>Boolean): A=>Boolean ={
- (x:A) => (p(x) || q(x))
- }
- def not[A](p: A=>Boolean): A=>Boolean ={
- (x:A) => !(p(x))
- }
- def imp[A](p: A=>Boolean, q: A=>Boolean): A=>Boolean = {
- (x:A) => (!(p(x)) || q(x))
- }
- and(p, q)(3)
- or(p,q)(3)
- not(p)(3)
- imp(p,q)(4)
- imp(p,q)(1)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement