From: Kim Yongsik
Subject: arithmetic and geometric progressions function.......
Date: 
Message-ID: <yfID5.1167$Es4.6110@news2.bora.net>
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.
From: David Bakhash
Subject: Re: arithmetic and geometric progressions function.......
Date: 
Message-ID: <m2vgv4d0fa.fsf@cadet.dsl.speakeasy.net>
"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