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
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
> * 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
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
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
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
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
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
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
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
10 matches
Mail list logo