Re: (string?) bug

2008-11-08 Thread Luc Prefontaine
A StringBuilder is not a Java String... neither is it a StringBuffer :))) user=> (string? (.toString (java.lang.StringBuilder. "hello"))) true user=> because: user=> (.getClass (java.lang.StringBuilder. "hello")) java.lang.StringBuilder and user=> (.getClass (.toString (java.lang.StringBuilde

(string?) bug

2008-11-08 Thread Brian Doyle
This seems like a bug returning false for StringBuilder. user=> (string? (new java.lang.String "hello")) true user=> (string? (new java.lang.StringBuilder "hello")) false --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Grou

Re: Recommending Approach to Performance Critical Code

2008-11-08 Thread CuppoJava
I'm rewriting my physics engine over from Java, which is number heavy. There's a lot of matrix multiplication and inversions. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, se

Re: a macro question, this time completely specified :-)

2008-11-08 Thread Stephen C. Gilardi
On Nov 8, 2008, at 10:23 PM, Stuart Halloway wrote: > > How about: > > (defn runonce > "Create a function that will only run its argument once." > [function] > (let [call-count (ref 0)] > (fn [& args] > (when (= 1 (dosync (alter call-count inc))) > (apply function args)))

Re: a macro question, this time completely specified :-)

2008-11-08 Thread Chouser
On Sat, Nov 8, 2008 at 10:23 PM, Stuart Halloway <[EMAIL PROTECTED]> wrote: > > How about: > > (defn runonce > "Create a function that will only run its argument once." > [function] > (let [call-count (ref 0)] > (fn [& args] > (when (= 1 (dosync (alter call-count inc))) > (

Re: a macro question, this time completely specified :-)

2008-11-08 Thread Stuart Halloway
How about: (defn runonce "Create a function that will only run its argument once." [function] (let [call-count (ref 0)] (fn [& args] (when (= 1 (dosync (alter call-count inc))) (apply function args) > On Nov 8, 2008, at 8:31 PM, Stuart Halloway wrote: > >> >> T

Re: a macro question, this time completely specified :-)

2008-11-08 Thread Stephen C. Gilardi
On Nov 8, 2008, at 8:31 PM, Stuart Halloway wrote: > > The defrunonce macro below works, creating a function that runs only > once and tracking its run status in metadata. > > Now, how do I write it without using eval? > > (defn runonce > "Create a function that will only run once, given a fun

Re: a macro question, this time completely specified :-)

2008-11-08 Thread Stuart Halloway
Excellent, thanks! Stuart On Sat, Nov 8, 2008 at 8:31 PM, Stuart Halloway > > <[EMAIL PROTECTED]> wrote: >> >> (defmacro defrunonce [sym doc & forms] >> "Defines a function with runonce semantics. Curren run status >> is kept in a reference under the :has-run metadata key." >> (let [[function

Re: a macro question, this time completely specified :-)

2008-11-08 Thread Chouser
On Sat, Nov 8, 2008 at 8:31 PM, Stuart Halloway <[EMAIL PROTECTED]> wrote: > > (defmacro defrunonce [sym doc & forms] > "Defines a function with runonce semantics. Curren run status > is kept in a reference under the :has-run metadata key." > (let [[function has-run] (runonce (eval (concat (

a macro question, this time completely specified :-)

2008-11-08 Thread Stuart Halloway
The defrunonce macro below works, creating a function that runs only once and tracking its run status in metadata. Now, how do I write it without using eval? (defn runonce "Create a function that will only run once, given a function. Returns a vector containing the function and the refer

Re: doseq, dotimes & loop/recur

2008-11-08 Thread Graham Fawcett
On Sat, Nov 8, 2008 at 4:23 PM, verec <[EMAIL PROTECTED]> wrote: > Everything that can be interpreted as a `seq', clojure's `doseq' takes > care of it. > > What I am after are the "special cases" for things one could somehow > enumerate but are not a `seq'. > > A number range is one such thing, an

Re: nth and take-nth argument order

2008-11-08 Thread Michael Wood
On Sat, Nov 8, 2008 at 10:08 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > On Nov 8, 2:44 pm, "Michael Wood" <[EMAIL PROTECTED]> wrote: >> Is there any particular reason for the reversal of the order of >> arguments between nth and take-nth? > > Short answer - take-nth is more like take. > > Long

Re: doseq, dotimes & loop/recur

2008-11-08 Thread verec
> > To rephrase the question differently, what could exist that is not a > > clojure `seq' that we would want to iterate over? > > > Clojure already answers this (partially?) by providing (dotimes ...) > > (as CL does) to iterate over a zero based consecutive and finite > > sequence of numbers. Th

Re: prog1

2008-11-08 Thread Matthias Benkard
On 8 Nov., 20:24, Phlex <[EMAIL PROTECTED]> wrote: > There must be some reason for CL to have it as a macro > (call-argument-limit perhaps ?) I don't know, but I suspect it might be matter of aesthetics. In CL, PROGN can't be a function for various reasons (off the top of my head: multiple-value

Re: doseq, dotimes & loop/recur

2008-11-08 Thread Graham Fawcett
HI, On Sat, Nov 8, 2008 at 2:39 PM, verec <[EMAIL PROTECTED]> wrote: > But then why would we want any of `doseq', `dotimes' or `doall', and > if we do, is that set complete, and with respect to what design > principle? Well, given loop/recur as a fundamental iteration form, and doall as a mecha

Re: nth and take-nth argument order

2008-11-08 Thread Rich Hickey
On Nov 8, 2:44 pm, "Michael Wood" <[EMAIL PROTECTED]> wrote: > Is there any particular reason for the reversal of the order of > arguments between nth and take-nth? Short answer - take-nth is more like take. Longer answer: http://groups.google.com/group/clojure/browse_frm/thread/8b2c8dc96b39d

nth and take-nth argument order

2008-11-08 Thread Michael Wood
Is there any particular reason for the reversal of the order of arguments between nth and take-nth? I would have expected something like: clojure/nth ([n coll]) clojure/take-nth ([index coll]) ([index coll not-found]) or else: clojure/nth ([coll n]) clojure/take-nth ([coll index]) ([coll ind

Re: doseq, dotimes & loop/recur

2008-11-08 Thread verec
Hmmm. Thank you for the post. Questions of laziness apart, I know that recursion has been proven to be equivalent to iterations (expect to weed out interview candidates, as per Steve Yege's remarks :-) But then why would we want any of `doseq', `dotimes' or `doall', and if we do, is that set co

Re: prog1

2008-11-08 Thread Michael Wood
On Sat, Nov 8, 2008 at 8:48 PM, André Thieme <[EMAIL PROTECTED]> wrote: > > On 8 Nov., 18:00, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote: >> Hi, >> >> Am 08.11.2008 um 17:39 schrieb Meikel Brandmeyer: >> >> >> (defn returning [returnval & body] >> >> returnval) [...] > I also don't see how the f

Re: prog1

2008-11-08 Thread Phlex
André Thieme wrote: > On 8 Nov., 17:47, Phlex <[EMAIL PROTECTED]> wrote: > >> Robert Pfeiffer wrote: >> >>> Is there a benefit in implementing this as a macro instead of a >>> function? The function version would be very simple: >>> >>> (defn returning [returnval & body] >>>re

Re: prog1

2008-11-08 Thread Randall R Schulz
On Saturday 08 November 2008 10:44, André Thieme wrote: > On 8 Nov., 18:32, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote: > > Hi, > > > > Am 08.11.2008 um 17:58 schrieb Randall R Schulz: > > > Peasant? Or did you mean "pedant?" > > > > In german there is the word "Banause" which translates > > acco

Re: prog1

2008-11-08 Thread André Thieme
On 8 Nov., 18:00, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote: > Hi, > > Am 08.11.2008 um 17:39 schrieb Meikel Brandmeyer: > > >> (defn returning [returnval & body] > >>  returnval) > > And another question, which a I got when I read the > mail of Phlex: Is the order of evaluation of function > ar

Re: prog1

2008-11-08 Thread André Thieme
On 8 Nov., 18:32, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote: > Hi, > > Am 08.11.2008 um 17:58 schrieb Randall R Schulz: > > > Peasant? Or did you mean "pedant?" > > In german there is the word "Banause" which translates > according the dictionary to "peasant". It means something > like the follo

Re: prog1

2008-11-08 Thread André Thieme
On 8 Nov., 17:47, Phlex <[EMAIL PROTECTED]> wrote: > Robert Pfeiffer wrote: > > Hello, > > > Is there a benefit in implementing this as a macro instead of a > > function? The function version would be very simple: > > > (defn returning [returnval & body] > >    returnval) > > Well no, the forms ar

Re: doseq, dotimes & loop/recur

2008-11-08 Thread Graham Fawcett
Hi, On Sat, Nov 8, 2008 at 11:20 AM, verec <[EMAIL PROTECTED]> wrote: > > More of an inquiry into the "fp mindset as opposed to the procedural > one" than anything else ... > > If I got this right, there are two forms of iterations: internal and > external. > `map' is an "internal iterator", `dos

Re: prog1

2008-11-08 Thread Meikel Brandmeyer
Hi, Am 08.11.2008 um 17:58 schrieb Randall R Schulz: Peasant? Or did you mean "pedant?" In german there is the word "Banause" which translates according the dictionary to "peasant". It means something like the following: Artist: "Oh! Look this beautiful picture! It's art!" Banause: "It's jus

Re: Print compiled Clojure svn revision?

2008-11-08 Thread Matt Revelle
If marking SVN revisions and/or release versions is something we still want and want automated, it now looks like using the build tool is the only way to go. The example I sent earlier to the list includes the creation of a "versioninfo" file from the build script which is then read and s

Re: prog1

2008-11-08 Thread Meikel Brandmeyer
Hi, Am 08.11.2008 um 17:39 schrieb Meikel Brandmeyer: (defn returning [returnval & body] returnval) And another question, which a I got when I read the mail of Phlex: Is the order of evaluation of function arguments guaranteed to be from the left to the right? Sincerely Meikel smime.p7s D

Re: prog1

2008-11-08 Thread Randall R Schulz
On Saturday 08 November 2008 08:39, Meikel Brandmeyer wrote: > Hi, > > Am 08.11.2008 um 17:10 schrieb Robert Pfeiffer: > > Is there a benefit in implementing this as a macro instead of a > > function? The function version would be very simple: > > > > (defn returning [returnval & body] > > retur

Re: prog1

2008-11-08 Thread Phlex
Robert Pfeiffer wrote: > Hello, > > Is there a benefit in implementing this as a macro instead of a > function? The function version would be very simple: > > (defn returning [returnval & body] >returnval) > > > Well no, the forms are evaluated. It's usefull for side effects. user> (def

Re: prog1

2008-11-08 Thread Meikel Brandmeyer
Hi, Am 08.11.2008 um 17:10 schrieb Robert Pfeiffer: Is there a benefit in implementing this as a macro instead of a function? The function version would be very simple: (defn returning [returnval & body] returnval) Although I'm a strong proponent of using macros only where they are really n

doseq, dotimes & loop/recur

2008-11-08 Thread verec
More of an inquiry into the "fp mindset as opposed to the procedural one" than anything else ... If I got this right, there are two forms of iterations: internal and external. `map' is an "internal iterator", `doseq' is an "external iterator". An "internal iterator" does the iteration "by itself

Re: prog1

2008-11-08 Thread Robert Pfeiffer
Hello, Is there a benefit in implementing this as a macro instead of a function? The function version would be very simple: (defn returning [returnval & body] returnval) This is just a K combinator with varargs. Robert Pfeiffer --~--~-~--~~~---~--~~ You recei

Re: Patch and audit: Use vectors for bindings in doseq, et al.

2008-11-08 Thread Rich Hickey
On Nov 8, 8:52 am, Chouser <[EMAIL PROTECTED]> wrote: > Attached is an updated patch. Instead of using "for" in the > implementation of "doseq", this has a "doseq" that uses loop/recure. > The interface is the same, but it should run faster. This also means > "doseq" is only defined once (nor r

Re: prog1

2008-11-08 Thread Stephen C. Gilardi
On Nov 8, 2008, at 5:55 AM, Phlex wrote: > Hello, > > I was missing the prog1 macro from common lisp, so here it is. > > (defmacro prog1 [& body] > " (prog1 forms*) > Evaluates all the forms, returning the result of the first form" > `(let [result# ~(first body)] > ~@(rest body) > resu

Re: Patch and audit: Use vectors for bindings in doseq, et al.

2008-11-08 Thread Chouser
Attached is an updated patch. Instead of using "for" in the implementation of "doseq", this has a "doseq" that uses loop/recure. The interface is the same, but it should run faster. This also means "doseq" is only defined once (nor redefined as in the earlier patch). This patch is against 1089, t

Re: Patch and audit: Use vectors for bindings in doseq, et al.

2008-11-08 Thread Rich Hickey
On Nov 7, 5:09 pm, James Reeves <[EMAIL PROTECTED]> wrote: > On Nov 7, 9:32 pm, Chouser <[EMAIL PROTECTED]> wrote: > > > > And in which case, your vector syntax could be misleading, because it > > > seems to imply you're assigning i to 10: > > > > (dotimes [i 10] > > > (prn i)) > > > Vectors ar

prog1

2008-11-08 Thread Phlex
Hello, I was missing the prog1 macro from common lisp, so here it is. (defmacro prog1 [& body] " (prog1 forms*) Evaluates all the forms, returning the result of the first form" `(let [result# ~(first body)] ~@(rest body) result#)) user> (prog1 "a" "b" "c") "a" user> (prog1) nil us