aboutsummaryrefslogtreecommitdiff
path: root/Semestr 2/racket/lista5/props.bak
blob: 1a5659a2c74f6c4f3351a79bc96ab895d005f16d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#lang racket

(provide var?
         neg?
         conj?
         disj?
         conj
         disj
         neg
         conj-left
         conj-right
         disj-right
         disj-left
         neg-subf)
; (require "solution.rkt")

(define (var? t) (symbol? t))

(define (neg? t)
  (and (list? t)
       (= 2 (length t))
       (eq? 'neg (car t))))

(define (conj? t)
  (and (list? t)
       (= 3 (length t))
       (eq? 'conj (car t))))

(define (disj? t)
  (and (list? t)
       (= 3 (length t))
       (eq? 'disj (car t))))

(define (lit? t)
  (or (var? t)
      (and (neg? t)
           (var? (neg-subf t)))))

(define (conj left right)
  (list 'conj left right))

(define (disj left right)
  (list 'disj left right))

(define (neg f)
  (list 'neg f))

(define (conj-left f)
  (if (conj? f)
      (cadr f)
      (error "Złe dane ze znacznikiem -- CONJ-LEFT" f)))

(define (conj-right f)
  (if (conj? f)
      (caddr f)
      (error "Złe dane ze znacznikiem -- CONJ-RIGHT" f)))

(define (disj-left f)
  (if (disj? f)
      (cadr f)
      (error "Złe dane ze znacznikiem -- DISJ-LEFT" f)))

(define (disj-right f)
  (if (disj? f)
      (caddr f)
      (error "Złe dane ze znacznikiem -- DISJ-RIGHT" f)))

(define (neg-subf f)
  (if (neg? f)
      (cadr f)
      (error "Złe dane ze znacznikiem -- NEG-FORM" f)))