Re: multiplying lists

2010-08-20 Thread Andrew Gwozdziewycz
On Thu, Aug 19, 2010 at 7:56 PM, Glen Rubin wrote: > > I want to multiply a list of n items by h lists of n items, so that > for example if i have list 'a' and 'b' > > (def a (list 1 2 3)) > (def b (list '(4 5 6) '(7 8 9))) > > when multiplied I will get: > > ((4 10 18) (7 16 27)) > Others have a

Re: multiplying lists

2010-08-19 Thread Meikel Brandmeyer
Hi, On 20 Aug., 01:56, Glen Rubin wrote: > I want to multiply a list of n items by h lists of n items, so that > for example if i have list 'a' and 'b' > > (def a (list 1 2 3)) > (def b (list '(4 5 6) '(7 8 9))) > > when multiplied I will get: > > ((4 10 18) (7 16 27)) And just to train myself

Re: multiplying lists

2010-08-19 Thread Btsai
This should work: (defn mult-list-by-lists [a b] (let [mult-lists (fn [x y] (map * x y))] (map #(mult-lists a %) b))) On Aug 19, 5:56 pm, Glen Rubin wrote: > I want to multiply a list of n items by h lists of n items, so that > for example if i have list 'a' and 'b' > > (def a (list 1 2 3)

Re: multiplying lists

2010-08-19 Thread Alan
Or if you want to avoid the #(...%...) syntax: user=> (def a (list 1 2 3)) #'user/a user=> (def b (list '(4 5 6) '(7 8 9))) #'user/b user=> (map (partial map * a) b) ((4 10 18) (7 16 27)) On Aug 19, 4:56 pm, Glen Rubin wrote: > I want to multiply a list of n items by h lists of n items, so that

Re: multiplying lists

2010-08-19 Thread wwmorgan
user=> (def a [1 2 3]) #'user/a user=> (def b [[4 5 6] [7 8 9]]) #'user/b user=> (map #(map * a %) b) ((4 10 18) (7 16 27)) - Will Morgan On Aug 19, 7:56 pm, Glen Rubin wrote: > I want to multiply a list of n items by h lists of n items, so that > for example if i have list 'a' and 'b' > > (def

Re: multiplying lists

2010-08-19 Thread David Nolen
On Thu, Aug 19, 2010 at 7:56 PM, Glen Rubin wrote: > > I want to multiply a list of n items by h lists of n items, so that > for example if i have list 'a' and 'b' > > (def a (list 1 2 3)) > (def b (list '(4 5 6) '(7 8 9))) > > when multiplied I will get: > > ((4 10 18) (7 16 27)) > Clojure make

multiplying lists

2010-08-19 Thread Glen Rubin
I want to multiply a list of n items by h lists of n items, so that for example if i have list 'a' and 'b' (def a (list 1 2 3)) (def b (list '(4 5 6) '(7 8 9))) when multiplied I will get: ((4 10 18) (7 16 27)) -- You received this message because you are subscribed to the Google Groups "Cloj