Re: challenge with vectors

2010-10-27 Thread Glen Rubin
awesome dude!!! Thanks for the book recommendation...I'll take a look at those when I can. Right now I am just eager to get my code working ;) On Oct 27, 1:18 pm, Aravindh Johendran wrote: > On Oct 27, 8:24 am, Glen Rubin wrote: > > > wow, i think you just went way over my head.  First off a v

Re: challenge with vectors

2010-10-27 Thread Glen Rubin
wow, i think you just went way over my head. First off a very naive question: I thought all clojure programming was functional, as long as you are not using refs, agents, or other mutable values etc...?? On Oct 27, 12:26 am, Aravindh Johendran wrote: > What kind of an answer are you looking

Re: challenge with vectors

2010-10-26 Thread Aravindh Johendran
What kind of an answer are you looking for? Just the quickest way to do it? Do you want an "idiomatic" clojure solution or are you learning functional programming using clojure? There are many ways to do this. Others have provided cool solutions. Here's a way of doing it if you are interested in f

Re: challenge with vectors

2010-10-26 Thread Btsai
Is it ok if the index starts at 0? (use '[clojure.contrib.seq :only (indexed)]) (defn get-min-and-index [coll] (apply min-key #(second (second %)) (indexed coll))) user=> (get-min-and-index [[22 5] [56 8] [99 3] [43 76]]) [2 [99 3]] On Oct 26, 7:54 pm, Glen Rubin wrote: > I have a sequence l

Re: challenge with vectors

2010-10-26 Thread Stuart Campbell
On 27 October 2010 12:54, Glen Rubin wrote: > I have a sequence like this: > > [ [a b] [a b] [a b] [a b] ] > > where a and b are numbers. I would like to return the vector and its > index for which b is the least in this collection. > > For example, if my data is as follows > > [ [22 5] [56 8] [

challenge with vectors

2010-10-26 Thread Glen Rubin
I have a sequence like this: [ [a b] [a b] [a b] [a b] ] where a and b are numbers. I would like to return the vector and its index for which b is the least in this collection. For example, if my data is as follows [ [22 5] [56 8] [99 3] [43 76] ] I would like to return 3rd vector in the coll