Subversion Repositories programming

Rev

Rev 70 | Blame | Compare with Previous | Last modification | View Log | RSS feed

irasnyd@duallie lisp $ cat hw09.lisp
;Written By: Ira Snyder
;Due Date: 02-14-2005
;Homework #: Hw09 (Exercise #13)

;;; My assumption on this homework is that you meant to
;;; mean that I should make an iterative version of NONE
;;; from Exercise 11 (HW06), not AL1 from Exercise 6.
(defun NONE (L)
  (do ((L L (cdr L))
       (NO 0)
       (NE 0))
      ((null L) (list NO NE))
    (if (oddp (car L)) (setf NO (1+ NO)) (setf NE (1+ NE)))
  )
)

irasnyd@duallie lisp $ clisp -q

[1]> (load 'hw09.lisp)
;; Loading file hw09.lisp ...
;; Loaded file hw09.lisp
T
[2]> (none nil)
(0 0)
[3]> (none '(3))
(1 0)
[4]> (none '(2))
(0 1)
[5]> (none '(3 1 4 1 5))
(4 1)
[6]> (bye)
irasnyd@duallie lisp $