-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathday1.lisp
33 lines (29 loc) · 898 Bytes
/
day1.lisp
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
(in-package :cs325-user)
(define-test match-p
(assert-true (match-p '? 'a))
(assert-true (match-p 'a 'a))
(assert-false (match-p 'b 'a))
(assert-true (match-p '() '()))
(assert-true (match-p '(?) '(a)))
(assert-false (match-p '(?) '(a b)))
(assert-true (match-p '? '(a b)))
(assert-true (match-p '(? b ?) '(a b c)))
(assert-false (match-p '((?)) '((a b))))
(assert-true (match-p '((? ?)) '((a b))))
(assert-false (match-p '(? ?) '((a b))))
(assert-false (match-p '(?) '()))
(assert-true (match-p '? '()))
(assert-false (match-p '(?) 'a))
)
(defun my-equal (x y)
(cond ((atom x) (eql x y))
((atom y) nil)
((my-equal (car x) (car y))
(my-equal (cdr x) (cdr y)))
(t nil)))
(defun match-p (x y)
(cond ((eql x '?) t)
((atom x) (eql x y))
((atom y) nil)
((not (= (length x) (length y))) nil)
(t nil)))