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
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
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
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)))
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)))
> (
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
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
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
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 (
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
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
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
> > 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
38 matches
Mail list logo