thanks!
On 25 February 2010 15:28, fra wrote:
> Hi,
>
> I have a small improvement.
> The function / called with only argument returns the inverse, so you
> can define g-mean and h-mean more shortly:
>
> (defn g-mean [coll]
> (expt (reduce * coll) (/ (count coll
>
> (defn h-mean [coll] ;;
Hi,
I have a small improvement.
The function / called with only argument returns the inverse, so you
can define g-mean and h-mean more shortly:
(defn g-mean [coll]
(expt (reduce * coll) (/ (count coll
(defn h-mean [coll] ;; Michael Kohl's function
(/ (count coll) (reduce + (map / coll)))
here is the final version of the implementation.
http://gist.github.com/313558
again, any thought would be great.
Aviad.
On 22 February 2010 22:11, Aviad Reich wrote:
> I don't mean to signal the end of this thread, but I just wanted to thank
> you all for you replies.
> I will update the draf
I don't mean to signal the end of this thread, but I just wanted to thank
you all for you replies.
I will update the draft (and add Colin and Mikel's infinite seq code as
well) possible in a day or two (no at home till then), and post the new code
before posting to Rosetta.
Cheers,
Aviad
On 22 F
On Mon, Feb 22, 2010 at 11:43 AM, Johnny Kwan wrote:
> Whichever is faster depends on the size of the argument list
I see, thanks for clarifying. I'd then change my version to this since
I still like map with an anonymous function more than the
for-comprehension in this case.
defn h-mean [coll]
Hi,
On Feb 22, 11:43 am, Johnny Kwan wrote:
> (time (reduce + (range 1 1000))) ; 4.5 secs on my Macbook Air
> (time (apply + (range 1 1000))) ; OutOfMemory error
Ah. It holds unto the head.
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups
Hi,
On Feb 22, 2010, at 1:43 AM, Meikel Brandmeyer wrote:
> Hi,
>
> On Feb 22, 12:18 am, Johnny Kwan wrote:
>> I'm really new to Clojure, but I'm under the impression that reduce would
>> be better than apply, since I assume that apply would reify the entire
>> sequence at once, whereas reduce
Hi,
On Feb 22, 2:30 am, trptcolin wrote:
> I do have a feeling I'm missing something really obvious that would
> make my example simpler, so if anybody has any tips I'd be much
> obliged!
Using OP's code:
(let [numbers (take 1000 (fibs))]
(println (a-mean numbers) ">=" (g-mean numbers) ">="
Hi,
On Feb 22, 12:18 am, Johnny Kwan wrote:
> I'm really new to Clojure, but I'm under the impression that reduce would
> be better than apply, since I assume that apply would reify the entire
> sequence at once, whereas reduce would consume the sequence one by one.
> Could someone more familiar
Aviad,
Nice job! One nitpick is that won't work for infinite sequences,
since reduce isn't lazy. If you wanted your definitions to work for
arbitrary indexes of infinite sequences (like the Fibonacci numbers),
you could provide sequences providing successive results for the input
sequences.
I d
On Mon, Feb 22, 2010 at 12:18 AM, Johnny Kwan wrote:
> I'm really new to Clojure, but I'm under the impression that reduce would be
> better than apply, since I assume that apply would reify the entire sequence
> at once, whereas reduce would consume the sequence one by one.
I was going by this
I'm really new to Clojure, but I'm under the impression that reduce would be
better than apply, since I assume that apply would reify the entire sequence at
once, whereas reduce would consume the sequence one by one. Could someone more
familiar with the implementation weigh in on this?
On Feb
On Sun, Feb 21, 2010 at 9:41 PM, Aviad Reich wrote:
> ANY comments will be great (including: this is all wrong - don't
> post it).
FWIW since I'm not exactly an expert on idiomatic Clojure either, I'd
write h-mean like this:
(defn h-mean [coll]
(/ (count coll) (apply + (map #(/ 1 %) coll
Hi everyone,
being a newb to clojure, my ability to contribute to is still limited.
However, I thought I'll try starting with something simple.
http://rosettacode.org/wiki/Averages/Pythagorean_means seems straightforward
enough, but since it's a comparative site, and implementations should be as
14 matches
Mail list logo