Minimum value in a vector

2009-12-02 Thread Don
I am having difficulty approaching this problem. I'm not sure if it can be done in one swoop, or requires a few steps. I have 5 vectors as such: a [2 4 6 7] b [1 3 9 2] c [2 4 5 6] d [6 1 3 8] e [4 8 2 1] And I want to take the minimum value at a given index between the vectors. Therefore,

Re: Minimum value in a vector

2009-12-02 Thread Wilson MacGyver
assuming, vector a b c d e are already defined. I'd do user= (map vector a b c d e) ([2 1 2 6 4] [4 3 4 1 8] [6 9 5 3 2] [7 2 6 8 1]) you can then use the solutions provided from previous messages to find the min value of each vector. so you then end up with [0 1 0 0 0] [0 0 0 1 0] [0 0 0 0

Re: Minimum value in a vector

2009-12-02 Thread John Harrop
On Wed, Dec 2, 2009 at 5:43 PM, Don josereyno...@gmail.com wrote: I am having difficulty approaching this problem. I'm not sure if it can be done in one swoop, or requires a few steps. I have 5 vectors as such: a [2 4 6 7] b [1 3 9 2] c [2 4 5 6] d [6 1 3 8] e [4 8 2 1] And I want to

Re: Minimum value in a vector

2009-12-02 Thread Wilson MacGyver
it in a vector [1 1 2 1] And I don't know from what vector the minimum value is coming from. The solution is probably already here but I can't think of it.  Sorry. On Dec 2, 3:40 pm, Wilson MacGyver wmacgy...@gmail.com wrote: assuming, vector a b c d e are already defined. I'd do user

Re: Minimum value in a vector

2009-12-02 Thread Chouser
On Wed, Dec 2, 2009 at 6:22 PM, Don josereyno...@gmail.com wrote: Thank you Stefan and Kevin.  Awesome solutions that answer my question.  However I actually made a mistake in posing my question. Let me attempt to ask my question again.  I have 5 vectors as such:  a [2 4 6 7]  b [1 3

Re: Minimum value in a vector

2009-12-02 Thread Don
Thanks to everyone for the solutions. I actually wrote this terribly ugly function. Terrible. This should go in the don't write code like this section in clojure book. (defn md2 [d1 d2 d3 d4 d5] (let [cnt (count d1)] (loop [i 0 v []] (if (= i cnt) v (do (if (=