Depending on your use, you may want to deal with a sequence that is
empty or is length 1.  Right now there's an uncaught exception in that
case:

user=> (arithmetic-progression? [1])
java.lang.IllegalArgumentException: Wrong number of args (0) passed to: 
core$-EQ- (NO_SOURCE_FILE:0)

Brian

On Tue, Mar 08, 2011 at 10:26:24AM -0500, Fred Concklin wrote:
> Tests whether list is arithmetic progression.
>
> (defn arithmetic-progression? [intlist]
>   "tests if list is arithmetic progression."
>   (apply =
>    (map
>     #(apply - %)
>     (partition 2 1 (reverse intlist)))))

Attachment: pgpMFPtPoIOjO.pgp
Description: PGP signature

Reply via email to