-
Notifications
You must be signed in to change notification settings - Fork 0
/
proper-list.lisp
29 lines (26 loc) · 995 Bytes
/
proper-list.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
#+quicklisp (ql:quickload "cl-yautils" :silent t)
#-quicklisp (load "cl-yautils.lisp" :print nil)
(import 'cl-yautils::proper-list)
;; Simulate a main function.
(defun main ()
;; Test against an empty list.
(assert (equal '() (proper-list '())))
;; Test against a dotted pair.
(assert (equal '(a b) (proper-list (cons 'a 'b))))
;; Test against a proper list.
(assert (equal '(a b c d) (proper-list '(a b c d))))
;; Test against a list with a trailing dotted pair.
(assert (equal '(a b c d)
(proper-list (cons 'a
(cons 'b
(cons 'c 'd))))))
;; Test against a list with non-trailing dotted pairs.
(assert (equal '(a b c d e f g)
(proper-list
(cons (cons 'a 'b)
(cons 'c
(cons (cons 'd 'e)
(cons 'f 'g)))))))
(quit))
;; Call the main function.
(main)