#clojure logs

2008-07-14

13:11Chousersometimes you just need reduce, because you can't do this with apply:
13:11Chouser(defn sum-of-squares [s] (reduce (fn [a b] (+ a (* b b))) 0 s))
13:11Chouserunless you do it like this:
13:11Chouser(defn sum-of-squares [s] (apply + (map #(* % %) s)))
13:12Chouser...which is clearer, shorter, and lazy. hmm...
13:12abrooksHeh.
13:15rhickeysome seqs have an internal reduce, which will be much faster than apply
13:16Chouser(reduce (fn [m v] (assoc m v (str v "_val"))) {} '(a b c d))
13:16Chouser(into {} (map #(vector % (str % "_val")) '(a b c d)))
13:16Chouserrhickey: really? that's interesting.
13:18cemerickThat's *very* interesting.
13:19Chouserwith new variadic conj: (apply conj {} (map #(vector % (str % "_val")) '(a b c d)))
13:20cemerickrhickey: thanks for the quick turnaround on the outstanding topics :-)
13:20rhickeyyes, since for some data structures there's a perf benefit in not creating a general-purpose seq
13:20rhickeycemerick: sure
13:21cemerickI think it's a pretty good sign overall that the worst/best I can come up with are patches handling exit codes and reflection-warning filenames
18:53rhickeyhttp://clojure.org/Contributing - any thoughts?
21:55abrooksrhickey: "Contributing" looks good. On a semi-related note, is it too early to consider a more formalized enhancement forum similar to Python Enhancement Proposals (PEPs)? This could help focus some of the questions., suggestions and effort. Perhaps it's too early but those sorts of things are often added too late.
22:12rhickeyabrooks: I'm sure we can add more formality later, but I'm interesting in seeing what develops naturally before adopting an existing system (not that there's anything wrong with PEPs)
22:13abrooksThat sounds good.
22:18albinoPEPs mostly developed out of guido getting tired of saying "already rejected", he could just reference PEPs after that