Subversion Repositories programming

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
65 irasnyd 1
irasnyd@duallie lisp $ cat hw05.lisp
2
;;; Written By: Ira Snyder
3
;;; Due Date:   Wed 02-02-2005
4
;;; Homework #: HW05
5
 
6
;;;
7
;;; Count the number of numbers in an arbitrary
8
;;; depth expression
9
;;;
10
(defun COUNT# (E)
11
  (cond
12
    ((numberp E) 1)
13
    ((atom E)    0)
14
    (t           (+ (COUNT# (car E))
15
                    (COUNT# (cdr E))))
16
  )
17
)
18
 
19
irasnyd@duallie lisp $ clisp -q
20
 
21
[1]> (load 'hw05.lisp)
22
;; Loading file hw05.lisp ...
23
;; Loaded file hw05.lisp
24
T
25
[2]> (COUNT# nil)
26
 
27
[3]> (COUNT# 3)
28
1
29
[4]> (COUNT# 'a)
30
 
31
[5]> (COUNT# '(5 1 a 4))
32
3
33
[6]> (COUNT# '((1 1 (a)) 7 (b (3))))
34
4
35
[7]> (bye)
36
irasnyd@duallie lisp $
37