Re: On Lisp => Clojure

2009-07-18 Thread Meikel Brandmeyer
Hi, Am 19.07.2009 um 06:06 schrieb Rowdy Rednose: (defn db-push ([key val] (db-push key val *default-db*)) ([key val db] (swap! db assoc key (cons val (@db key) But I think it's broken in the face of concurrency, as I capture the value of @db at the time of the call to the function s

Re: On Lisp => Clojure

2009-07-18 Thread Rowdy Rednose
On Jul 19, 12:53 pm, Richard Newman wrote: > > * Can the body of the db-push function be simplified? > > I think so. Untested: > > (defn db-push >   ([key val] (db-push key val *default-db*)) >   ([key val db] >      (swap! db assoc key (cons val (db key)) If I add an @ it runs: (defn db-pu

Re: On Lisp => Clojure

2009-07-18 Thread Richard Newman
> * Is "function overloading" the idiomatic way to implement default > params in clojure? Typically, I think so. You could also use multimethods, but that might be unnecessary flexibility. Another approach is to emulate keyword arguments: (defn foo [x y & args] (let [{:keys [baz bar]} (app

On Lisp => Clojure

2009-07-18 Thread Rowdy Rednose
Hi all, in my quest to learn clojure (and lisp in general), I'm currently trying to translate some the "On Lisp" code to clojure. The first couple of functions and macros in Chapter 19 "A Query Compiler" read: (defun make-db (&optional (size 100)) (make-hash-table :size size)) (defvar *defau

Re: On Lisp -> Clojure

2008-10-08 Thread Fogus
Chapter 4 now up. http://www.earthvssoup.com/2008/10/08/on-lisp-clojure-chapter-4/ In this episode we see Rich Hickey slap a n00b. ;) -m --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" grou

Re: On Lisp -> Clojure

2008-10-02 Thread Fogus
Thanks for the pointers Alexander. I decided to take to heart the criticisms and rewrite a few of the functions from chapter 2; hopefully they are more Clojure-esque. :) http://www.earthvssoup.com/2008/10/02/on-lisp-clojure-chapter-2-redux/ -m

Re: On Lisp -> Clojure

2008-09-30 Thread Alexander Kjeldaas
2008/9/30 Chouser <[EMAIL PROTECTED]> > > remove-if uses "regular" recursion, but because the JVM does not > optimize away tail calls the way Common Lisp (usually) does, this > could fail for very long lists. However, if you just replace "cons" > with "lazy-cons" and the other recursive call with

Re: On Lisp -> Clojure

2008-09-30 Thread Fogus
The comment was held in moderation. Sadly, if I did not perform some triage on the site comments I would be inundated with comments on Viagra and mortgage loans. Far from being discouraged, I am enthusiastic by your recommendations. I am far less interested in being correct than in doing it corr

Re: On Lisp -> Clojure

2008-09-30 Thread Chouser
I tried to leave a comment on your blog, but it's not clear to me if it's being held for moderation, or simply failed. So I'll paste it here too. On Tue, Sep 30, 2008 at 10:06 AM, Fogus <[EMAIL PROTECTED]> wrote: > > In an attempt to get a feel for Clojure I have started porting Paul > Graham's

On Lisp -> Clojure

2008-09-30 Thread Fogus
In an attempt to get a feel for Clojure I have started porting Paul Graham's "On Lisp". I have a good feel for the syntax so far, but I feel that perhaps I am simply writing Common Lisp in Clojure. If anyone is interested, my early attempts are at: http://www.earthvssoup.com/tag/onlisp/ Feel f