That's a good one, on par with the one line low-pass filter: ;; filter noise ;;(http://clojure-log.n01se.net/date/2009-10-13.html by ambient ;;this is such a cool transform!!!
(defn lo-pass [d coll] (reductions #(+ (* %2 d) (* %1 (- 1.0 d))) coll)) sincerely, --Robert McIntyre On Thu, Feb 3, 2011 at 4:46 PM, Ken Wesson <kwess...@gmail.com> wrote: > On Thu, Feb 3, 2011 at 4:33 PM, Base <basselh...@gmail.com> wrote: >> Thats the one! >> >> Now I just have to understand it... >> >> The first apply is throwing me a little. > > Start with > > (map foo [1 2 3] [4 5 6] [7 8 9]) > > That calls foo with the first elements of the collections (so, 1 4 7), > then again with the second (2 5 8), and then the third (3 6 9). > > Now, if foo is vector the return values will be [1 4 7], [2 5 8], and > [3 6 9]. Which are the rows of your transposed matrix. > > (apply map vector matrix) > > does (map foo row1 row2 row3) in the case of a three-row matrix, for > instance, and more generally should extract the columns of any matrix. > > (vec ...) wrapped around it converts the seq return value into a vector. > > Note that (vec '(1 2 3)) => [1 2 3]; (vector 1 2 3) => [1 2 3], i.e. > (vec foo) = (apply vector foo). > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en