43 lines
1.6 KiB
Plaintext
43 lines
1.6 KiB
Plaintext
;; Function To Be Tested: prog2
|
|
;;
|
|
;; Source: Steele's book Section 7.4: simple sequencing Page: 109
|
|
;;
|
|
;; Created By: Karin M. Sye
|
|
;;
|
|
;; Creation Date: May 29, 1986
|
|
;;
|
|
;; Last Update: May 29, 1986
|
|
;;
|
|
;; Filed As: {eris}<lispcore>cml>test>7-4-prog2.test
|
|
;;
|
|
;;
|
|
;; Syntax: PROG2 first second {form}*
|
|
;;
|
|
;; Function Description: PROG2 takes a number of forms and evaluates them sequentially. It discards the results
|
|
;; of all forms but the second one and returns the value of the second form.
|
|
;;
|
|
;; Argument(s): first - first form
|
|
;; second - second form
|
|
;; {form}* - the rest of forms
|
|
;;
|
|
;; Returns: value of the second form
|
|
;;
|
|
(do-test test-prog20
|
|
(and (eq (prog2 1 2 3 4 5 6) 2)
|
|
(eq (prog2 (defmacro mac (x) `(gcd ,x 20 30)) (mac 10) (mac 40)) 10)
|
|
(eq (prog2 (defun fun (x) (nth x '(foo bar gack tank bush moon fish))) (fun 2) (fun 5) (fun 0)) 'gack)
|
|
(eq (prog2 (rplaca (setq x '((a . b) c d (e. f))) 'foo) (car (rplaca x 'fish)) (car (rplaca x 'ham))
|
|
(list x)) `fish)))
|
|
|
|
(do-test test-prog21
|
|
;;
|
|
;; - prog2 always returns a single value, even if the second form tries to return multiple values. - p110
|
|
;;
|
|
(and (eq (prog2 nil (values 2 4 6 8)) 2)
|
|
(eq (prog2 (defmacro mac (x) `(values-list (list ,x 'p 'q))) (mac 'a) (mac 'w) (mac 'o)) 'a)
|
|
(eq (prog2 (defun fun () (values (signum 10) (signum -9) (max 2 2.0 1.9999999 2.000009))) (fun) (fmakunbound 'fun))
|
|
1)))
|
|
;;
|
|
;;
|
|
STOP
|
|
|