Re: arithmetic progression

2011-03-08 Thread Fred Concklin
Thanks! fpc -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send e

Re: arithmetic progression

2011-03-08 Thread Ken Wesson
On Tue, Mar 8, 2011 at 2:28 PM, Alan wrote: > On Mar 8, 10:27 am, Ken Wesson wrote: >> On Tue, Mar 8, 2011 at 10:42 AM, Chris Perkins >> wrote: >> > You'll probably want to add checks for special cases, like an empty or >> > one-element sequence, too. >> >> Better yet, clojure.core should amend

Re: arithmetic progression

2011-03-08 Thread Alan
On Mar 8, 10:27 am, Ken Wesson wrote: > On Tue, Mar 8, 2011 at 10:42 AM, Chris Perkins > wrote: > > You'll probably want to add checks for special cases, like an empty or > > one-element sequence, too. > > Better yet, clojure.core should amend = so that (=) and (= x) return > true instead of thr

Re: arithmetic progression

2011-03-08 Thread Ken Wesson
On Tue, Mar 8, 2011 at 10:42 AM, Chris Perkins wrote: > You'll probably want to add checks for special cases, like an empty or > one-element sequence, too. Better yet, clojure.core should amend = so that (=) and (= x) return true instead of throwing an arity exception. That would make the behavio

Re: arithmetic progression

2011-03-08 Thread Brian Martin
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) B

Re: arithmetic progression

2011-03-08 Thread Chris Perkins
On Mar 8, 10:26 am, Fred Concklin wrote: > Tests whether list is arithmetic progression. > > Thoughts, feedback: > > (defn arithmetic-progression? [intlist] >   "tests if list is arithmetic progression." >   (apply = >    (map >     #(apply - %) >     (pa

arithmetic progression

2011-03-08 Thread Fred Concklin
Tests whether list is arithmetic progression. Thoughts, feedback: (defn arithmetic-progression? [intlist] "tests if list is arithmetic progression." (apply = (map #(apply - %) (partition 2 1 (reverse intlist) fpc -- You received this message because you are sub