diff src/rlm/web_stuff.clj @ 0:78a630e650d2

initial import
author Robert McIntyre <rlm@mit.edu>
date Tue, 18 Oct 2011 00:57:08 -0700
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/rlm/web_stuff.clj	Tue Oct 18 00:57:08 2011 -0700
     1.3 @@ -0,0 +1,19 @@
     1.4 +(ns rlm.web-stuff)
     1.5 +
     1.6 +
     1.7 +;;(from http://www.mail-archive.com/clojure@googlegroups.com/msg31123.html
     1.8 +(defn convolve [ns ms]
     1.9 +  (let [ns (vec ns), ms (vec ms),
    1.10 +	count-ns (count ns), count-ms (count ms)]
    1.11 +    (loop [n 0,
    1.12 +	   y (transient (vec (repeat (dec (+ count-ns count-ms)) 0)))]
    1.13 +      (if (= n count-ns) (persistent! y)
    1.14 +	  (recur (inc n)
    1.15 +		 (loop [m 0, y y]
    1.16 +		   (if (= m count-ms) y
    1.17 +		       (let [n+m (+ n m)]
    1.18 +			 (recur (inc m) (assoc! y n+m
    1.19 +						(+ (y n+m) (* (ns n) (ms
    1.20 +								      m)))))))))))));;)
    1.21 +
    1.22 +