2009/3/23 Krešimir Šojat kso...@gmail.com:
(rand-int 49) will produce one integer, and repeat will repeat it 10
times, that is why you see same number repeated.
How embarrassing!
As soon as I switched my machine off last night I realised rand-int
was only being called once - of course it
Why presumably with side effects?Otherwise you would use repeat. A pure
function returns the same value every time, so there is no reason to call
it repeatedly.
Joshua
On Tue, Mar 24, 2009 at 10:04 AM, Paul Drummond paul.drumm...@iode.co.ukwrote:
2009/3/23 Krešimir Šojat kso...@gmail.com:
2009/3/24 Joshua Fox joshuat...@gmail.com:
Why presumably with side effects?
Otherwise you would use repeat. A pure function returns the same value
every time, so there is no reason to call it repeatedly.
Yup, that makes sense.
Random numbers are side-effecting (is that the right term?) and
Has anyone gotten 20090320 to work on a new MacBook Pro running
Leopard?
With further investigation, it looks like any call to (use...) either
explicitly or as part of an (ns...) function call causes clojure to
crash since the upgrade. I've fiddled around with the class path, and
nothing seems
On Mar 23, 2009, at 10:36 PM, Paul Drummond wrote:
2009/3/24 Joshua Fox joshuat...@gmail.com:
Why presumably with side effects?
Otherwise you would use repeat. A pure function returns the same
value
every time, so there is no reason to call it repeatedly.
Yup, that makes sense.
On Mar 23, 2009, at 23:11, Meikel Brandmeyer wrote:
This is not correct. defmulti may take any of Clojure's
reference types containing the hierarchy. So it doesn't
need to be a Var. A Ref, an Atom or an Agent are also
possible.
Thanks for pointing this out. Here comes a corrected patch!
News for the handful of people interested in gfs.
Below is a sample trace of the gf implementation.
Dispatch is wholly deterministic; you never need prefer-method. There
is no need to specify a dispatch function, though dispatch
customization is available if you want it. The default dispatch
On Mar 24, 2009, at 11:19, mikel wrote:
Dispatch is wholly deterministic; you never need prefer-method. There
Then what is the rule for choosing one method when there are several
that match the arguments?
In the scope in which a generic function is applied, next-method is
always bound to
On 24/03/2009 1:06, pmf wrote:
On Mar 24, 12:01 am, Rowdy Rednoserowdy.redn...@gmx.net wrote:
Hi group,
say I have 2 sequences
(def seq-a '(a1 a2 a3))
(def seq-b '(b1 b2 b3))
and want to iterate over them in parallel, like this
(par-doseq [a seq-a b seq-b] (prn a b))
which
As was described in a Software Engineering Radio podcast on
transactional memory, there are many parallels between garbage
collection and transactional memory. Some parallels that aren't in
place yet though include:
1) There are tools to measure the impact of GC on runs of an
application, but we
+1 for running all the code under src/jvm through some code formatter
that uses something at least similar to the Sun Java conventions.
On Mon, Mar 23, 2009 at 11:59 PM, BerlinBrown berlin.br...@gmail.com wrote:
I was curious about how some of the clojure code worked and observed
that the
The latest version of Clojure incorporated lazy sequences which broke many
libraries early on. Most of these problems have been worked out. In my
experience you should use the cutting edge version of everything including
SLIME. I clone everything from GitHub (clojure, clojure-contrib,
Javadoc would be nice, but I do note that Rich's Java code is pretty darn
clear ;)
I also note the indentation style is similar to Whitesmith's according to
Wikipedia http://en.wikipedia.org/wiki/Indent_style. I've always preferred
the BSD curly brace level matching convention over the KR
Some generic STM bits of wisdom:
- STMs in standard languages (e.g. C, C++) suffer from having to
track all memory references. THis overhead means the STM code
typically starts 3x to 10x slower than non-STM code, which is a pretty
stiff penalty to recover from. If you're only getting a 3x
2009/3/24 Konrad Hinsen konrad.hin...@laposte.net
On Mar 24, 2009, at 11:19, mikel wrote:
Dispatch is wholly deterministic; you never need prefer-method. There
Then what is the rule for choosing one method when there are several
that match the arguments?
In the scope in which a generic
Even though I don't really care for the indentation style used, it is
(unlike most projects) consistent and clear.
Joshua
On Mar 24, 8:40 am, David Nolen dnolen.li...@gmail.com wrote:
Javadoc would be nice, but I do note that Rich's Java code is pretty darn
clear ;)
I also note the
Hi, all.
I'm experimenting clojure.
Some code, I needed something like sorted-set-by, but no such
thing.
So i used sorted-map-by ignoring value part.
Is it deliberate for some reason?
Or just not there?
--~--~-~--~~~---~--~~
You received this message because you
You mean by Sun Norvig conventions right ? ;)
http://code.google.com/p/clojure/issues/detail?id=16q=prettycolspec=ID%20Type%20Status%20Priority%20Reporter%20Owner%20Summary
On Mar 24, 1:46 am, Mark Volkmann r.mark.volkm...@gmail.com wrote:
+1 for running all the code under src/jvm through some
Hi all.
I'm experimenting cljoure.
some code, i needed something like sorted-set-by. but, no such
thing, so I emulated that using sorted-map-by.
Is it deliberate for some reason?
or just not there?
--~--~-~--~~~---~--~~
You received this message because you are
Hi, all.
I'm experimenting clojure.
Some code, I needed something like sorted-set-by, but no such
thing.
So i used sorted-map-by ignoring value part.
Is it deliberate for some reason?
Or just not there?
--~--~-~--~~~---~--~~
You received this message because you
Hi, all.
I don't know why my previous posts ignored.
spam filtering? so i changed title.
I'm experimenting clojure.
Some code, I needed something like sorted-set-by, but no such
thing.
So i used sorted-map-by ignoring value part.
Is it deliberate for some reason?
Or just not there?
Support for using JVM annotations with Clojure code has come up
several times before,
I'd like a feature request issue to be created and to start discussing
the implementation.
It seems that an annotations metadata tag could contain all
annotations for an object,
and any annotations that
Thanks guys, these solutions look much better already.
But do I always have to have these 2 steps
* merge collection
* split collection
It feels a bit inefficient, I don't know if it actually is, though.
On Mar 24, 8:05 pm, Phlex ph...@telenet.be wrote:
On 24/03/2009 1:06, pmf wrote:
On
Some working code would make it a lot easier to understand *exactly*
what you're looking for. Do you think you could post a few quick
methods on github? If memory serves, the reflections package should
be a good place to start.
However, you'd need to ask *why* you need this.
If the answer is
You could define a helper function, zip (as in Haskell) :
(def zip (partial map list))
and then use as showed above:
(doseq [[x y] (zip [:a :b] [1 2])] (println x: x , y: y))
2009/3/24 Rowdy Rednose rowdy.redn...@gmx.net
Thanks guys, these solutions look much better already.
But do I
@Rowdy
Take the time to do the interleave example by hand. You'll it does
exactly what you want in one pass.
On Mar 24, 10:10 am, Rowdy Rednose rowdy.redn...@gmx.net wrote:
Thanks guys, these solutions look much better already.
But do I always have to have these 2 steps
* merge collection
I want to write a function or macro that allows me to output the value
of an expression without repeating it. For example, I want something
like (dump (+ 1 2)) to output (+ 1 2) = 3.
This works.
(defn dump1 [string]
(println string = (load-string string)))
(dump1 (+ 1 2))
Note how I had to
I want to write a function or macro that allows me to output the value
of an expression without repeating it. For example, I want something
like (dump (+ 1 2)) to output (+ 1 2) = 3.
This works.
(defn dump1 [string]
(println string = (load-string string)))
(dump1 (+ 1 2))
Note how I had to
On Mar 24, 2009, at 5:03 AM, Rich wrote:
Has anyone gotten 20090320 to work on a new MacBook Pro running
Leopard?
I tried it just now and it worked for me. Here's the test I did:
- Download 20090320 zip file
- Expand it into dir
- create a file in dir called Structure.clj
On Tue, Mar 24, 2009 at 9:44 AM, Stephen C. Gilardi squee...@mac.com wrote:
One thing to note is that namespace names should always have at least one
period in them. I believe this is due to a rule regarding Java packages. At
some point the clojure namespace became clojure.core for this
On Tue, Mar 24, 2009 at 9:44 AM, Stephen C. Gilardi squee...@mac.com wrote:
One thing to note is that namespace names should always have at least one
period in them. I believe this is due to a rule regarding Java packages. At
some point the clojure namespace became clojure.core for this
On Mar 24, 2009, at 15:44, Mark Volkmann wrote:
I'm wondering if there is a way to avoid that using a macro. The hard
part is printing the expression. The following doesn't work. It
outputs 3 = 3.
(defmacro dump2 [expr]
`(let [value# ~expr]
(pr ~expr)
(println = value#)))
On Tue, Mar 24, 2009 at 9:55 AM, Konrad Hinsen
konrad.hin...@laposte.net wrote:
On Mar 24, 2009, at 15:44, Mark Volkmann wrote:
I'm wondering if there is a way to avoid that using a macro. The hard
part is printing the expression. The following doesn't work. It
outputs 3 = 3.
(defmacro
2009/3/24 Mark Volkmann r.mark.volkm...@gmail.com:
Thanks! It looks like I don't need the let now. Does a macro have to
evaluate to one form? For example, this works, but it seems I can't
drop the do.
(defmacro dump [expr]
`(do
(print (quote ~expr))
(println = ~expr)))
How
On Mar 24, 2009, at 16:00, Mark Volkmann wrote:
Thanks! It looks like I don't need the let now.
Indeed.
Does a macro have to evaluate to one form? For example, this works,
but it seems I can't
drop the do.
Yes, a macro has to evaluate to one form. This is actually not so
much a
On Mar 24, 2009, at 10:49 AM, Mark Volkmann wrote:
On Tue, Mar 24, 2009 at 9:44 AM, Stephen C. Gilardi
squee...@mac.com wrote:
One thing to note is that namespace names should always have at
least one
period in them. I believe this is due to a rule regarding Java
packages. At
some point
Eric Rochester has a debug macro, together with a walkthrough of how he
built it, here
http://writingcoding.blogspot.com/2008/09/stemming-part-19-debugging.html
Joshua
On Tue, Mar 24, 2009 at 4:43 PM, Mark Volkmann r.mark.volkm...@gmail.comwrote:
I want to write a function or macro that
On 24/03/2009 15:10, Rowdy Rednose wrote:
Thanks guys, these solutions look much better already.
But do I always have to have these 2 steps
* merge collection
* split collection
It feels a bit inefficient, I don't know if it actually is, though.
Allright let's see what we can do :
make a
(defn par-doseq-fn [fn seqs]
(loop [rests seqs]
(when (every? identity (map seq rests))
(apply fn (map first rests))
(recur (map rest rests)
It should of course be like this :
(defn par-doseq-fn [fn seqs]
(loop [rests seqs]
(when (every? seq
On Mar 24, 10:19 am, Sean francoisdev...@gmail.com wrote:
Some working code would make it a lot easier to understand *exactly*
what you're looking for. Do you think you could post a few quick
methods on github?
No need for gist, this will do as an example:
(ns some.namespace
(:gen-class
is there something as simple as this in clojure?
whole python program:
of = open(filename,w)
of.write(hello)
of.close()
I checked the api and looked around the wiki and google quickly and saw how
to use java's stuff to do it ... but, welll...
I noticed slurp in the api for reading
(defn par-doseq-fn [fn seqs]
(loop [rests seqs]
(when (every? identity (map seq rests))
(apply fn (map first rests))
(recur (map rest rests)
It should of course be like this :
(defn par-doseq-fn [fn seqs]
(loop [rests seqs]
(when
Hello,
try
(with-open [of (java.io.FileWriter. /path/to/your/file)]
(.write of coucou))
As far as java libraries are concerned, and answer commonly seen in this ml
is : use apache commons io. And indeed it does the job well, but, yes,
it's then another dependency to your project, for what one
e wrote:
is there something as simple as this in clojure?
whole python program:
of = open(filename,w)
of.write(hello)
of.close()
I checked the api and looked around the wiki and google quickly and saw how
to use java's stuff to do it ... but, welll...
There are possibly
For reference, here's a version I wrote while I was working on cl-
format and the pretty printer:
(defn prerr [ args]
Println to *err*
(binding [*out* *err*]
(apply println args)))
(defmacro prlabel [prefix arg more-args]
Print args to *err* in name = value format
(cons 'prerr
Hello!
Yes, you are right, sorted-set-by is missing. Good news is - it is
on the way :-)
See issue 76:
http://code.google.com/p/clojure/issues/detail?id=76
Frantisek
On Mar 24, 5:35 am, hjlee hj.d@gmail.com wrote:
Hi, all.
I don't know why my previous posts ignored.
spam filtering? so
Hi all,
I'm getting an error I don't quite understand. Starting Clojure
(r1329) and entering
user (ns foo (:use [clojure.contrib.zip-filter :as zf]))
I get an exception,
java.lang.IllegalStateException: descendants already refers to:
#'clojure.core/descendants in namespace: foo
The doc doesn't claim that :as works with use.
But it works well with require :
user (ns foo (:require [clojure.contrib.zip-filter :as zf]))
HTH,
--
Laurent
2009/3/24 Tom Emerson tremer...@gmail.com
Hi all,
I'm getting an error I don't quite understand. Starting Clojure
(r1329) and
On Mar 24, 2009, at 1:01 PM, Tom Emerson wrote:
Hi all,
I'm getting an error I don't quite understand. Starting Clojure
(r1329) and entering
user (ns foo (:use [clojure.contrib.zip-filter :as zf]))
Because you've used :use, you are referring all of
clojure.contrib.zip-filter into foo.
On Mar 24, 7:59 am, Laurent PETIT laurent.pe...@gmail.com wrote:
2009/3/24 Konrad Hinsen konrad.hin...@laposte.net
On Mar 24, 2009, at 11:19, mikel wrote:
Dispatch is wholly deterministic; you never need prefer-method. There
Then what is the rule for choosing one method when
question: what do people think about the general topic of inheritance?
my take on it so far is that inheritance apparently sounds like a good
idea at first to some folks, but quickly turns into something of a
nightmare if one is actually concerned with keeping a coherent
semantics (so that (a)
On Mar 24, 12:42 pm, Parth Malwankar parth.malwan...@gmail.com
wrote:
user= (with-open [f (writer (file test.txt))]
(binding [*out* f]
(println hello world !!!)))
Or even more simply:
(use 'clojure.contrib.duck-streams)
(spit test.txt Hello, world!\n)
-Stuart Sierra
On Mon, Mar 23, 2009 at 6:49 PM, Laurent PETIT laurent.pe...@gmail.com wrote:
Hello,
there has been plenty of time to speak about that in the previous thread on
the subject, and it's a shame these interesting proposals had to wait for
the release of the functionality to pop up :-).
But I
On Mar 24, 7:46 am, Mark Volkmann r.mark.volkm...@gmail.com wrote:
+1 for running all the code under src/jvm through some code formatter
that uses something at least similar to the Sun Java conventions.
On Mon, Mar 23, 2009 at 11:59 PM, BerlinBrown berlin.br...@gmail.com wrote:
I was
On Mar 24, 5:56 am, cliffc cli...@acm.org wrote:
Some generic STM bits of wisdom:
- STMs in standard languages (e.g. C, C++) suffer from having to
track all memory references. THis overhead means the STM code
typically starts 3x to 10x slower than non-STM code, which is a pretty
stiff
On Mar 24, 12:58 pm, Raoul Duke rao...@gmail.com wrote:
question: what do people think about the general topic of inheritance?
my take on it so far is that inheritance apparently sounds like a good
idea at first to some folks, but quickly turns into something of a
nightmare if one is
*bump*
Just letting people know that this is still an important and
unresolved issue for me.
Calling super multi-methods?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group, send
does anyone else think that should be more fundamental like the python
example? imagine saying that out loud to your friend who asks . . . and the
amount of noise, visually:
use clojure dot contrib dot duck dash streams.
perhaps it is already the hope that it will spit will eventually sit next
+1
Using regular and proper formatting assists in submitting patches.
A little Javadoc would be nice as well.
On Tue, Mar 24, 2009 at 4:46 AM, Mark Volkmann
r.mark.volkm...@gmail.com wrote:
+1 for running all the code under src/jvm through some code formatter
that uses something at least
Hi,
Am 24.03.2009 um 16:00 schrieb Mark Volkmann:
Thanks! It looks like I don't need the let now.
But there are reasons to keep it! Eg. returning the expression
result!
(defmacro dump
[expr]
`(let [value# ~expr]
(println (pr-str (quote ~expr)) = (pr-str value#))
value#))
Then
Hi,
Am 24.03.2009 um 18:51 schrieb mikel:
(define-method add [x y] ...)
(define-method add [[x java.lang.Integer] y] ...)
(define-method add [x [y java.lang.Integer]] ...)
and call (add 3 3). Which of the methods is chosen?
Isn't it the second, which is the most
Hi,
Am 24.03.2009 um 20:08 schrieb Howard Lewis Ship:
Using regular and proper formatting assists in submitting patches.
hahaha! If someone submitting a patch ever adhered to a coding
convention of any sort.
A little Javadoc would be nice as well.
Yes. That would definitively be a good a
On Mar 24, 3:39 pm, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
Am 24.03.2009 um 18:51 schrieb mikel:
(define-method add [x y] ...)
(define-method add [[x java.lang.Integer] y] ...)
(define-method add [x [y java.lang.Integer]] ...)
and call (add 3 3). Which of
On Mon, 23 Mar 2009 19:41:07 -0700
Mark Engelberg mark.engelb...@gmail.com wrote:
On Mon, Mar 23, 2009 at 7:31 PM, Vincent Foley vfo...@gmail.com
wrote:
More generally, is it possible that I'm just doing this whole thing
wrong? That using vectors to represent binary fields and records
i guess another way to say this is that I can see both sides of the argument
... on one side, it shouldn't be a priority to resolve problems that java
already provides when there are probably other more pressing issues. And
it's part of the design decision to allow users to leverage java
I think Cliff may mean that each STM-participating memory access is 3x
slower, but in Clojure, because of immutability, a very small
proportion of accesses are Ref accesses, whereas in C/C++ *all* memory
accesses would be.
I agree that there's lots of room for adding instrumentation to
Clojure's
I think I figured it out.
If I install clojure.jar into /Library/Java/Extensions/ (the ext
directory on Macs) then it won't work. Even if I use java -cp ... to
point to a different clojure.jar. Simply having the jar in that folder
breaks things.
Once I deleted it from /Library/Java/Extensions,
Hi,
Am 24.03.2009 um 22:36 schrieb mikel:
CLOS says that if two matches are otherwise equally specific, the one
on the left wins. Similarly, it says that if two classes define slots
with the same name, the one farthest from the root of the class
heterarchy (as defined by a standard traversal
A relevant question is: what is the relative cost of locking and
blocking (in the pure Java approach) vs. the cost of retrying (in the
Clojure/STM approach).
I don't want to go out on a limb, having not looked at the Clojure STM
implementation. However, I would bet that the costs are roughly
Thanks all,
microbenchmarking shows that a simple
(time (doseq [[a b] (map vector list-a list-b)]))
is ~50% faster on my system than
(def par-doseq-fn (comp dorun map))
(defmacro par-doseq [bindings body]
(let [bindings (partition 2 bindings)]
`(par-doseq-fn (fn ~(vec (map first
I don't want to go out on a limb, having not looked at the Clojure STM
implementation. However, I would bet that the costs are roughly equal.
Even if Clojure was 50% slower, or 100% slower, the knowlege that you
can spin up a large number of threads and not worry about deadlocks is
On Tue, Mar 24, 2009 at 11:40 PM, Howard Lewis Ship hls...@gmail.com wrote:
A relevant question is: what is the relative cost of locking and
blocking (in the pure Java approach) vs. the cost of retrying (in the
Clojure/STM approach).
I can't think, off the top of my head, of a fair way to
Hi,
Is there any way to get a dynamic member-symbol for use in the (.)
special form?
For example, I get the following exception:
user= (def obj (Object.))
#'user/obj
user= (. obj (symbol f))
java.lang.IllegalArgumentException: No matching method found: symbol
for class java.lang.Object
I
On Mar 24, 11:53 pm, e evier...@gmail.com wrote:
does anyone else think that should be more fundamental like the python
example? imagine saying that out loud to your friend who asks . . . and the
amount of noise, visually:
use clojure dot contrib dot duck dash streams.
perhaps it is
Okay, I've made some changes to my proposed str-utils. I've also got
a few answers to some of the issues Stuart raised.
New Changes
1. re-strip is now lazy
I re-wrote this method to used the re-partition method in str-utils.
This enables the laziness, and helped be consolidate my Java
Hi,
I would generally agree with Stuart that wrapping Java functions is
not a good idea.
However, string functions come up so often that I think that this is
one area where the rule should be broken, if only for readablility.
Making str-utils kick-ass is a great idea.
pc
On Mar 24, 7:05 pm,
Awesome. Thanks Konrad.
On Mar 23, 4:11 am, Konrad Hinsen konrad.hin...@laposte.net wrote:
On 22.03.2009, at 21:10, Jon Nadal wrote:
I often need to map a function over the values of a map while
preserving keys--something like:
...
Is there a more concise way to do this in Clojure?
It'd be nice to have a macro that worked more like the first example -
spit is great for one-liners, but the fact that it opens and closes the
file each time you call it seems a bit painful for anything more complex.
Something that ends up working like:
(with-out-as test.txt
(println hello)
I'm interested to know what the process/priority is on bubbling things up
from contrib into the core. Is a discussion under way about going through
it all?
I also think it's good to have cross-language conventions sometimes unless
there are compelling reasons.
For example, slurp is, perhaps,
On Mar 24, 5:37 pm, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
Am 24.03.2009 um 22:36 schrieb mikel:
CLOS says that if two matches are otherwise equally specific, the one
on the left wins. Similarly, it says that if two classes define slots
with the same name, the one farthest from
On Tue, Mar 24, 2009 at 10:19 PM, e evier...@gmail.com wrote:
I'm interested to know what the process/priority is on bubbling things up
from contrib into the core. Is a discussion under way about going through
it all?
I also think it's good to have cross-language conventions sometimes
81 matches
Mail list logo