Re: Roman Numerals

2009-03-04 Thread David Sletten
On Mar 3, 2009, at 4:53 AM, Chouser wrote: (defn roman? [roman-string] (and (not (empty? roman-string)) (re-matches #(?:M{0,3})(?:D?C{0,3}|C[DM])(?:L?X{0,3}|X[LC])(?:V?I{0,3}|I [VX])$ roman-string))) The normal idiom in Clojure is (seq x) instead of (not (empty?

Re: Waterfront - The Clojure-based editor for Clojure

2009-03-04 Thread aperotte
Michael, Itay, I apologize, that was actually an intermediate script. I also incorporated Michael's suggestion. The only thing that's different from Michael's is the addition of the bin directory. This is my current script: #!/bin/bash DP=${0%/*} java -cp

Re: Waterfront - The Clojure-based editor for Clojure

2009-03-04 Thread aperotte
Michael, Itay, I apologize, that was actually an intermediate script. I also incorporated Michael's suggestion. The only thing that's different from Michael's is the addition of the bin directory. Also, my script assumes that you've set a CLASSPATH environment variable to contain the clojure

pmap slower than map when reducing

2009-03-04 Thread Dimiter malkia Stanev
Hi guys, In the example below, if map is replaced with pmap, it goes twice slower on my MBP (2 CPUs). I believe it's probably the (reduce + ...) causing it, but I can't explain it. Version with map: user (time (pnpolytest)) Elapsed time: 3903.533 msecs 600 Version with pmap: user (time

Inclusive-exclusive range

2009-03-04 Thread Mibu
Why does range in Clojure use an inclusive-exclusive range? I'm aware of the traditional substring range convention, which always puzzled me as to how an unintuitive and error-prone use became cemented as the norm. I'm not calling for a change in range. I'm just genuinely curious.

Re: Roman Numerals

2009-03-04 Thread Chouser
On Wed, Mar 4, 2009 at 4:43 AM, David Sletten da...@bosatsu.net wrote: Conversely, when says side effect. This is clear for 2 reasons. First, there is no else clause, so when doesn't really work as an expression. Furthermore, the forms in the when body are evaluated in an implicit do. Since

Re: The Application Context Pattern

2009-03-04 Thread Glen Stampoultzis
Hi Itay, Thanks for posting this example. Being new to Clojure it's a nice example to study since it solves a very realistic problem that many new to functional programming will face. I think I've unraveled most of how the code is working but there's one function I'm not particularly clear

Re: Inclusive-exclusive range

2009-03-04 Thread Joshua Fox
With pointer-based strings or arrays, as in C , it is natural to start at index 0, so that you can do pointer arithmetic: address+0 is the first character/item. Then, if you have a string or array of length n, the last item is at n-1. Joshua On Wed, Mar 4, 2009 at 2:07 PM, Mibu

Re: Inclusive-exclusive range

2009-03-04 Thread Michael Wood
On Wed, Mar 4, 2009 at 2:07 PM, Mibu mibu.cloj...@gmail.com wrote: Why does range in Clojure use an inclusive-exclusive range? I'm aware of the traditional substring range convention, which always puzzled me as to how an unintuitive and error-prone use became cemented as the norm. I'm not

Metadata on functions

2009-03-04 Thread Konrad Hinsen
Rich, is there a reason why metadata is explicitly disabled on function objects? I find myself wanting to put metadata on functions frequently. It seems even more important for functions than for anything else, given that there is no way to inspect a function object at all, it's a

Re: Metadata on functions

2009-03-04 Thread Anand Patil
On Wed, Mar 4, 2009 at 12:50 PM, Konrad Hinsen konrad.hin...@laposte.netwrote: Rich, is there a reason why metadata is explicitly disabled on function objects? I find myself wanting to put metadata on functions frequently. It seems even more important for functions than for anything else,

Re: Inclusive-exclusive range

2009-03-04 Thread Joshua Fox
This is discussed, with references, here http://en.wikipedia.org/wiki/Array#Index_of_the_first_element --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Inclusive-exclusive range

2009-03-04 Thread Mibu
On Mar 4, 2:46 pm, Michael Wood esiot...@gmail.com wrote: On Wed, Mar 4, 2009 at 2:07 PM, Mibu mibu.cloj...@gmail.com wrote: Why does range in Clojure use an inclusive-exclusive range? For what it's worth, Python's range function works the same way. I think Clojure's design leans towards

Re: Inclusive-exclusive range

2009-03-04 Thread Mibu
Joshua, my puzzlement is not with the first element but the last. For example, the (range -1 2) gives (-1 0 1). On Mar 4, 3:06 pm, Joshua Fox joshuat...@gmail.com wrote: This is discussed, with references, herehttp://en.wikipedia.org/wiki/Array#Index_of_the_first_element

Re: Inclusive-exclusive range

2009-03-04 Thread Konrad Hinsen
On Mar 4, 2009, at 14:06, Mibu wrote: On Mar 4, 2:46 pm, Michael Wood esiot...@gmail.com wrote: On Wed, Mar 4, 2009 at 2:07 PM, Mibu mibu.cloj...@gmail.com wrote: Why does range in Clojure use an inclusive-exclusive range? For what it's worth, Python's range function works the same way. I

Re: Inclusive-exclusive range

2009-03-04 Thread Itay Maman
(+1 for Konrad's point regarding concat). Two points, in favor of 0-based indexing (as opposed to 1-based) When you look at a piece of code and see zero used as an index into some custom-made collection, you immediately know that this is a reference to the first item. Except for the rare cases

Re: Metadata on functions

2009-03-04 Thread Rich Hickey
On Mar 4, 2009, at 7:50 AM, Konrad Hinsen wrote: Rich, is there a reason why metadata is explicitly disabled on function objects? I find myself wanting to put metadata on functions frequently. It seems even more important for functions than for anything else, given that there is no way

Re: Inclusive-exclusive range

2009-03-04 Thread Meikel Brandmeyer
Hi, Am 04.03.2009 um 14:06 schrieb Mibu: On Mar 4, 2:46 pm, Michael Wood esiot...@gmail.com wrote: On Wed, Mar 4, 2009 at 2:07 PM, Mibu mibu.cloj...@gmail.com wrote: Why does range in Clojure use an inclusive-exclusive range? For what it's worth, Python's range function works the same way.

Clojure creates lots of classloaders

2009-03-04 Thread Hendrik
Hi, I got a question: Clojure seems to create poopillions of DynamicClassLoader instances. Why does it do that? Could I try patching it so that it creates less of them? I need this cause I ran into trouble working with JNI. I looked at the Clojure source rev 1323. I'm no expert, this is my

Re: Metadata on functions

2009-03-04 Thread Rich Hickey
On Mar 4, 10:46 am, Konrad Hinsen konrad.hin...@laposte.net wrote: On Mar 4, 2009, at 15:09, Rich Hickey wrote: Supporting with-meta for fns requires they be copyable with new metadata (as are all the persistent collections and symbols). I haven't decided how best to support that

Re: Clojure creates lots of classloaders

2009-03-04 Thread Joshua Fox
I think it is the best way to load and discard lots of dynamically-loaded and in fact dynamically-generated classes. Joshua On Wed, Mar 4, 2009 at 5:21 PM, Hendrik geheimm...@gmail.com wrote: Hi, I got a question: Clojure seems to create poopillions of DynamicClassLoader instances. Why does

warning on mutation

2009-03-04 Thread Joshua Fox
Can Clojure generate warnings when a function has side effects, particularly in transactions and other places where one should avoid them? Perhaps just a warning on access to any objects other than those of Clojure types and pre-approved immutable Java types (String, Number, etc.)? Joshua

Re: Clojure creates lots of classloaders

2009-03-04 Thread pmf
Without dedicated classloaders, temporary (dynamically created) classes would leak (since there is no way to unload a class without letting its classloader be garbage collected). This might or might not be the reason why Clojure uses many classloaders.

Re: warning on mutation

2009-03-04 Thread Jeffrey Straszheim
Not exactly, but there is the IO! macro (see core.clj) that you can use to mark your side effect generating code. On Wed, Mar 4, 2009 at 10:49 AM, Joshua Fox joshuat...@gmail.com wrote: Can Clojure generate warnings when a function has side effects, particularly in transactions and other

Re: Clojure creates lots of classloaders

2009-03-04 Thread Jeffrey Straszheim
This was to fix a bug where new code (generated by (eval ...)) would never get garbage collected and crashed some programs that used eval heavily. The JVM has a limitation that it will never GC a loaded class, but can GC a collection of classes referenced by a single classloader. On Wed, Mar 4,

Re: Question on names of errors in error-kit

2009-03-04 Thread samppi
Yeah. Personally, I don't think they should stand out any more than a struct basis needs to stand out. (defstruct person :fname :lname) (struct person Bob Joe) (deferror parse-error {...}) (raise parse-error ...) Defined errors are just variables in a namespace, whose siblings include the

Re: Question on names of errors in error-kit

2009-03-04 Thread Chouser
On Wed, Mar 4, 2009 at 11:34 AM, samppi rbysam...@gmail.com wrote: Yeah. Personally, I don't think they should stand out any more than a struct basis needs to stand out. SVN rev 565 has '*error*' renamed to 'error', and the example updated. This is a breaking change if you were using the

fitness

2009-03-04 Thread Dan
I am doing a genetic algorithm my individual have various immutable characteristics, one of them being their fitness. The problem I have with it is that fitness is somewhat expensive and can be requested zero (the individual will undergo some transformation and the fitness of the intermediary

Clojure-contrib build fails

2009-03-04 Thread timc
After checking out the trunk of clojure-contrib (revision 565) and doing ant jar, I get this: compile_clojure: [java] Compiling clojure.contrib.accumulators to C: \eclipseWS1\clojure-cont rib\classes [java] java.lang.IllegalArgumentException: fn params must be Symbols (accum

Re: fitness

2009-03-04 Thread Meikel Brandmeyer
Hi, Am 04.03.2009 um 18:21 schrieb Dan: How can I have my fitness computation be triggered on first access and reused afterward? Maybe you can use a Delay. {:fitness (delay (compute-my-fitness))} And when you access the value use force. (- my-thing :fitness force) The first time it

JavaWorld article

2009-03-04 Thread Joshua Fox
I am working on a short article to appear in JavaWorld sometime this spring. Its goal is to encourage senior Java developers to learn more about Clojure. The audience is experienced and knowledgeable about Java, but LISP to them is a distant memory from college. So, rather than present a tutorial,

Re: Clojure-contrib build fails

2009-03-04 Thread Stephen C. Gilardi
I'm not getting that exception. The fact that ant jar is compiling code means that you've specified a clojure.jar property for ant in some way other than the command line (properties file?). One thing to check is whether the clojure.jar at that path was built from the current svn checkout

Re: Clojure-contrib build fails

2009-03-04 Thread Konrad Hinsen
On Mar 4, 2009, at 18:21, timc wrote: After checking out the trunk of clojure-contrib (revision 565) and doing ant jar, I get this: compile_clojure: [java] Compiling clojure.contrib.accumulators to C: \eclipseWS1\clojure-cont rib\classes [java]

Re: JavaWorld article

2009-03-04 Thread Itay Maman
On Mar 4, 7:33 pm, Joshua Fox joshuat...@gmail.com wrote: I am working on a short article to appear in JavaWorld sometime this spring. Its goal is to encourage senior Java developers to learn more about Clojure. The audience is experienced and knowledgeable about Java, but LISP to them is

Re: JavaWorld article

2009-03-04 Thread Itay Maman
Sorry, this was supposed to be offline On Mar 4, 8:29 pm, Itay Maman itay.ma...@gmail.com wrote: On Mar 4, 7:33 pm, Joshua Fox joshuat...@gmail.com wrote: I am working on a short article to appear in JavaWorld sometime this spring. Its goal is to encourage senior Java developers to

Re: Clojure creates lots of classloaders

2009-03-04 Thread Chas Emerick
Hendrik, I came across this issue with JNI libs some years ago, and also comes up in the context of most app servers, which use a multitude of classloaders to enable hot code reloading and such. The general solution is to move your JNI lib into your boot classpath; in my experience with

Re: JavaWorld article

2009-03-04 Thread Chas Emerick
Joshua, I'd be happy to take a look if it'd be helpful. Cheers, Chas Emerick Founder, Snowtide Informatics Systems Enterprise-class PDF content extraction cemer...@snowtide.com http://snowtide.com | +1 413.519.6365 On Mar 4, 2009, at 12:33 PM, Joshua Fox wrote: I am working on a short

Re: The Application Context Pattern

2009-03-04 Thread Glen Stampoultzis
Thank you. Makes perfect sense to me now. 2009/3/5 Itay Maman itay.ma...@gmail.com Suppose you have three observers: o1, o2, o3. run-observers evaluates them in this order. Let's assume we don't have run-observers-till-fixpoint. Thus, after the evaluation of a processor we will use

Re: fitness

2009-03-04 Thread bOR_
If you use hash-maps, or a struct-map as the basis of your individual, you can just make a key 'fitness', and store the once-calculated fitness in there. I'm not sure how, but it might be possible that at the creation of your animals, you assign the key 'fitness' a basic function that upon being

Re: Game of Life

2009-03-04 Thread Larry Sherrill
I've incorporated everyone's suggestions and thought I would post the resulting smaller code. I refactored init-cells away and just pass in an init or new function to calc-state to reuse the for loop. I made determine-next-state a little more verbose than technically necessary to make conway's

Re: Clojure creates lots of classloaders

2009-03-04 Thread Chas Emerick
That's a good point. Does such usage cause some failure, or is it a performance issue? I would think that prior generations' code (classes + classloader(s)) would get GC'd as necessary -- or is the number of created classloaders so significant as to hit some serious limitation? - Chas

Accessing ASM?

2009-03-04 Thread Robert Feldt
Can we access the ASM used by clojure internally from clojure code? Anyone has an example? I need to write a bytecode transformer to trace the execution of a Java class. Would be great to be able to work with asm from within clojure. --~--~-~--~~~---~--~~ You

Re: Clojure creates lots of classloaders

2009-03-04 Thread Jeffrey Straszheim
I dies with a MaxPermGen exception. On Wed, Mar 4, 2009 at 3:27 PM, Chas Emerick cemer...@snowtide.com wrote: That's a good point. Does such usage cause some failure, or is it a performance issue? I would think that prior generations' code (classes + classloader(s)) would get GC'd as

Re: fitness

2009-03-04 Thread Jason Wolfe
Let me add my 2 cents here. The delay solution seems like the right one, with one caveat: two otherwise identical individuals will no longer have the same hash value or compare as =. If you're trying to remove duplicate individuals or some such, this may be a problem; otherwise, probably not.

Re: Accessing ASM?

2009-03-04 Thread Itay Maman
I guess my response is why not?. ASM is a Java library. Clojure works with Java. Where's the catch? (or maybe I am missing something) -- Itay Maman http://javadots.blogspot.com On Mar 4, 11:09 pm, Robert Feldt robert.fe...@gmail.com wrote: Can we access the ASM used by clojure internally from

Metadata for namespaces

2009-03-04 Thread pmf
Hi, is there a way to attach metadata (especially a docstring) to namespaces? The Namespace-class implements (via AReference - IReference - IMeta) the IMeta-interface, but the obvious way of using the reader-macro to attach metadata does not work and I don't know any other way. I.e. I would

Re: Metadata for namespaces

2009-03-04 Thread Meikel Brandmeyer
Hi, Am 04.03.2009 um 23:24 schrieb pmf: is there a way to attach metadata (especially a docstring) to namespaces? The Namespace-class implements (via AReference - IReference - IMeta) the IMeta-interface, but the obvious way of using the reader-macro to attach metadata does not work and I don't

Re: Accessing ASM?

2009-03-04 Thread Robert Feldt
I meant if ASM is already coming with clojure since it is used by clojure when generating bytecode. Maybe I am missing something... ;) Anyway, I can use the normal way. On Mar 4, 11:04 pm, Itay Maman itay.ma...@gmail.com wrote: I guess my response is why not?. ASM is a Java library. Clojure

Re: Metadata for namespaces

2009-03-04 Thread pmf
On Mar 4, 11:31 pm, Meikel Brandmeyer m...@kotka.de wrote: (ns foo.bar    docstring goes here    ...) Thanks a lot, this works for me. (Perhaps this should be mentioned in the documentation of the ns-form.) --~--~-~--~~~---~--~~ You received this message

Re: Synchronous watches

2009-03-04 Thread Anand Patil
On Wed, Mar 4, 2009 at 10:35 AM, Anand Patil anand.prabhakar.pa...@gmail.com wrote: Hi Rich, I like the flexibility of the new watches, but I'm missing a way to watch for errors. Currently, if an agent's action results in an error its watchers aren't even triggered. Thanks, Anand

Re: Game of Life

2009-03-04 Thread Raffael Cavallaro
In my experience, life is a bit more interesting if the field wraps and it is square. Here are some mods to your most recent version that does this. I've also parameterized the field size, the delay, and the initial probability of a cell being occupied. Thanks for sharing this - it's fun.

Re: Accessing ASM?

2009-03-04 Thread MikeM
On Mar 4, 5:39 pm, Robert Feldt robert.fe...@gmail.com wrote: I meant if ASM is already coming with clojure since it is used by clojure when generating bytecode. Maybe I am missing something... ;) You can look at genclass.clj for an example of using the ASM that is bundled with Clojure.

Clojure's syntax design: macros vs functions

2009-03-04 Thread Elena
I wonder if Clojure does employ the same syntax either for macros and functions by design or it's just a remainder of Lisp. I think that a shared syntax for both macros and functions calls is a flaw in the syntax of Lisps, because you can't tell, just by looking at a form, which expressions get

Re: Clojure's syntax design: macros vs functions

2009-03-04 Thread Matt Revelle
On Mar 4, 2009, at 8:03 PM, Elena wrote: I wonder if Clojure does employ the same syntax either for macros and functions by design or it's just a remainder of Lisp. I think that a shared syntax for both macros and functions calls is a flaw in the syntax of Lisps, because you can't tell,

Re: Clojure's syntax design: macros vs functions

2009-03-04 Thread MikeM
I think that a shared syntax for both macros and functions calls is a flaw in the syntax of Lisps, because you can't tell, just by looking at a form, which expressions get evaluated and which don't, at least when you are dealing with side effects. You might want to think about macros such

Re: Clojure's syntax design: macros vs functions

2009-03-04 Thread Stuart Sierra
Hi Elena, I thinks the Lisp convention says something about how to think about Lisp programs. Well-written macros shouldn't require you to think about the fact that they are macros. Instead of thinking about functions calls vs. macro calls, try to think of forms. A form can be a function call

When in Rome

2009-03-04 Thread David Sletten
On Mar 4, 2009, at 3:56 AM, Rich Hickey wrote: Conversely, when says side effect. This is clear for 2 reasons. First, there is no else clause, so when doesn't really work as an expression. Furthermore, the forms in the when body are evaluated in an implicit do. Since only the final value

Re: :use feature requests

2009-03-04 Thread Jason Wolfe
Intentionally referring an entire namespace in and also aliasing it seems a very odd thing to do. The number of libs this change would break is very likely to be tiny and the breakage will be obvious and easy to fix. I just ran into an instance where I might want to do just this. I have a

Re: Synchronous watches

2009-03-04 Thread Timothy Pratley
Also, (remove-watch a key) fails to raise an error if a doesn't have any watches associated with key. Just curious why you would want it to? Might you be equally served with something like (get-watches a) so you can determine if a key is there to be removed? (defn get-watches

Re: Synchronous watches

2009-03-04 Thread Timothy Pratley
I forgot to mention the reason I don't feel it should be an error to remove a non-existent watch user= (dissoc {:a 1 :b 2} :c) {:a 1, :b 2} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to

Re: :use feature requests

2009-03-04 Thread Chouser
On Wed, Mar 4, 2009 at 10:10 PM, Jason Wolfe jawo...@berkeley.edu wrote: I have a file really/long/namespace/util.clj with a bunch of utilities, structs, and method definitions.  Following (what I gather is) an accepted convention, these structs have a :class key that maps to a

Modular composition/plugin architecture

2009-03-04 Thread Adrian Cuthbertson
Hi, How would one create a plugin modular composition using clojure functions/modules only (i.e without resorting to java interface/ plugin class implementations)? For example; ; say myutil/ut1.clj contains (ns 'myutil.ut1) (defn foo [] :foo-ut1) ; and myutil/ut2.clj contains (ns 'myutil.ut2)

Re: :use feature requests

2009-03-04 Thread Stephen C. Gilardi
On Mar 4, 2009, at 11:46 PM, Chouser wrote: Adding an :all option as Steve suggests would clean this up even more: (ns util (:use [really.long.namespace.util :as util :all])) I looked into this further after suggesting it and was reminded that it would be difficult to support an

Re: Roman Numerals

2009-03-04 Thread Tom Faulhaber
BTW, cl-format (my Common Lisp format function for Clojure), supports the ~...@r directive for converting Arabic to Roman (but nothing to go the other way around. I didn't spend too much time thinking about stylistic issues when I wrote it, but if you're interested you can compare. It's at