Subversion Repositories programming

Rev

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

Script started, file is hw02.script
irasnyd@duallie lisp $ cat hw02.lisp
;Written by: Ira Snyder
;Date:       01-13-2005
;Project #:  Hw 02

;define a function to calculate the result of the infix expression
; -b + sqrt( -b^2 - 4*a*c )

(defun QUAD-MINUS (A B C)
  (/ 
    (+ (- B) (sqrt (- (* B B) (* 4 A C))))
    (* 2 A)
  )
)

;define a function to calculate the result if the infix expression
; -b - sqrt( -b^2 - 4*a*c )

(defun QUAD-PLUS (A B C)
  (/ 
    (- (- B) (sqrt (- (* B B) (* 4 A C))))
    (* 2 A)
  )
)

;define a function that evaluates to a list containing both
;roots provided by the quadratic function

(defun QUAD2 (A B C)
  (list (QUAD-MINUS A B C) (QUAD-PLUS A B C))
)

irasnyd@duallie lisp $ clisp -q

[1]> (load 'hw02.lisp)
;; Loading file hw02.lisp ...
;; Loaded file hw02.lisp
T
[2]> (QUAD2 1 2 -8)
(2 -4)
[3]> (QUAD2 1 -2 1)
(1 1)
[4]> (quit)
irasnyd@duallie lisp $ exit
Script done, file is hw02.script