On 13 Mar 2010, at 03:32, Jonathan Shore wrote:
Could + and other operators be changed to a macro mapping rather
than the current defn, mapping the argument list to a binary
expression tree (+ (+ (+ ... instead of the list style application
(I'm guessing yes, not being familiar with CL-st
Thanks for your thoughtful reply, see below.
On Mar 13, 2010, at 3:03 AM, Konrad Hinsen wrote:
> On 13 Mar 2010, at 03:32, Jonathan Shore wrote:
>
>> Could + and other operators be changed to a macro mapping rather than the
>> current defn, mapping the argument list to a binary expression tree
Hey all!
I am trying to filter a sequence until a false value is returned. Is
there a control-flow form to do this? ( I know I could write a loop
statement to do it)
Here are more details of what I am actually trying to do, in case
above is not clear.
input is the lazy sequence of primes:
(u
You can use either take-while or for to do what you want.
(take-while #(< % 20) primes)
(for [p primes :while (< p 20)] p)
Hope that helps
-Patrick
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@google
On 13 March 2010 15:49, Glen Rubin wrote:
> If I try:
>
> (filter #(while (< % 20)) primes)
>
> It gets hung up since filter keeps testing primes, despite the fact
> that they have grown too large. So, I would like filter to stop at
> the first false result.
Actually that's not what happens. Exe
Hello all.
I have had some time lately to work on my C FFI for Clojure and I
think it's pretty much feature complete now.
It has support for functions, callbacks, structures, unions and
globals.
For structures there is support for different alignments.
The library has two main namespaces: clj-nati
Hi,
I just ran these two microbenchmarks, where I attempted to measure the
overhead in Clojure's loop-recur form as compared to just mutating an
array.
;;loop-recur (5300 msecs)
(time
(dotimes [n 5000]
(loop [accum (int 0) i (int 0)]
(if (< i 5)
(recur (+ accum i) (inc i))
On Sat, Mar 13, 2010 at 1:59 PM, CuppoJava wrote:
> Hi,
> I just ran these two microbenchmarks, where I attempted to measure the
> overhead in Clojure's loop-recur form as compared to just mutating an
> array.
>
> ;;loop-recur (5300 msecs)
> (time
> (dotimes [n 5000]
>(loop [accum (int 0) i (
BTW your "5" literal is boxed, which is causing slowness:
user> (time
(dotimes [n 5000]
(loop [accum (int 0) i (int 0)]
(if (< i (int 5))
(recur (+ accum i) (inc i))
accum
"Elapsed time: 861.027 msecs"
On Mar 13, 10:59 am, CuppoJava wrote:
> Hi,
> I jus
On 12 March 2010 23:26, Scott wrote:
> How do I write a function 'bit' that converts an integer to binary
> representation:
>
> (bit 0) -> 2r0
> (bit 1) -> 2r1
> (bit 2) -> 2r10
> (bit 3) -> 2r11
I understand that you want a way to obtain a string representation of
a number in binary. I think you
Is there a good practice for documenting the structure basis object
for structmaps?
As I'm using more Clojure code on a production, I'm finding it useful
to document structmaps, but the only way I can find to do it is using
the following pattern to add the doc meta to a var:
(def #^{:doc "..."}
thanx, that's a start. It seems that plt-scheme's match is a bit more
powerful, but I think I can manage with this as well. So far the
biggest annoyance is the fact that I can match a number or a string,
but not a symbol (I can in :when condition, I know...) which is
something I can live with.
--
I just found clojure.contrib.types match which maybe fits more with
what I'm trying to do... I'll check it out tomorrow, almost 3am here...
--
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
N
On Sat, Mar 13, 2010 at 9:32 AM, Jonathan Shore
wrote:
> Hi,
>
> I've been evaluating clojure with a bias around performance (I do a lot of
> numerical work). I don't need to the metal, but want to see that
> fundamental operations are comparable to java in performance and that
> performance
On Sat, Mar 13, 2010 at 3:03 PM, Konrad Hinsen
wrote:
> On 13 Mar 2010, at 03:32, Jonathan Shore wrote:
>
>> Could + and other operators be changed to a macro mapping rather than the
>> current defn, mapping the argument list to a binary expression tree (+ (+
>> (+ ... instead of the list style
As a mea culpa for my earlier stupidity, here's a proposed solution
that is semantically transparent if somewhat inelegantly brute force
in its approach:
http://gist.github.com/331211
If need be, it could also define entries for :inline and
:inline-entries for the auto-generated arity overloads.
Hello,
I'm new to Clojure, but in other languages, zip is a workhorse, and I
didn't find it, so I
(defn zip [& ss]
(partition (count ss) (apply interleave ss)))
but because I didn't find it, I am suspicious: is there a better way?
Marmaduke
ps. As a first-poster: thanks to Rich Hickey and St
Greetings everyone!
I am currently beginning to learn clojure, and here's one thing that I
don't quite understand, that many exceptions thrown by clojure are the
most generic java.lang.Exception's (e.g. when a symbol cannot be
resolved). Why aren't more specific exception classes used, like
clojur
Thank you, this has been very helpfull.
The reason I came across this problem is that I never intended to
evaluate the symbols in the expression trees. I rather wanted to use
them to represent symbolic constants in an abstract expression tree. I
am now convinced that using keywords throughout is t
Hello Christophe,
On Fri, Mar 12, 2010 at 08:27:15PM +0100, Christophe Grand wrote:
> See my memoize5: the call isn't computed inside the swap!s
That doesn't mean, that it is not computed several times!
user=> (defn f
[x]
(println "Got" x "from" (Thread/currentThread))
Hi,
On Thu, Mar 11, 2010 at 01:32:36PM -0800, Phil Hagelberg wrote:
> Historically this has been because calculating the classpath couldn't
> be done in Clojure itself since it needed to be done before the JVM
> booted. Having to figure this kind of thing out in a shell script or
> in elisp is a
Hi,
On Fri, Mar 12, 2010 at 08:25:23AM +1100, Alex Osborne wrote:
> The list equivalent to the vec or set functions is (apply list ...) --
> there's no shorthand for it as you shouldn't be using lists much
> explicitly, use a vector instead.
In fact there is a short-hand:
user=> (seq [])
nil
us
I see, so that's what I was missing.
Thanks for your help!
-Patrick
--
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
I think what you want is take-while instead of filter:
(take-while %(< % 20) primes)
-Matt
--
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 -
Hmm.. I should re-read messages before sending them. The correct code
is:
(take-while #(< % 20) primes)
--
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
Hi,
On Sat, Mar 13, 2010 at 06:55:56AM -0800, Marmaduke wrote:
> I'm new to Clojure, but in other languages, zip is a workhorse, and I
> didn't find it, so I
>
> (defn zip [& ss]
> (partition (count ss) (apply interleave ss)))
>
> but because I didn't find it, I am suspicious: is there a bett
In clojure map works like zipWith.
So you can pass to it vector if you want just plain zip: (map vector
colls)
That makes making a special named function unnesessary.
On Mar 13, 6:55 am, Marmaduke wrote:
> Hello,
>
> I'm new to Clojure, but in other languages, zip is a workhorse, and I
> didn't
Hi Meikel,
On Sat, Mar 13, 2010 at 10:51 PM, Meikel Brandmeyer wrote:
> On Fri, Mar 12, 2010 at 08:27:15PM +0100, Christophe Grand wrote:
>
> > See my memoize5: the call isn't computed inside the swap!s
>
> That doesn't mean, that it is not computed several times!
>
I agree: it can be concurre
java to the rescue!
Thanks to all for your suggestions
Scott
On Mar 13, 3:45 pm, Michał Marczyk wrote:
> On 12 March 2010 23:26, Scott wrote:
>
> > How do I write a function 'bit' that converts an integer to binary
> > representation:
>
> > (bit 0) -> 2r0
> > (bit 1) -> 2r1
> > (bit 2) -> 2r10
Is there a way to say that a protocol extends another protocol or
interface? I.e. can i specify that a given protocol must also support
the "seq" method from clojure.lang.Seqable?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group,
On Mar 13, 4:51 pm, Christophe Grand wrote:
> My variations on memoize use a single atom: your bounded-memoize id roughly
> equivalent to my memoize2 + fifo-strategy,
> seehttp://gist.github.com/330644#LID19.
I finally found the time to fully read your gist, and I see you are
indeed doing the sa
On Mar 14, 11:57 am, Eugen Dück wrote:
> This gap shrinks when using memoize7 thanks to the use of delays, but
> it is not completely closed and can still lead to multiple delays of
> the same computation. If we want to get rid off this gap and make it
Actually, I take that back. The delay might
of Clojure, in my opinion: all checks of the type "does
this value fit with that function" are done at runtime.
Konrad
__ Information provenant d'ESET NOD32 Antivirus, version de la base des
signatures de virus 4942 (20100313) __
Le message a été vérifié par ES
Konrad.
__ Information provenant d'ESET NOD32 Antivirus, version de la base des
signatures de virus 4942 (20100313) __
Le message a été vérifié par ESET NOD32 Antivirus.
http://www.eset.com
--
You received this message because you are subscribed to the Google
Groups &quo
Hi Christophe,
your fifo-strategy (the one that uses "identity" as the hit method)
does not work:
user=> (def g (memoize7 identity (fifo-strategy 3)))
#'user/g
user=> (g 1)
1
user=> (g 1)
java.lang.IllegalArgumentException: Wrong number of args passed to:
core$identity (NO_SOURCE_FILE:0)
You hav
35 matches
Mail list logo