Subversion Repositories programming

Rev

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

Rev Author Line No. Line
63 irasnyd 1
Script started, file is hw02.script
2
irasnyd@duallie lisp $ cat hw02.lisp
3
;Written by: Ira Snyder
4
;Date:       01-13-2005
5
;Project #:  Hw 02
6
 
7
;define a function to calculate the result of the infix expression
8
; -b + sqrt( -b^2 - 4*a*c )
9
 
10
(defun QUAD-MINUS (A B C)
11
  (/ 
12
    (+ (- B) (sqrt (- (* B B) (* 4 A C))))
13
    (* 2 A)
14
  )
15
)
16
 
17
;define a function to calculate the result if the infix expression
18
; -b - sqrt( -b^2 - 4*a*c )
19
 
20
(defun QUAD-PLUS (A B C)
21
  (/ 
22
    (- (- B) (sqrt (- (* B B) (* 4 A C))))
23
    (* 2 A)
24
  )
25
)
26
 
27
;define a function that evaluates to a list containing both
28
;roots provided by the quadratic function
29
 
30
(defun QUAD2 (A B C)
31
  (list (QUAD-MINUS A B C) (QUAD-PLUS A B C))
32
)
33
 
34
irasnyd@duallie lisp $ clisp -q
35
 
36
[1]> (load 'hw02.lisp)
37
;; Loading file hw02.lisp ...
38
;; Loaded file hw02.lisp
39
T
40
[2]> (QUAD2 1 2 -8)
41
(2 -4)
42
[3]> (QUAD2 1 -2 1)
43
(1 1)
44
[4]> (quit)
45
irasnyd@duallie lisp $ exit
46
Script done, file is hw02.script