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 http://
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 option
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)
On Wed, Mar 4, 2009 at 10:10 PM, Jason Wolfe 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 namespace-qualified keyword.
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 t
> 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 [#^clojure.lang.
> 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
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 o
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 cal
>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 s
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,
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 ev
On Mar 4, 5:39 pm, Robert Feldt 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.
--~--~-~--~
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.
((imp
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,
> An
On Mar 4, 11:31 pm, Meikel Brandmeyer 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 because you are
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 wrote:
> I guess my response is "why not?". ASM is a Java library. Clojure
> works with Java.
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'
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 li
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 wrote:
> Can we access the ASM used by clojure internally from clojure code?
> Any
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
I dies with a MaxPermGen exception.
On Wed, Mar 4, 2009 at 3:27 PM, Chas Emerick 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 necessary -- or is the
>
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 receiv
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
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 rul
Many people consider the use of eval in "normal" code to be bad style.
However, there are times when it is justified, such as genetic programming
or dynamic code loading. In these cases Clojure falls down without the
classloader trick.
On Wed, Mar 4, 2009 at 3:03 PM, Chas Emerick wrote:
>
> He
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
Thank you. Makes perfect sense to me now.
2009/3/5 Itay Maman
>
> 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 run-observers to run th
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 ar
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
Thanks Konrad - that did the trick!
On Mar 4, 5:43 pm, Konrad Hinsen wrote:
> 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.accumulat
Sorry, this was supposed to be offline
On Mar 4, 8:29 pm, Itay Maman wrote:
> On Mar 4, 7:33 pm, Joshua Fox 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
On Mar 4, 7:33 pm, Joshua Fox 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 a distant memory
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] java.lang.IllegalArgumen
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
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,
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
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
ulators.c
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 stat
On Wed, Mar 4, 2009 at 11:34 AM, samppi 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 name '*error*'
direc
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
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, 2
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 wrote:
> Can Clojure generate warnings when a function has side effects,
> particularly in transactions and other places where one should
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.
--~--~-~--~~~---~
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
--~--
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 wrote:
>
> Hi,
>
> I got a question: Clojure seems to create poopillions of
> DynamicClassLoader instances. Why does it do that? Cou
On Mar 4, 10:46 am, Konrad Hinsen 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 copyability for fns that
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 copyability for fns that are
> closures while minimizing the overhead for fns
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
first
Hi,
Am 04.03.2009 um 14:06 schrieb Mibu:
On Mar 4, 2:46 pm, Michael Wood wrote:
On Wed, Mar 4, 2009 at 2:07 PM, Mibu 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
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 i
On Mar 4, 2009, at 4:43 AM, David Sletten wrote:
>
> 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-str
(+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 o
On Wed, Mar 4, 2009 at 3:17 PM, Mibu wrote:
>
> Joshua, my puzzlement is not with the first element but the last.
>
> For example, the (range -1 2) gives (-1 0 1).
Because, if you have a vector of 10 elements, (and your language
starts indexing from 0) you can use (range 10) for the indexes,
ins
On Mar 4, 2009, at 14:06, Mibu wrote:
> On Mar 4, 2:46 pm, Michael Wood wrote:
>> On Wed, Mar 4, 2009 at 2:07 PM, Mibu 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 to
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 wrote:
> This is discussed, with references,
> herehttp://en.wikipedia.org/wiki/Array#Index_of_the_first_element
--~--~-~--~~~--
On Mar 4, 2:46 pm, Michael Wood wrote:
> On Wed, Mar 4, 2009 at 2:07 PM, Mibu 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 what's right more than what's
custom eve
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 clojure@goog
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 run-observers to run these
observers.
Under this scenario, what will happen if o3 will return a ne
On Wed, Mar 4, 2009 at 12:50 PM, 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 ther
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
comple
On Wed, Mar 4, 2009 at 2:07 PM, Mibu 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 calling for a
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 wrote:
>
> Why d
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 about.
On Wed, Mar 4, 2009 at 4:43 AM, David Sletten 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 o
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.
--~--~---
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
On Feb 27, 2:57 pm, Rich Hickey wrote:
> I've added (back)synchronouswatches(svn 1309+), which us
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
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 ja
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 "$CLASSPATH:${DP}/clj:${DP}/java:${
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
71 matches
Mail list logo