Re: novice question, performance surprise

2012-02-11 Thread Sean Corfield
On Sat, Feb 11, 2012 at 5:46 PM, Sean Corfield wrote: > You can get a doctoring D**n you autocorrect! :) You can get a docstring... -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the g

Re: novice question, performance surprise

2012-02-11 Thread Cedric Greevey
On Sat, Feb 11, 2012 at 8:46 PM, Sean Corfield wrote: > On Sat, Feb 11, 2012 at 4:22 PM, Cedric Greevey wrote: >> Cute, but that makes giving it a docstring, pre- and postconditions, >> and similar things a pain. > > You can get a doctoring and even arglists (for code assist in your IDE > and for

Re: novice question, performance surprise

2012-02-11 Thread Sean Corfield
On Sat, Feb 11, 2012 at 4:22 PM, Cedric Greevey wrote: > Cute, but that makes giving it a docstring, pre- and postconditions, > and similar things a pain. You can get a doctoring and even arglists (for code assist in your IDE and for clojure.repl/doc): (def ^{:arglists '([pred coll]) } separate

Re: novice question, performance surprise

2012-02-11 Thread Cedric Greevey
On Sat, Feb 11, 2012 at 7:05 PM, Alan Malloy wrote: > (def separate (juxt filter remove)). Cute, but that makes giving it a docstring, pre- and postconditions, and similar things a pain. > It's in old-contrib, I think in clojure.contrib.seq-utils or > something. Obviously not recommended for use

Re: novice question, performance surprise

2012-02-11 Thread Alan Malloy
(def separate (juxt filter remove)). It's in old-contrib, I think in clojure.contrib.seq-utils or something. Obviously not recommended for use in new programs. On Feb 11, 3:49 pm, Cedric Greevey wrote: > On Sat, Feb 11, 2012 at 4:44 PM, Jules wrote: > > There is a standard library function for

Re: novice question, performance surprise

2012-02-11 Thread Cedric Greevey
On Sat, Feb 11, 2012 at 4:44 PM, Jules wrote: > There is a standard library function for this: separate. Not according to clooj's tab completion, http://clojure.org/cheatsheet, or http://clojure.github.com/clojure/ -- none of those match any library function to the substring "sep", and the third

Re: novice question, performance surprise

2012-02-11 Thread Jules
There is a standard library function for this: separate. For example (separate even? coll) returns two results in a vector: (filter even? coll) and (filter odd? coll). On Feb 10, 9:05 pm, Manuel Paccagnella wrote: > On 02/09/2012 11:40 PM, Steve Miner wrote: > > > filter is lazy so it won't actua

Re: novice question, performance surprise

2012-02-10 Thread Manuel Paccagnella
On 02/09/2012 11:40 PM, Steve Miner wrote: filter is lazy so it won't actually do the work unless the values are needed. To get a reasonable time, you need to use the result for some computation. Try something like this: (defn sum-all [m] (reduce + (apply map + (vals m (time (sum-all (s

Re: novice question, performance surprise

2012-02-09 Thread Steve Miner
filter is lazy so it won't actually do the work unless the values are needed. To get a reasonable time, you need to use the result for some computation. Try something like this: (defn sum-all [m] (reduce + (apply map + (vals m (time (sum-all (separate-nums (range 1 On Feb 9, 201

novice question, performance surprise

2012-02-09 Thread Manuel Paccagnella
Sorry for what I guess is a pretty basic question. I've written for practice a simple function that takes a sequence of numbers and returns a map with the odd and even ones. No big deal: (defn separate-nums [coll] (hash-map :even (filter even? coll) :odd (filter odd? coll))) But I th