-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbool.rkt
More file actions
43 lines (34 loc) · 949 Bytes
/
bool.rkt
File metadata and controls
43 lines (34 loc) · 949 Bytes
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
#lang webracket
(#%provide true false false?
boolean=?
symbol=?
; implies nand nor
xor)
; (#%require (for-syntax racket/base))
(define true #t)
(define false #f)
(define (false? v) (eq? v #f))
(define (boolean=? x y)
(unless (and (boolean? x) (boolean? y))
(raise-argument-error 'boolean=? "boolean?" (if (boolean? x) 1 0) x y))
(eq? x y))
(define (symbol=? x y)
(unless (and (symbol? x) (symbol? y))
(raise-argument-error 'symbol=? "symbol?" (if (symbol? x) 1 0) x y))
(eq? x y))
#;(define-syntax (implies stx)
(syntax-case stx ()
[(implies x y)
(syntax/loc stx (if x y #t))]))
#;(define-syntax (nor stx)
(syntax-case stx ()
[(_ expr ...) (syntax/loc stx (not (or expr ...)))]))
#;(define-syntax (nand stx)
(syntax-case stx ()
[(_ expr ...) (syntax/loc stx (not (and expr ...)))]))
(define (xor a b)
(if a
(if b
#f
a)
b))