lisp function questions
- From: dan655t@xxxxxxxxx
- Date: 29 Sep 2005 09:42:40 -0700
Hi I am a newbie to lisp and need some help with my functions. I need
to write a function that:
takes 3 integer arguments representing the coefficients of ax^2 +bx +c
and finds the solutions for ax^2 +bx +c = 0. The return value will be a
a list with first element (-b + sqrt(b^2 - 4ac))/2a and second element
(-b - sqrt(b^2 -4ac))/2a.
If the roots are repeated, please list the root just once.
here is my work so far. It is lacking the second part which I'm looking
for a way to implement.
(defun QROOT (a b c)
(/ (+ (- b) (sqrt ( - (* b b) (* 4 a c)))) (* 2 a))
(/ (- (- b) (sqrt ( - (* b b) (* 4 a c)))) (* 2 a))
)
My other function I am having trouble with is:
a function that goes through a list and calculates the average of all
numerica entries that appear somewhere inside the list.
(defun average (m)
(/ (+ m) (length m))
)
But I have to only count numeric entries. Also I do not think I am
taking the sum of the list correctly. Any help would be greatly
appreciated. Thanks!
.
- Follow-Ups:
- Re: lisp function questions
- From: josephoswaldgg@xxxxxxxxxxx
- Re: lisp function questions
- From: Joe Marshall
- Re: lisp function questions
- From: Pascal Bourguignon
- Re: lisp function questions
- Prev by Date: Re: The joy of garbage collection
- Next by Date: Re: What's so great about lisp?
- Previous by thread: The joy of garbage collection
- Next by thread: Re: lisp function questions
- Index(es):