Re: Practical Clojure
I need to clarify something, since I unintentionally introduced confusion into this discussion. The initial comment by faenvie referred to the book "Practical Clojure", a very good book (I own a copy). I spaced out and thought that faenvie's comment concerned the newly released "Clojure Programming". I threw in my two bits, and a link to a promotional release of some material from CP. I apologize for my carelessness. My enthusiasm for CP got the best of me. Disclaimer: I have no financial or other stake in any of these books. I speak only as an appreciative reader. We are fortunate that the Clojure community is well served by several excellent books. -- 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
Re: Practical Clojure
I have not read it all (yet), but what I have read is outstanding. O'Reilly has made the table of contents and first chapter available online. If you are at all curious, check it out. The first chapter contains an exceptionally lucid and thorough section on destructuring. http://cdn.oreilly.com/oreilly/booksamplers/9781449394707_sampler.pdf -- 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
Re: What's the efficient functional way to computing the average of a sequence of numbers?
> "Very likely" strikes me as a huge overstatement here. Most sequences > that you want to average won't be source-code literals, they'll be > lazy sequences, and those aren't counted Point taken about lazy sequences. But the above was not intended to suggest the sequence needs to be source code literal to satisfy 'counted?', rather that vectors, lists, maps, and sets do so. That covers a fair bit of ground. -- 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
Re: What's the efficient functional way to computing the average of a sequence of numbers?
On Thu, Mar 29, 2012 at 12:18 AM, simon.T wrote: > The obvious way is like the following, which traverse the sequence 2 times. > ... The obvious way does not necessarily traverse the sequence twice. If a sequence S satisfies the 'counted?' predicate, (count S) takes constant time. In particular user=> (counted? [:a :b :c]) true user=> (counted? '(:a :b :c)) true user=> (counted? {:a 1 :b 2 :c 3}) true user=> (counted? #{:a :b :c}) true The examples are stolen from: http://clojuredocs.org/clojure_core/clojure.core/counted_q So it is very likely that (/ (reduce + coll) (count coll)) will not traverse 'coll' twice, and the natural way is the preferred way. -- 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
Re: ANN: Marginalia v0.7.0
Fogus, congratulations on the release. My thanks to you and all the contributors. Marginalia rules. -- 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
Re: Korma - cannot acquire connections
This worked for me, with mysql 5.1 on Ubuntu Natty. The clojure_test library and fruit table already existed. (ns foo.core (use [korma.db]) (use [korma.core])) (defdb mydb {:subprotocol "mysql" :subname "//127.0.0.1:3306/clojure_test" :user "clojure_test" :password "clojure_test"}) (defentity fruit (database mydb) (table :fruit)) (select fruit) -- 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
Re: Clojure Conj extracurricular activities spreadsheet
Please add me to the 'Literate Programming' and 'Heroku Drinking' sessions. -- 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
A Leiningen configuration question
There are dev dependencies (Marginalia, swank-clojure) that I want added to every new Leiningen project. Is there a way to configure lein so that these are automatically inserted into the project.clj file on project creation? Thank you, David -- 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
Re: How often do you use REPL?
My standard practice is to split the (Emacs) screen, one side is a Clojure mode edit session, the other a repl. Best of both worlds. One can easily build up complex expressions as required, and still easily evaluate expressions in either side of the screen. If you are not familiar with Emacs and want to see how this works, check out Craig Andera's screencasts at http://www.pluralsight-training.net/microsoft/olt/course/toc.aspx?n=clojure-concurrency-tutorial . He uses the same approach. These screencasts are well worth watching, BTW. Good stuff. On Sep 27, 3:14 pm, Christian Guimaraes wrote: > It's a noob question... I know > > But in my studies I use REPL 80% of the coding time. > > More advanced users still uses REPL so many times? -- 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
Re: concurrency example about java x clojure
> > > The fact that currently having vals and keys return seqs in the same > > order is not guaranteed by the documentation ? At the recent Pragmatic Studio class I asked Rich and Stuart about this very point. As I recall, Rich said vals and keys do behave as one would hope, so that for a map m we can count on (zipmap (keys m) (vals m)) being equal to m. Again, as I recall the plan is to eventually update the documentation to reflect this. David -- 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
Re: Announcement: secrets of monad fu, revealed
"Easy to grok" is music to my ears. I imagine most people who read my post would skip the proofs, and that is just fine. The proofs are gruntwork. I wouldn't want the tedious details to obscure the idea of the monad, which is quite elegant once you get your head around it. On Mon, Sep 6, 2010 at 9:53 AM, Eivind Magnus Hvidevold wrote: > > I liked it. Easy to grok. > I had some vague idea that monads are like "overloading the pipe operator in > a function pipeline", but now it's much clearer. > I know some abstract algebra, though not category theory. > I skipped the proofs, didn't care about those. -- 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
Announcement: secrets of monad fu, revealed
I had too much time on my hands, and put together a Clojure-based monad tutorial. If that kind of thing is your cup of tea, I'd love to get some feedback on it. Here's the link http://erl.nfshost.com/2010/09/05/bind-unit-and-all-that-2/ David -- 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
Re: clojure-conj registration is now open!
Yesterday I paid for my ticket, and scheduled a vacation day for Oct 22. Looking forward to it. -- 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
Re: looking for a simpler implementation of a function I'm using
> conj sounds like 'append' to me which I have no idea about the > performance characteristics in clojure(it is a no-no in F#, Haskell ++ > is better but would grow the stack). conj is not the same as append; it will insert the new element in the smart (most efficient) way. For instance: user> (conj '(1 2 3) 0) (0 1 2 3) user> (conj [1 2 3] 0) [1 2 3 0] There is no performance hit from using conj to insert at the end of a vector. -- 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
Re: looking for a simpler implementation of a function I'm using
Using a vector instead of a list as the accumulator makes it possible to skip the mapping of reverse used in the earlier version of pw: (defn pw [f? x] (let [phi (fn [a e] (if (f? e) (cons [e] a ) (cons (conj (first a) e) (rest a] (reverse (reduce phi [] x -- 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
Re: looking for a simpler implementation of a function I'm using
On Sat, Aug 7, 2010 at 9:36 PM, gary ng wrote: > if you don't mind about performance, this seems to be natural to me > > user=> (reverse (map reverse (reduce (fn [a e] (if (even? e) (cons [e] a) > (cons > (cons e (first a)) (rest a (list) [1 2 3 7 5 4 1]))) > ((1) (2 3 7 5) (4 1)) I reworked that a bit, to parameterize it: (defn pw [f? x] (let [phi (fn [a e] (if (f? e) (cons [e] a) (cons (cons e (first a)) (rest a] (reverse (map reverse (reduce phi () x) This is in the same family as my version 2, but I think it is much cleaner. This approach gets rid of the recursion, a definite win. Thanks, Gary. -- 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
looking for a simpler implementation of a function I'm using
Here are a couple of implementations of a function I'm calling 'partition-when'. I feel like there should be a simpler way than either of these. If you have one, I'd love to see it. (defn partition-when;;version 1 "Partition a sequence into subsequences; begin a new subseq whenever the predicate f? returns true. Example: (partition-when even? [ 1 2 3 7 5 4 1]) returns [[1] [2 3 7 5] [4 1]]." [f? ys] (let [xs (vec ys) indices (positions f? xs) ;; uses clojure.contrib.seq-utils/positions n (count xs)] (->> (concat [0] indices [n]) (distinct) ;; handle possible repeated leading zero (partition 2 1) (map #(apply (partial subvec xs) %) (defn partition-when;; version 2 [f? xs] (when (seq xs) (loop [ys(rest xs) work [(first xs)] accum []] (if (empty? ys) (conj accum work) (let [y (first ys)] (if (f? y) (recur (rest ys) [y] (conj accum work)) (recur (rest ys) (conj work y) accum ))) Speed is no big deal for me; the sequences I'm handling are short, say about length100. BTW, one of these is considerably faster than the other for longish sequences. Can you guess which? What I'm looking for is a natural, conceptually clean approach. Thanks, David -- 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
Re: Leiningen and loading hooks
Phil, Just a personal opinion, but I'd urge you not to worry too much about breaking changes just yet. The future value of doing the right thing now outweighs the value of backwards compatibility in an application as young as Lein. To answer your direct question, I would not be affected by a requirement that hooks be declared in project.clj. Actually, I think there are advantages to explicit declarations. David -- 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
Re: filtering with multiple predicates
Here's an approach that doesn't use macros. I'm not sure I'd actually do this, but here it is just for grins. (defn bind [pred] (fn [[x bool]] [x (and (pred x) bool)])) (defn comp# [ & preds ] (let [ phi (reduce comp (map bind preds))] (fn [x] (second (phi [x true]) user> (filter (comp# even? pos? #(zero? (rem % 3)) ) (range -30 30)) (6 12 18 24) -- 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
Re: filtering with multiple predicates
Alex, Very slick; I really liked that. Thank you for posting it . David On Fri, Jul 23, 2010 at 6:33 PM, ataggart wrote: > Not that preserves the short-circuiting behavior of 'and. This works > though: > > (defmacro andf [& fns] > (let [x# (gensym)] > `(fn [~x#] (and ~@(map #(list % x#) fns) -- 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
Re: gobble up a collection 2 at a time
Here's my take: (defn mmap [f coll] (->> coll (partition 2) (map (fn [[x y]] (f x y) For instance: user> (mmap + (range 8)) (1 5 9 13) user> (mmap * (range 8)) (0 6 20 42) You probably want to think about whether you'll see input sequences with an odd number of terms, and how best to handle them. -- 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
Re: A functional, efficient, convolution function. Is imperitive-style the answer?
I thought this problem was interesting enough to merit better treatment than I can give it here, hence a blog post was in order. Brief version: I think I have a lazy, functional, and idiomatic implementation with decent performance. Check it out here: http://erl.nfshost.com/2010/07/17/discrete-convolution-of-finite-vectors/ -- 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
Re: A functional, efficient, convolution function. Is imperitive-style the answer?
I tried to run Jame's code, but the compiler (1.2 beta) squawked at me: Unable to resolve symbol: indexed in this context [Thrown class java.lang.Exception] What do I need to pull in to pick up the "indexed" function? On Sat, Jul 17, 2010 at 5:08 AM, James Reeves wrote: > Perhaps something like this? > > (defn convolve [ns ms] > (loop [nums (for [[i n] (indexed ns) > [j m] (indexed ms)] [(+ i j) (+ n m)]) > y (transient (vec (repeat (+ (count ns) (count ms)) 0)))] > (if-let [[i s] (first nums)] > (recur (next nums) (assoc! y i (+ (y i) s))) > (persistent! y -- 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
Re: Can anyone create a simpler version of prime factors in Clojure?
I looked through some of my Project Euler solutions and found this version. It is essentially the same as Uncle Bob's, but to my eye it is a bit easier to read. (defn least-nontrivial-divisor [n];; integer n > 1 (loop [k 2] (cond (zero? (rem n k)) k ;; k divides n, return k (> (* k k) n ) n ;; k > sqrt n, return n :else (recur (inc k) (defn prime-factors [n];; integer n > 1 (loop [n n factors []] (if (= 1 n) factors (let [d (least-nontrivial-divisor n)] (recur (quot n d) (conj factors d)) -- 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
Re: Clojure Conference Poll
+1 DC -- 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
Re: How can I parse this with clojure.contrib.zip-filter.xml ?
James, That worked beautifully. I knew it had to be simple, but I was drawing a total blank. Thank you, David. On Fri, Jan 22, 2010 at 9:53 PM, James Reeves wrote: > On Jan 23, 2:29 am, David Cabana wrote: >> What I'd like to get from 'tickets' is something like ( ["Alice" >> ["foo"]] ["Bob" ["bar" "baz"]]), that is, output that ties incidents >> to customers. So far it has eluded me. > > "xml->" just returns a sequence of matches. If you want nested > matches, you'll need to put another loop in. Perhaps something like: > > (defn tickets [xml] > (for [ticket (zf/xml-> xml :ticket)] > [(zf/xml1-> ticket :customer zf/text) > (zf/xml-> ticket :item zf/text)])) > > That should work, but I haven't had the opportunity to test it, so > forgive me if I'm wrong! :) > > - James > > -- > 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
How can I parse this with clojure.contrib.zip-filter.xml ?
I have been fooling around with clojure.contrib.zip-filter.xml, and feel like I'm stuck on something that should be simple. Below is code showing what I'm talking about. I'm trying to parse some simple xml, but can't quite get what I'm after. (ns foo (:require [clojure.xml :as xml]) (:require [clojure.zip :as zip]) (:require [clojure.contrib.zip-filter.xml :as zf])) ;; read and parse xml string (defn parse-str [s] (zip/xml-zip (xml/parse (new org.xml.sax.InputSource (new java.io.StringReader s) ;; illustrative xml string (def incidents (parse-str " Alice foo Bob bar baz ")) (defn customers [xml] (zf/xml-> xml :ticket :customer zf/text)) (defn items [xml] (zf/xml-> xml :ticket :item zf/text)) (defn tickets [xml] ;; not quite right (zf/xml-> xml :ticket zf/text)) ;; ;;(items incidents) yields ("foo" "bar" "baz") ;;(customers incidents) yields ("Alice" "Bob") ;;(tickets incidents)yields ("Alicefoo" "Bobbarbaz") ;; What I'd like to get from 'tickets' is something like ( ["Alice" ["foo"]] ["Bob" ["bar" "baz"]]), that is, output that ties incidents to customers. So far it has eluded me. If you can offer any suggestions, I'd sure appreciate it. David -- 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
Re: Processing list more elegantly
If speed matters, I found both of these to be faster than the version using reductions. First version is to roll my own replacement for reductions, specialized to addition: (defn partial-sums [coll] (loop [result [0] tot 0 terms coll] (if (empty? terms) result (let [next (+ tot (first terms))] (recur (conj result next) next (rest terms)) (defn left-tot1 [lst] (map vector lst (partial-sums lst))) Even faster is this one, which is something along the lines of one of you original versions, but without a list reversal. (defn left-tot2 [lst] (loop [result [ ] tot 0 terms lst] (if (empty? terms) result (let [f (first terms)] (recur (conj result [f tot]) (+ tot f) (rest terms)) On Sun, Dec 27, 2009 at 9:22 PM, Conrad wrote: > ...for some reason, however, this version is a lot slower than my 3 > versions of the code- Not sure if it's the laziness of this version, > or if there's stuff being put on the call stack by "reductions"... > -- 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
Re: Processing list more elegantly
Try this: (use '[clojure.contrib.seq-utils :only (reductions)]) (defn left-total [lst] (map vector lst (reductions + (cons 0 lst On Sun, Dec 27, 2009 at 8:36 PM, Conrad wrote: > I've been writing Clojure code today and have noticed the same pattern > show up multiple times, but can't find an elegant way to code it in > idiomatic Clojure. I feel like I'm missing an obvious solution... > anyone else see something I don't? Thanks in advance! > > The problem boils down to the following minimal example: Suppose you > want to write a function "left-total" which takes a list of number and > returns pairs of said numbers, along with the total of numbers to the > left: > > => (left-total [3 5 10 1 2 7]) > ([3 0] [5 3] [10 8] [1 18] [2 19] [7 21]) > > I can think of several ways to write this function. Three acceptable > versions of this function are written below, but all of them are > hideous looking. Is there a better solution? (Note that any solution > should avoid thrashing the stack or performing more than the minimum > number of additions.) -- 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
Can a function determine it's own name at runtime?
Suppose we define a function called sq: (defn sq [x] (do (println "sq") (* x x))) I wanted sq to print it's own name when run; to make it do so I inserted the name as a string. Is there some way to dynamically determine the name and so avoid using the string? Similarly, is it possible to define a function name-of so that (name-of sq) returns "sq", etc ? Thank you, drc -- 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
Re: Funding Clojure 2010
For years I have complained about the parts of java I don't like, and lamented the stagnation of lisp. I never imagined anyone could simultaneously attack both issues so beautifully and so successfully. Bravo. I have yet to make a dime using Clojure, but hope to some day. So as a Christmas present for myself, I sent in my donation. Thanks for your amazing work Rich. -- 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
Re: Matlab for Lisp programmers?
If clean syntax really matters to you, you might want to take a look at Mathematica. Its syntax is extremely simple and regular, very lispy. Check out this link: http://reference.wolfram.com/mathematica/tutorial/EverythingIsAnExpression.html On Fri, Sep 11, 2009 at 10:43 AM, CuppoJava wrote: > > I'm just wondering if there's anybody here that knows of a good Matlab > book to teach the semantics and syntax of the language? The books that > I've run into so far mostly focus on teaching the library and teach > the syntax in an ad-hoc learn-it-as-you-go fashion, which I don't > like. After Clojure, all other syntax seems difficult now. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Lazy sequence blows starck. Why?
On Jul 3, 11:11 pm, Gert Verhoog wrote: > This seems to work: > > (def triangle-numbers (lazy-cat [1] (map + (iterate inc 2) triangle- > numbers))) > > cheers, > gert Gert, Your proposed change works very well. It's interesting that a (seemingly) small change makes a huge difference in performance and correctness. I'm new to clojure and laziness, and will have to mull this over. Thank you for your help. It is much appreciated. David --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Lazy sequence blows starck. Why?
I'm working one of the Euler project problems, which asks for the first triangle number with more than 500 divisors. I thought it might be fun to use lazy sequences, and tried two approaches. One worked, the other blew the stack. I'm trying to understand why the second approach fails. Here's the successful approach. (defn tri [n] (* n (inc n) 1/2)) (defn triangle-numbers [] (map tri (iterate inc 1))) (take 1 (filter #(> (count-divisors %) 500) (triangle-numbers))) I have omitted the definition of count-divisors for the sake of brevity. The failing approach is the same, except for an alternative definition of the triangle numbers: (defn triangle-numbers [] (lazy-cat [1] (map + (iterate inc 2) (triangle-numbers This second approach dies with a stack overflow. Can anyone shed some light on why? Thank you. David Cabana --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---