Re: transaction failed after retry limit

2008-12-22 Thread bOR_
Seems fairly reproducable. With a population of a 1000 people: 126288 living:939 infected: 933 ave VL: 5.5225080385852285 pro alleles in population: 63.9313139960273147(621 467 404 360 24 2) tap alleles in population: 42.7024232960074537(830 718 317 13) mhc alleles i

Re: Functional way to implement a VM?

2008-12-22 Thread Konrad Hinsen
On 22.12.2008, at 22:07, Mark Volkmann wrote: > Are you and or Jim planning to write an article on monads in Clojure > any time soon? I'd love to see that. I don't understand them well now. Where would such an article best be published? I agree that there is an interest in explaining monads sp

Re: Newbie: Creating a character from a Unicode sequence

2008-12-22 Thread Stephen C. Gilardi
On Dec 23, 2008, at 1:53 AM, Emeka wrote: What is '16' doing there? Emeka It the optional "radix" argument to parseInt, specifying that the characters being parsed should be interpreted as hexadecimal digits. http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html#parseInt(java.la

Uploaded prng-utils.clj

2008-12-22 Thread Mark H.
Spurred by discussions in the "DISCUSS: replace (rand)" thread, http://groups.google.com/group/clojure/browse_thread/thread/25dc26841ed00710/44050938894f9296?lnk=gst&q=rand#44050938894f9296 I've adapted, written, and tested some utilities for handling pseudorandom numbers. Here are the highligh

Re: Newbie: Creating a character from a Unicode sequence

2008-12-22 Thread Emeka
What is '16' doing there? Emeka --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+un

Re: Newbie: Creating a character from a Unicode sequence

2008-12-22 Thread Stephen C. Gilardi
On Dec 23, 2008, at 1:03 AM, samppi wrote: Is there a way to turn this: [\3 \5 \A \3] ...into this? \u35A3 Here's one way: user=> (#(char (Integer/parseInt (apply str %) 16)) [\3 \5 \A \3]) \㖣 user=> --Steve smime.p7s Description: S/MIME cryptographic signature

Newbie: Creating a character from a Unicode sequence

2008-12-22 Thread samppi
Is there a way to turn this: [\3 \5 \A \3] ...into this? \u35A3 --~--~-~--~~~---~--~~ 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 To unsubscribe fro

Re: Functional way to implement a VM?

2008-12-22 Thread Mark Volkmann
Konrad, Are you and or Jim planning to write an article on monads in Clojure any time soon? I'd love to see that. I don't understand them well now. It seems that most of articles that discuss them only include Haskell examples. A Clojure-centric article on monads would be very helpful. -- R. Ma

Re: Stumped - Java hangs when using Swing in Slime

2008-12-22 Thread Michael Beauregard
This is a long shot, but... It's been a while since I played with swing in clojure, but I remember the swing UI would display behind emacs. The result is that the app is correctly running despite the fact that it is obscured by other windows while your REPL appears stuck. Michael --~--~

Re: Functional way to implement a VM?

2008-12-22 Thread Konrad Hinsen
On 22.12.2008, at 12:01, Robert Feldt wrote: > I'm playing around with different designs to implement VM's (in a > functional style). Think for parsing, FSM etc. This sounds like the perfect application for the state monad - see the random number examples in http://groups.google.com/g

Re: Stumped - Java hangs when using Swing in Slime

2008-12-22 Thread levand
Update: I was actually able to sporadically replicate this problem using simply Jeffrey Chu's clojure-mode, without Slime or Swank. It only occurs on this PC. My home workstation, which is running Windows Vista and the same version of Java, works without a hitch. Again, everything works fine wh

Re: A Common Lisp format function for Clojure now up

2008-12-22 Thread Josip Gracin
On Mon, Dec 22, 2008 at 8:30 AM, Tom Faulhaber wrote: > You can see/download the current state of it in its github project: > http://github.com/tomfaulhaber/cl-format/ Great job! CL format is a great tool. --~--~-~--~~~---~--~~ You received this message because

Re: clojure.contrib.enum Exception

2008-12-22 Thread Andrew Baine
Okay, thanks Stuart. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@g

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Rich Hickey
On Dec 22, 11:57 am, Chouser wrote: > On Mon, Dec 22, 2008 at 11:31 AM, Stuart Sierra > > wrote: > > > On Dec 22, 11:05 am, Rich Hickey wrote: > >> But I think there is a tendency to bring presumptions from CL's > >> symbols/packages/interning, many of which do not apply. > > > Sounds like a

Re: ns references clarification

2008-12-22 Thread Stephen C. Gilardi
On Dec 22, 2008, at 1:42 PM, Brian Doyle wrote: It would appear that using (:import ...) and (import ...) with the ns function work the same (svn rev 1172.) 1:1 user=> (ns blah (import (java.net URL))) nil 1:2 blah=> (URL. "http://www.clojure.org";) #http://www.clojure.org> and 1:1 user=> (

ns references clarification

2008-12-22 Thread Brian Doyle
It would appear that using (:import ...) and (import ...) with the ns function work the same (svn rev 1172.) 1:1 user=> (ns blah (import (java.net URL))) nil 1:2 blah=> (URL. "http://www.clojure.org";) #http://www.clojure.org> and 1:1 user=> (ns blah2 (:import (java.net URL))) nil 1:2 blah2=> (U

Re: Numeric tower and Java's math library

2008-12-22 Thread Mark H.
On Dec 22, 8:08 am, Stuart Sierra wrote: > Yeah, I love (expt 2 64) as a Common Lisp parlor trick.  I've thought > about trying to write a Clojure "pow", but I don't know enough about > the algorithms involved.  How do you compute something like 25/9 to > the power of 3/2? That's much harder tha

Re: agents, memory usage and threads

2008-12-22 Thread prhlava
> What I found that when the JVM memory usage goes to around 26% of > available RAM, only one thread runs at the time from then on. Is this > JVM optimising? Well, it was hitting the JVM default amount of heap limit - works as expected with proper parameters to java... Sorry for the noise, Vl

Re: Exercise: how to print multiplication table?

2008-12-22 Thread Tom Faulhaber
Here's an alternative, more "mappy" definition using the cl-format function I posted earlier: (defn multipication-table [limit] (let [nums (range 1 (inc limit))] (cl-format true "~{~{~4d~}~%~}" (map #(map % nums) (map #(partial * %) nums)) user> (multipi

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Chouser
On Mon, Dec 22, 2008 at 11:31 AM, Stuart Sierra wrote: > > On Dec 22, 11:05 am, Rich Hickey wrote: >> But I think there is a tendency to bring presumptions from CL's >> symbols/packages/interning, many of which do not apply. > > Sounds like a good FAQ, or another entry in http://clojure.org/lisp

Re: A Common Lisp format function for Clojure now up

2008-12-22 Thread Tom Faulhaber
Remco, Right on both counts. I have modified it to use the (or ...) form as you suggest. Thanks, Tom --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goo

Re: SPARQL DSL - a humble request for review and guidance

2008-12-22 Thread Randall R Schulz
On Monday 22 December 2008 07:58, Michael Wood wrote: > ... > > This seems to be a lot simpler if you use keywords instead of > ?something: The tradition of using a leading question mark to designate a (logical) variable is pretty widespread, and many practitioners from the realms of automated

Re: Simple doseq problem

2008-12-22 Thread Stuart Sierra
On Dec 22, 11:10 am, Piotr 'Qertoip' Włodarek wrote: > user=> (doseq [word ("one" "two" "three")] (println word)) The problem here is that the list ("one" "two" "three") tries to evaluate "one" as a function. Try this: user=> (doseq [word (list "one" "two" "three")] (println word)) one two thr

Re: bit-and, bit-or arity question

2008-12-22 Thread ntu...@googlemail.com
On Dec 22, 12:39 am, Randall R Schulz wrote: > But I (the individual) agree, modulo a proper overloading pattern to > afford minimal overhead for the two-argument form. You mean like: (defn bit-or ([] 0) ([x] x) ([x y] (clojure.lang.Numbers/or x y)) ([x y & rest] (reduce #(clojure.

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Stuart Sierra
On Dec 22, 11:05 am, Rich Hickey wrote: > But I think there is a tendency to bring presumptions from CL's > symbols/packages/interning, many of which do not apply. Sounds like a good FAQ, or another entry in http://clojure.org/lisps If I may: "Unlike Common Lisp, symbols and keywords are just i

Re: namespace function

2008-12-22 Thread Randall R Schulz
On Monday 22 December 2008 08:10, Rich Hickey wrote: > ... > > Clojure names have distinct namespace components so they can be used > to designate/find things in namespaces. Designate, yes. Find, no, if I understand what you're saying. There's no index / repository / collection / directory / ta

Re: Exercise: how to print multiplication table?

2008-12-22 Thread J. McConnell
2008/12/22 Brian Doyle : > > 2008/12/22 J. McConnell >> >> 1:1 user=> (defn multiplication-row [n k] >> (map (partial * k) (range 1 (inc n >> #'user/multiplication-row >> 1:3 user=> (defn multiplication-table [n] >> (map (partial multiplication-row n) (range 1 (inc n >> #'user/multiplic

Re: Exercise: how to print multiplication table?

2008-12-22 Thread Chouser
On Mon, Dec 22, 2008 at 10:23 AM, Piotr 'Qertoip' Włodarek wrote: > > Being new to Clojure, to Lisp and to functional programming in > general, I have some trouble wraping my head around it. Looks to me like you're doing pretty well. > I came that far: > > (defn multiplication-row [n k] >(ma

Re: namespace function

2008-12-22 Thread J. McConnell
On Mon, Dec 22, 2008 at 11:10 AM, Rich Hickey wrote: > > On Dec 22, 10:40 am, "Mark Volkmann" > wrote: >> On Mon, Dec 22, 2008 at 9:10 AM, Rich Hickey wrote: >> >> > On Dec 22, 8:55 am, "Mark Volkmann" wrote: >> >> >> I thought that every symbol and keyword was in some namespace, >> >> default

Re: Exercise: how to print multiplication table?

2008-12-22 Thread Brian Doyle
2008/12/22 J. McConnell > On Mon, Dec 22, 2008 at 10:23 AM, Piotr 'Qertoip' Włodarek > wrote: > > > > Being new to Clojure, to Lisp and to functional programming in > > general, I have some trouble wraping my head around it. > > > > As the first exercice, I would like to print multiplication tab

Simple doseq problem

2008-12-22 Thread Piotr 'Qertoip' Włodarek
user=> (doseq [word ("one" "two" "three")] (println word)) Throws java.lang.Exception: Unable to resolve symbol: word in this context. Could you please give any working example of doseq? I've seen one or two examples on the web but they doesn't seem to work. Regards, Piotrek --~--~-~--

Re: namespace function

2008-12-22 Thread Rich Hickey
On Dec 22, 10:40 am, "Mark Volkmann" wrote: > On Mon, Dec 22, 2008 at 9:10 AM, Rich Hickey wrote: > > > On Dec 22, 8:55 am, "Mark Volkmann" wrote: > > >> I thought that every symbol and keyword was in some namespace, > >> defaulting to the current namespace when the symbol or keyword is > >>

Re: Exercise: how to print multiplication table?

2008-12-22 Thread lpetit
Hello, Not a lot of time to answer, so I'll be straight to the point below : On 22 déc, 16:23, Piotr 'Qertoip' Włodarek wrote: > Hello, > > Being new to Clojure, to Lisp and to functional programming in > general, I have some trouble wraping my head around it. > > As the first exercice, I would

Re: Numeric tower and Java's math library

2008-12-22 Thread Stuart Sierra
On Dec 22, 7:14 am, "Mark Engelberg" wrote: > Is there any kind of math library that works a bit more intelligently > with Clojure's numbers, or has anyone looked at bringing more of these > math functions into the Clojure core or contrib so that these > functions will dispatch correctly? Yeah,

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Rich Hickey
On Dec 22, 10:43 am, Randall R Schulz wrote: > On Monday 22 December 2008 07:23, Rich Hickey wrote: > > > ... > > > This conversation is way off track. > > > Symbols and keywords are not 'in' namespaces, they are not interned > > in namespaces, there are not lists of, e.g. keywords in a particu

Re: Exercise: how to print multiplication table?

2008-12-22 Thread J. McConnell
On Mon, Dec 22, 2008 at 10:23 AM, Piotr 'Qertoip' Włodarek wrote: > > Being new to Clojure, to Lisp and to functional programming in > general, I have some trouble wraping my head around it. > > As the first exercice, I would like to print multiplication table of > specified order, like: > (print-

Re: SPARQL DSL - a humble request for review and guidance

2008-12-22 Thread Michael Wood
On Mon, Dec 22, 2008 at 1:30 AM, Michael Wood wrote: > On Sun, Dec 21, 2008 at 7:03 PM, Adam Harrison (Clojure) > wrote: > [...] >> (defmacro where [& triples] >> `(let [encode# (fn [x#] (cond (and (symbol? x#) (= (first (name x#)) >> \?)) (name x#) >> (integer? x#)

Re: namespace function

2008-12-22 Thread Mark Volkmann
On Mon, Dec 22, 2008 at 9:10 AM, Rich Hickey wrote: > > On Dec 22, 8:55 am, "Mark Volkmann" wrote: >> >> I thought that every symbol and keyword was in some namespace, >> defaulting to the current namespace when the symbol or keyword is >> defined. > > Symbols and keywords aren't 'in' namespaces

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Randall R Schulz
On Monday 22 December 2008 07:23, Rich Hickey wrote: > ... > > This conversation is way off track. > > Symbols and keywords are not 'in' namespaces, they are not interned > in namespaces, there are not lists of, e.g. keywords in a particular > namespace. Then the term "namespace" is rather poorly

Exercise: how to print multiplication table?

2008-12-22 Thread Piotr 'Qertoip' Włodarek
Hello, Being new to Clojure, to Lisp and to functional programming in general, I have some trouble wraping my head around it. As the first exercice, I would like to print multiplication table of specified order, like: (print-multiplication-table 3) 1 2 3 2 4 6 3 6 9 I came that far:

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Rich Hickey
On Dec 22, 9:01 am, Randall R Schulz wrote: > On Monday 22 December 2008 05:51, Mark Volkmann wrote: > > > On Sun, Dec 21, 2008 at 2:30 PM, Randall R Schulz > wrote: > > > On Sunday 21 December 2008 11:33, chris wrote: > > >> ... > > > >> That answers my question. Don't use a namespace, and t

Re: jEdit Mode for Clojure

2008-12-22 Thread Chouser
On Tue, Dec 16, 2008 at 2:22 AM, Daniel Spiewak wrote: > > Proper regexp highlighting would be nice, but as I mentioned, I'm not > sure what the "correct" way to handle this may be. Are regular > expressions actually handled specially in the reader? If not, then we > should probably just reuse

Re: namespace function

2008-12-22 Thread Mark Volkmann
On Mon, Dec 22, 2008 at 8:08 AM, Randall R Schulz wrote: > > On Monday 22 December 2008 05:55, Mark Volkmann wrote: >> On Sun, Dec 21, 2008 at 3:44 PM, Stephen C. Gilardi wrote: >> > ... >> >> I thought that every symbol and keyword was in some namespace, >> defaulting to the current namespace wh

Re: namespace function

2008-12-22 Thread Rich Hickey
On Dec 22, 8:55 am, "Mark Volkmann" wrote: > On Sun, Dec 21, 2008 at 3:44 PM, Stephen C. Gilardi wrote: > > > > > > > On Dec 21, 2008, at 4:35 PM, Mark Volkmann wrote: > > > Why do I get an IncompatibleClassChangeError below? I'm using revision > > 1180. > > > (def my-map {:a 1 :b 2}) > > (na

Re: Functional way to implement a VM?

2008-12-22 Thread Robert Feldt
On Dec 22, 2:39 pm, Ola Bini wrote: > Well, the "classical" functional way of writing a language > implementation is to use continuation passing style. > Since you always pass one the new state to the waiting continuation you > never need to keep any explicit state around. > Yes, but I fail to

Re: namespace function

2008-12-22 Thread Mark Volkmann
On Mon, Dec 22, 2008 at 8:08 AM, Randall R Schulz wrote: > > On Monday 22 December 2008 05:55, Mark Volkmann wrote: >> On Sun, Dec 21, 2008 at 3:44 PM, Stephen C. Gilardi wrote: >> > ... >> >> I thought that every symbol and keyword was in some namespace, >> defaulting to the current namespace wh

Re: transaction failed after retry limit

2008-12-22 Thread bOR_
* So far it happened in both instances that I ran the simulation for more than 100k simulated years, so while this is reproducable, it does take a number of hours to get there. I can see if I can get the effect faster with a smaller population or something. * When I start the simulation, the mem

Re: Functional way to implement a VM?

2008-12-22 Thread Ola Bini
Robert Feldt wrote: > I'm playing around with different designs to implement VM's (in a > functional style). Think for parsing, FSM etc. > > One of the simpler I've come up with uses normal clojure funcs for > each instruction to the vm. They all take the state as a map as input > and then additio

Re: namespace function

2008-12-22 Thread Randall R Schulz
On Monday 22 December 2008 05:55, Mark Volkmann wrote: > On Sun, Dec 21, 2008 at 3:44 PM, Stephen C. Gilardi wrote: > > ... > > I thought that every symbol and keyword was in some namespace, > defaulting to the current namespace when the symbol or keyword is > defined. Since the default namespace

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Randall R Schulz
On Monday 22 December 2008 05:51, Mark Volkmann wrote: > On Sun, Dec 21, 2008 at 2:30 PM, Randall R Schulz wrote: > > On Sunday 21 December 2008 11:33, chris wrote: > >> ... > >> > >> That answers my question. Don't use a namespace, and the keyword > >> is global. Pass in a namespace, and the

Re: transaction failed after retry limit

2008-12-22 Thread Rich Hickey
On Dec 22, 7:41 am, bOR_ wrote: > Hi all, > > Long post, but it boils down that I'm running into a transaction > failed after retry limit after running my simulation for a couple of > hours. I chatted briefly with fyuryu in #clojure, and am now pasting > some of the hopefully relevant informati

Re: namespace function

2008-12-22 Thread Mark Volkmann
On Sun, Dec 21, 2008 at 3:44 PM, Stephen C. Gilardi wrote: > > On Dec 21, 2008, at 4:35 PM, Mark Volkmann wrote: > > Why do I get an IncompatibleClassChangeError below? I'm using revision > 1180. > > (def my-map {:a 1 :b 2}) > (namespace my-map) > java.lang.IncompatibleClassChangeError (NO_SOURC

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Mark Volkmann
On Sun, Dec 21, 2008 at 2:30 PM, Randall R Schulz wrote: > > On Sunday 21 December 2008 11:33, chris wrote: >> ... >> >> That answers my question. Don't use a namespace, and the keyword is >> global. Pass in a namespace, and the keyword is in that namespace. > > Yes, the default namespace for k

Re: Functional way to implement a VM?

2008-12-22 Thread Itay Maman
No doubts this is very elegant. However, I think that the underyling programming model is imperative: there's a map which is essentially a RAM. Each instruction writes to this RAM (alters the mappings in the map). It seems that a stack-machine exhibits a more functional nature: an instruction eit

Re: Functional way to implement a VM?

2008-12-22 Thread Chouser
On Mon, Dec 22, 2008 at 6:01 AM, Robert Feldt wrote: > > I'm playing around with different designs to implement VM's (in a > functional style). Think for parsing, FSM etc. > > One of the simpler I've come up with uses normal clojure funcs for > each instruction to the vm. They all take the state

Re: CLI launcher

2008-12-22 Thread Daniel Renfer
On Fri, Dec 19, 2008 at 8:27 PM, Phil Hagelberg wrote: > > "Tom Emerson" writes: > >> On Thu, Dec 18, 2008 at 12:56 PM, Phil Hagelberg >> wrote: >>> This was one of the most disorienting things I encountered when starting >>> with clojure. I'm used to codebases providing a bin/ directory or at

transaction failed after retry limit

2008-12-22 Thread bOR_
Hi all, Long post, but it boils down that I'm running into a transaction failed after retry limit after running my simulation for a couple of hours. I chatted briefly with fyuryu in #clojure, and am now pasting some of the hopefully relevant information into this post. Hope anyone can shed a ligh

Re: How to encapsulate local state in closures

2008-12-22 Thread Mark Engelberg
On Mon, Dec 22, 2008 at 4:23 AM, Parth Malwankar wrote: > If I get it right, atoms are quite useful to maintain state > in the context of a single thread with memoization and > counter (within a thread) being two examples. No, RH said that atoms were definitely intended for multiple threads, not

Re: How to encapsulate local state in closures

2008-12-22 Thread J. McConnell
On Mon, Dec 22, 2008 at 2:25 AM, Mark Engelberg wrote: > > Aside from the memoization example for > which it was invented, I am hard-pressed to think of a good use for > atoms. Not having used them myself, I can't think of many good examples either. However, one in addition to the cache example

Re: How to encapsulate local state in closures

2008-12-22 Thread Parth Malwankar
On Dec 22, 12:25 pm, "Mark Engelberg" wrote: > I misspoke; it's the call to counter that's the problem.  Let's say > you want to use a counter to count the number of times a ref is set, > something like this: > > (dosync (counter) (ref-set r 1)) > > If your var-set causes the transaction to ret

Numeric tower and Java's math library

2008-12-22 Thread Mark Engelberg
Clojure has pretty decent support for the so-called numeric tower. But most of the math operations in Java's math library only work on doubles. In PLT Scheme, I can do stuff like this: (sqrt 115792089237316195423570985008687907853269984665640564039457584007913129639936) and it outputs: 34028236

Re: doc strings for multimethods?

2008-12-22 Thread J. McConnell
On Sun, Dec 21, 2008 at 12:07 AM, Jason wrote: > > Thanks all. The patch looks interesting to me, although I'd only use > it if it was integrated into the main build. You and me both ;) - J. --~--~-~--~~~---~--~~ You received this message because you are subscr

Modulo

2008-12-22 Thread Mark Engelberg
Anyone know why there is no modulo or mod function in Clojure's core? I know there is a rem function, but that's not the same thing. mod and rem behave differently when the first number is negative. (mod -2 5) -> 3 (rem -2 5) -> -2 modulo n is important for making things stay in the range from

Re: Functional way to implement a VM?

2008-12-22 Thread Robert Feldt
On Dec 22, 12:27 pm, verec wrote: > The design simplicity is certainly very appealing, though it appears > that you can only operate on a predetermined fixed set of > "registers" (ie: a and b in your example) and would need to define as > many add_, sub_, mul_ ... variants as there are 'registe

Re: Functional way to implement a VM?

2008-12-22 Thread verec
The design simplicity is certainly very appealing, though it appears that you can only operate on a predetermined fixed set of "registers" (ie: a and b in your example) and would need to define as many add_, sub_, mul_ ... variants as there are 'registers' in your model. Also, simple arithmetic s

Functional way to implement a VM?

2008-12-22 Thread Robert Feldt
I'm playing around with different designs to implement VM's (in a functional style). Think for parsing, FSM etc. One of the simpler I've come up with uses normal clojure funcs for each instruction to the vm. They all take the state as a map as input and then additional arguments. They all return

Re: A Common Lisp format function for Clojure now up

2008-12-22 Thread Remco van 't Veer
Good morning Tom, Skimming through the code I found: (defmacro aif [test then-form else-form] `(let [~'it ~test] (if ~test ~then-form ~else-form))) The test form is evaluated twice, probably not what you want. You could replace this macro with an (or ..) form