On Sun, Dec 14, 2008 at 5:48 AM, bOR_ boris.sch...@gmail.com wrote:
Can anyone tell me what mistake I am making?
(time
(do
(dotimes i popsize
(send-off (agent i)
(doseq a [birth death infect infect evolve
evolve evolve evolve evolve] (a i
Jim,
I would make some minor changes in two places. I would write with-
monad as:
Obviously this is a better version.
And I would write m-lift as
I like that one as well.
I have uploaded a new version that integrates your improvements.
Another one is that the monad operations are now
Thanks! Needed only a small change then :)
(time
(do
(dotimes i popsize
(doseq a [birth death infect infect evolve evolve evolve
evolve evolve]
(send-off (agent i) a)))
(dosync (commute year inc
(report)
On Sun, Dec 14, 2008 at 8:49 AM, bOR_ boris.sch...@gmail.com wrote:
Thanks! Needed only a small change then :)
(time
(do
(dotimes i popsize
(doseq a [birth death infect infect evolve evolve evolve
evolve evolve]
(send-off (agent i) a)))
(dosync (commute
The order doesn't matter, and a somewhat mixed order would even be a
welcome side-effect of the whole concurrency bit.
What does worry me is that the agents are very short-lived. The
longest of these tasks takes 0.5msec (any evolution event), so I am
not sure if spawning all these agents is
On Saturday 13 December 2008 23:19, Mark H. wrote:
So I'm going to stop pretending like I'm an expert and actually post
some Clojure code. Be constructively critical 'cause I'm a n00b in
that regard ;-) This is a pseudorandom number generator for the
Gaussian (0,1) distribution.
... [
Hi, I'm just learning Clojure but I thought I would do a little
experiment to see where Clojure sits performance-wise compared to a
number of other languages on the old Fibonacci sequence. I think it
handles itself quite well.
The full writeup:
On Dec 14, 9:01 am, Mike Perham mper...@gmail.com wrote:
Hi, I'm just learning Clojure but I thought I would do a little
experiment to see where Clojure sits performance-wise compared to a
number of other languages on the old Fibonacci sequence. I think it
handles itself quite well.
The
I've not had time to look at the source yet, but want to note that the
exception with Swank happens at r1158:
r1158 | rhickey | 2008-12-12 21:37:12 -0500 (Fri, 12 Dec 2008) | 2
lines
force instance member interpretation of (.method ClassName), e.g.
(.getMethods String) works
Any idea how this
Ah, ok... I would have assumed that would be labeled as O(2n). Didn't
realize that was rolled into the constant factor. So, when graphed,
ANY linear function is O(n), no matter how steep the line is?
Obviously I have some reading to do.
Thanks for the clarification,
-Luke
On Dec 13, 6:35 pm,
yep. a function f(n) is O(n) if there are constants c and n0 such that f(n)
= c * n for all n = n0.
sometimes you do care about the c and the n0, though.
On Sun, Dec 14, 2008 at 12:41 PM, levand luke.vanderh...@gmail.com wrote:
Ah, ok... I would have assumed that would be labeled as O(2n).
On Dec 14, 2:01 pm, Mike Perham mper...@gmail.com wrote:
Hi, I'm just learning Clojure but I thought I would do a little
experiment to see where Clojure sits performance-wise compared to a
number of other languages on the old Fibonacci sequence. I think it
handles itself quite well.
Nice code chouser, always nice to see a succinct functional example.
On Dec 13, 10:15 am, Chouser chou...@gmail.com wrote:
On Sat, Dec 13, 2008 at 10:41 AM, Dmitri dmitri.sotni...@gmail.com wrote:
I wrote a simple word counter described herehttp://ptrace.fefe.de/wp/
it reads stdin and
On Dec 14, 12:08 pm, James Reeves weavejes...@googlemail.com wrote:
On Dec 14, 2:01 pm, Mike Perham mper...@gmail.com wrote:
Hi, I'm just learning Clojure but I thought I would do a little
experiment to see where Clojure sits performance-wise compared to a
number of other languages on
On Sunday 14 December 2008 09:00, harrison clarke wrote:
yep. a function f(n) is O(n) if there are constants c and n0 such
that f(n) = c * n for all n = n0.
sometimes you do care about the c and the n0, though.
To be sure.
And there can be times that, for the problem size you know you need
I've notice that the latest builds of Clojure now use strings for keys
in proxy mappings, whilst in the past they used to use symbols. Was
this change deliberate?
- James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
On Sunday 14 December 2008 10:40, James Reeves wrote:
I've notice that the latest builds of Clojure now use strings for
keys in proxy mappings, whilst in the past they used to use symbols.
Was this change deliberate?
Yes. Rich pointed this out in the SVN commit commentary for 1159:
proxy
Hi,
I ran into a special case that I'd like to avoid. When (filter ...) is
either applied to an empty collection or the filter predicate returns
false for all the elements in the supplied collection, filter returns
nil.
Would it be acceptable and desirable for it to return and empty list in
work (.getName (.getClass 0))
java.lang.Integer
work (.getName java.lang.Integer)
; Evaluation aborted.
Why does the second expression fail?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to
On Sunday 14 December 2008 11:08, Randall R Schulz wrote:
Hi,
I ran into a special case that I'd like to avoid. When (filter ...)
is either applied to an empty collection or the filter predicate
returns false for all the elements in the supplied collection, filter
returns nil.
Would it be
--- On Sun, 12/14/08, David wrote:
work (.getName java.lang.Integer)
; Evaluation aborted.
Why does the second expression fail?
Would that work in Java?
Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
More detail: I'm on a MBP with 2.2Ghz Core 2 Duo. I used Apple's
standard GCC 4.0.1 to compile with no settings (gcc fib.c -o fib).
The same code with Apple's GCC 4.2 produced the same time, I didn't
think to use an optimization flag as I haven't written C in a decade.
It looks like Michael's
On Dec 14, 2:26 pm, David dsieg...@yahoo.com wrote:
work (.getName (.getClass 0))
java.lang.Integer
work (.getName java.lang.Integer)
; Evaluation aborted.
Why does the second expression fail?
There used to be a long answer as to why:
When IS an appropriate time to use '()? It's in the language, so I
assume there must be at least one good use case.
Recently, I was writing a function that yields a sequence of all the
subsequences of a given sequence, e.g.,
(subseqs '(1 2 3)) -
(nil (1) (2) (3) (1 2) (1 3) (2 3) (1 2 3))
I
Sneaky, but I bet I'll get confused by the extra functionality at some point.
--- On Sun, 12/14/08, Rich Hickey richhic...@gmail.com wrote:
There used to be a long answer as to why:
http://groups.google.com/group/clojure/msg/8fc6f0e9a5800e4b
Now there is a short one - it does work!
On Sunday 14 December 2008 11:08, Randall R Schulz wrote:
...
It turns out that flatten (from clojure.contrib.seq-utils) is really
where I go wrong with my simple version of gather-slot-values.
Does this makes sense (specifically the last one)?
user= (flatten [])
nil
user= (flatten ())
nil
My mistake; unchecked operations work just fine if their arguments
(including constants) are given type hints. What happens if unchecked-
add/sub/... is given an argument of unknown type, though? It still
seems to work, though slowly.
On Dec 14, 12:35 pm, Michel Salim michel.syl...@gmail.com
I've moved the codebase to the Eclipse Public License as of SVN 1160:
http://opensource.org/licenses/eclipse-1.0.php
EPL is the successor to CPL, and acceptable to Google Code and others.
It allows all the same usages as did CPL, is commercial friendly etc.
Contrib should move over ASAP.
On Dec 14, 6:57 pm, Randall R Schulz rsch...@sonic.net wrote:
Yes. Rich pointed this out in the SVN commit commentary for 1159:
Ah, somehow I managed to miss that message! I should really pay closer
attention.
- James
--~--~-~--~~~---~--~~
You received this
So I have some code that looks somewhat like:
(update-in node [:index :x] set/union #{:y})
This seems fine as long as there's already a set in the desired spot.
However, since update-in will kindly build the map structure for you
if it doesn't already exist, I figured it would be nice not to
I'm trying AOT compilation for the first time. Here's what I did.
- created the directory com/ociweb below my current directory
- created the source file math.clj with the following content
(ns com.ociweb.math)
(defn fib [n] (reduce * (range 2 (inc n
- started a REPL in the current
How to dispatch on specific argument(s) of a function?
example:
(defmulti group )
(defmethod group ??? [xs n]
(loop [acc nil
x xs]
(if (not x)
(reverse acc)
(recur (cons (take n x) acc) (drop n x)
Here I want to dispatch on the class of the first argument
Hello.
I am having problems with gen-and-load-class. I have a file with an
example from the wiki book:
(gen-and-load-class 'user.UserException :extends Exception)
(defn user-exception-test []
(try
(throw (new user.UserException msg: user exception was here!!))
(catch
Mark Volkmann wrote:
I'm trying AOT compilation for the first time. Here's what I did.
- created the directory com/ociweb below my current directory
- created the source file math.clj with the following content
(ns com.ociweb.math)
(defn fib [n] (reduce * (range 2 (inc n
- started a
I've updated the Clojure classes graph (thanks for the push, R.
Schulz!) The new version includes the newest classes as well as Java
interfaces that are applicable. These latter are shown inside
diamonds.
A couple different .svg and .png versions are available here, along
with the code used to
I had some trouble understanding this at first too.
Here I want to dispatch on the class of the first argument xs.
on the first aargument, ie xs, or on the first argument of xs?
This should work:
(defmulti group
(fn [xs n]
(class xs)))
(defmulti group
(fn [xs n]
(class (first
Hi,
Looks like patch is already applied, but i now i get following error
after M-.
java.lang.IllegalArgumentException: No matching field found: separator
for class java.lang.Class (NO_SOURCE_FILE:0)
[Thrown class clojure.lang.Compiler$CompilerException]
I updated everything clojure related
Ok.. seems like the short lifespan of the agent-threads makes it hard
for the program
to actually start using its (in this case 2) multiple cpu's.
The next program has no problem filling both cpu's together for 199%
(top, linux), whilst the simulation
has trouble getting above 110%, but
Konrad,
I did some more work from the paper the parser combinator is based
on. From that I built what I think is a state monad transformer:
(defn stateT [m]
(monad [m-result (fn [v]
(fn [s]
((:m-result m) (list v s
m-bind (fn
Also, I came across set-state and fetch-state being implemented in
terms of update-state.
(defn set-state [s]
(update-state (fn [x] s)))
(defn fetch-state []
(update-state identity))
Jim
--~--~-~--~~~---~--~~
You received this message because
This is due to the change in clojure svn 1158. (.method ClassName ...)
syntax has been changed to call java.lang.Class method for ClassName,
not static field/method any more. Use namespace syntax instead.
diff --git a/swank/commands/basic.clj b/swank/commands/basic.clj
index ac0736f..4705cd5
On Sun, Dec 14, 2008 at 3:45 PM, Albert Cardona sapri...@gmail.com wrote:
Mark Volkmann wrote:
I'm trying AOT compilation for the first time. Here's what I did.
- created the directory com/ociweb below my current directory
- created the source file math.clj with the following content
(ns
On Dec 14, 6:09 am, Randall R Schulz rsch...@sonic.net wrote:
On Saturday 13 December 2008 23:19, Mark H. wrote:
So I'm going to stop pretending like I'm an expert and actually post
some Clojure code. Be constructively critical 'cause I'm a n00b in
that regard ;-) This is a pseudorandom
Hi,
I have quite a bit of Java code with I/O capabilities that generally
support both PrintStream and PrintWriter. I was a bit perplexed when I
tried to apply one of these methods to *out* and was rebuffed thusly:
java.lang.IllegalArgumentException:
No matching method found: printMessage
On Dec 14, 9:40 am, Konrad Hinsen konrad.hin...@laposte.net wrote:
Isn't that the standard Box-Muller transform?
Ah, yes, now I know what to call it ;-) Yes, it's a particular
implementation of the Box-Muller transform that is designed to avoid
trig functions.
On Sun, Dec 14, 2008 at 9:18 AM, Mark Volkmann
r.mark.volkm...@gmail.com wrote:
I see that the file clojure/contrib/test_clojure.clj does a use on
clojure.contrib.test-is.
That source file doesn't use anything else.
Is the soure file clojure/contrib/test_is/test_is.clj used by anything
or
On Dec 14, 3:16 pm, Randall R Schulz rsch...@sonic.net wrote:
Does this makes sense (specifically the last one)?
user= (flatten [])
nil
user= (flatten ())
nil
Yes; the empty sequence is just nil.
user= (flatten nil)
(nil)
That does look like a bug.
--
Michel
Hi,
The doc text for symbol is:
user= (doc symbol)
-
clojure.core/symbol
([name] [ns name])
Returns a Symbol with the given namespace and name.
However, the ns argument must be a String, not a namespace.
Would it be reasonable to allow an actual namespace as the ns
On 14.12.2008, at 18:40, Konrad Hinsen wrote:
(defn rng-uniform
Return an infinite lazy sequence of random numbers
[]
(drop 1 (iterate (fn [_] (rand)) nil)))
(defn transform-to-gaussian
Transform a sequence of uniform random number in the interval
[0, 1)
into a
I am porting some examples from Paul Graham's On Lisp book.
I have a problem with this one (fig 5. 4 page 67):
(defun fif (if then optional else)
#'(lambda (x)
(if (funcall if x)
(funcall then x)
(if else (funcall else x)
My implementation:
(defn fif [iff then
#(fif even? (fn [x] (* 2 x))) has no % sign in it, so it is a
function of zero arguments, which is not something that map can use.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this
user= (flatten nil)
(nil)
Not a bug.
flatten returns a sequence - in this case a sequence containing 'nil.
How else would you flatten on nil?
In the former cases the flatten returns the seq - nil
Can Clojure return an empty sequence otherwise?
(def x ())
(first x)
= nil
(def y x)
y
= nil
user= (flatten nil)
(nil)
Not a bug.
flatten returns a sequence - in this case a sequence containing 'nil.
How else would you flatten on nil?
In the former cases the flatten returns the seq - nil
Can Clojure return an empty sequence otherwise?
(def x ())
(first x)
= nil
(def y x)
y
= nil
On Sat, Dec 13, 2008 at 5:51 AM, Rich Hickey richhic...@gmail.com wrote:
No you can't, for the same reasons you can't for Iterator or
Enumeration seqs. Again it comes down to abstractions, and the
abstraction for (seq x) is one on persistent collections. It presumes
that (seq x) is
54 matches
Mail list logo