help me.....
function....arithmetic and geometric progressions......
For example.....
(next '(2 4 6 8))
10
(next '(4 -12 36 -108))
324
(next '(3 1 4 1))
unknown
how make this function next......??
nogarder.
"Kim Yongsik" <········@lycos.co.kr> writes:
> (next '(2 4 6 8))
> 10
>
> (next '(4 -12 36 -108))
> 324
>
> (next '(3 1 4 1))
> unknown
>
> how make this function next......??
I'll start you off. First, write a couple of predicate functions
which just test if a sequence is geometic so far, and likewise for
arirthmetic. These are easy tests (i.e. ratios and differences,
respectively). Have the predicates return either the ratio/difference
or NIL if they don't satisfy. Then apply the rule to the last
element.
Your functions might look like:
(defun arithmetic-p (numbers)
...)
(defun geometic-p (numbers)
...)
(defun arithmetic-next (number difference)
...)
(defun geometic-next (number ration)
...)
dave