Re: Elegant way of expressing this in Clojure?

2010-05-28 Thread Meikel Brandmeyer
Hi,

On May 27, 9:50 pm, Laurent PETIT laurent.pe...@gmail.com wrote:

 But you will still have the cost of creating 2 or 3 times several millions
 of Seq objects, even if they are quickly made GCable.

But then: why do it in Clojure, when you need close control anyway?
I see the main benefit in Clojure in having very high-level structures
available. If their use is not feasible, why not simply drop down to
Java or Assembly or whatever? The resulting Clojure code will be just
as ugly anyway.

 The OP said that arrays will be several gigabytes in size, so even if the
 set of different docs in much less than that by an order of magnitude (or
 even 2), memoizing a million of docs and then being forced to kill the VM
 may not be an option for him !

Ah ok. The OP said also, that loading a new document
invalidates the previous one, which I understood as it
releases the resources of the previous one. Buffers and
such. But you would still have references to now invalid
structures building up in the memoize cache. You are
right.

Here the modified memoize could come in handy with a
FifoStrategy and queue size of 1. So as soon as the next
document is loaded the previous one would drop out of the
memoize cache.

Sincerely
Meikel

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-28 Thread Laurent PETIT
2010/5/28 Luke VanderHart luke.vanderh...@gmail.com

  Why not design it so that it can be backed by Swing or SWT or HTML
  (perhaps with some AJAX) or whatever?  It seems kind of silly to do an
  abstraction on a single backend, don't you think?

 Ideally, yes. In practice, I'd rather implement one framework well
 than implement only the lowest common denominator of several. We're
 not just talking creating a window with menus and a few buttons - My
 project, for example, is a word processor. Having a requirement that
 it work across multiple GUI toolkits sounds a little bit hellish.

 That said, I do plan the core API to be abstract enough from the
 underlying implementation that it could in theory be backed by a
 different framework. I just don't intend to do the work of providing
 bindings to multiple implementations and ensuring that behavior is
 consistent. If some enterprising soul wants to use the same basic
 interfaces to front an alternative implementation, I'll certainly try
 to make it conducive to that. But having a API with seamlessly
 interchangeable back-ends doesn't sound very feasible.

 By the way, do the SWT people only come out at night? Or is it a US vs
 Europe issue? Seems somewhat curious that 7 in a row vote for Swing,
 then the next 4 are all SWT advocates. Should I expect the QT fans to
 show up tomorrow? :p


From my little experience with counterclockwise (clojure eclipse plugin
adoption), there seems clearly to be more adoption of Eclipse technologies
in Europe than in USA.

That said, and being an Eclipse guy myself at work, and given the arguments
that say deployment is part of the dev job (which is partly true, deployment
is often devoted to specialized teams, not necessarily the dev teams), I
maintain my idea that starting with Swing may be easier for you.
The ideas of interfaces done with Swing not being performant enough seem
dated to me. IntelliJ IDEA, the new generation of Netbeans have certainly
proven that it is possible to write big professional applications with
Swing.

My 0.02 €,

-- 
Laurent

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Elegant way of expressing this in Clojure?

2010-05-28 Thread Laurent PETIT
2010/5/28 Meikel Brandmeyer m...@kotka.de

 Hi,

 On May 27, 9:50 pm, Laurent PETIT laurent.pe...@gmail.com wrote:

  But you will still have the cost of creating 2 or 3 times several
 millions
  of Seq objects, even if they are quickly made GCable.

 But then: why do it in Clojure, when you need close control anyway?
 I see the main benefit in Clojure in having very high-level structures
 available. If their use is not feasible, why not simply drop down to
 Java or Assembly or whatever? The resulting Clojure code will be just
 as ugly anyway.


Agreed. But the question was how to stick with clojure, write it the most
elegantly while still being performant :)



  The OP said that arrays will be several gigabytes in size, so even if the
  set of different docs in much less than that by an order of magnitude (or
  even 2), memoizing a million of docs and then being forced to kill the VM
  may not be an option for him !

 Ah ok. The OP said also, that loading a new document
 invalidates the previous one, which I understood as it
 releases the resources of the previous one. Buffers and
 such. But you would still have references to now invalid
 structures building up in the memoize cache. You are
 right.

 Here the modified memoize could come in handy with a
 FifoStrategy and queue size of 1. So as soon as the next
 document is loaded the previous one would drop out of the
 memoize cache.


Indeed

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure Master on android

2010-05-28 Thread Remco van 't Veer
On 2010/05/28 01:45, MHOOO wrote:

 After reading on the dev group about running clojure on android I
 figured I might just as well try the hello-dalvik example myself.
 However the master branch fails because it is exhausing the heap?:

 --
 tho...@lisper:~/sources/clojure$ ./hello-dalvik.sh
 Compiling HelloDalvik to .

 UNEXPECTED TOP-LEVEL ERROR:
 java.lang.OutOfMemoryError: Java heap space

 Anyone else experience this error?

Try giving the dx command a bit more memory by adding something like:

  -Jmx1024m

before --dex.

For reference: I am not experiencing this problem on ubuntu lucid using
openjdk.

HTH,
Remco

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Newbie (with no Java experience) - how best to learn?

2010-05-28 Thread Alex Ott
Re all

Dave Pawson  at Thu, 27 May 2010 20:08:53 +0100 wrote:
 DP Is there a wiki where all these info sources could be collected please?
 DP Sounds really quite useful to the newbie.

Just FYI - I have special page (http://alexott.net/en/clojure/video.html)
with links to video lectures/screencasts about Clojure


-- 
With best wishes, Alex Ott, MBA
http://alexott.blogspot.com/   http://alexott.net
http://alexott-ru.blogspot.com/

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Newbie (with no Java experience) - how best to learn?

2010-05-28 Thread Dave Pawson
On 28 May 2010 08:30, Alex Ott alex...@gmail.com wrote:
 Re all

 Dave Pawson  at Thu, 27 May 2010 20:08:53 +0100 wrote:
  DP Is there a wiki where all these info sources could be collected please?
  DP Sounds really quite useful to the newbie.

 Just FYI - I have special page (http://alexott.net/en/clojure/video.html)
 with links to video lectures/screencasts about Clojure

Thanks Alex.
How to link to it from the clojure setup?

regards

-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Problem seeing fn metadata unless I eval or load a file

2010-05-28 Thread Christophe Grand
Actually it's a duplicate of ticket #270
http://www.assembla.com/spaces/clojure/tickets/270

On Thu, May 27, 2010 at 4:52 PM, Jim Menard jim.men...@gmail.com wrote:

 Christophe,

 Thank you for your research and for opening the ticket.

 Jim

 On Thu, May 27, 2010 at 9:59 AM, Christophe Grand christo...@cgrand.net
 wrote:
  Hi,
 
  On Thu, May 27, 2010 at 3:28 PM, Jim Menard jim.men...@gmail.com
 wrote:
 
  I've given some functions metadata that I want to use elsewhere. My
  problem is, I don't see the metadata I've added if I use or require
  the namespace; I need to explicitly load the file (or eval the
  function definitions manually in slime/swank) to see the metatada.
  Here's some simple code that shows my problem. What am I doing wrong,
  or not understanding about metadata?
 
  ;;;  src/ctest/funcs.clj 
  (ns ctest.funcs)
 
  (defn
   #^{:wadl {:url /f1 :method GET :doc The f1 function.}}
   f1 [] 42)
 
  (defn
   #^{:wadl {:url /f2 :method GET :doc The f2 function.}}
   f2 [] eleventy-seven)
 
  ;;;  src/ctest/core.clj 
  (ns ctest.core
   (:use ctest.funcs))
 
  (def wadl-meta (list (meta ctest.funcs/f1) (meta ctest.funcs/f2)))
 
  There is indeed a bug in how defn copy metadata from the var to the fn:
  user= (defn foo {:bar :baz} [] 42)
  #'user/foo
  user= (meta #'foo)
  {:ns #Namespace user, :name foo, :file NO_SOURCE_PATH, :line 221,
  :arglists ([]), :bar :baz}
  user= (meta foo)
  {:ns #Namespace user, :name foo}
  user= (defn foo {:lucy :ethel} [] 43)
  #'user/foo
  user= (meta #'foo)
  {:ns #Namespace user, :name foo, :file NO_SOURCE_PATH, :line 224,
  :arglists ([]), :lucy :ethel}
  user= (meta foo)
  {:ns #Namespace user, :name foo, :file NO_SOURCE_PATH, :line 221,
  :arglists ([]), :bar :baz}
 
  There you see that the fn got the previous metadata and not the current.
 I'm
  going to open a ticket.
 
  Christophe
 
  --
  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
  Note that posts from new members are moderated - please be patient with
 your
  first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en



 --
 Jim Menard, http://www.io.com/~jimm/ http://www.io.com/%7Ejimm/

 --
 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
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
Brussels, 23-25/6 http://conj-labs.eu/
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Newbie (with no Java experience) - how best to learn?

2010-05-28 Thread Alex Ott


Dave Pawson  at Fri, 28 May 2010 08:56:40 +0100 wrote:
 DP On 28 May 2010 08:30, Alex Ott alex...@gmail.com wrote:
  Re all
 
  Dave Pawson  at Thu, 27 May 2010 20:08:53 +0100 wrote:
   DP Is there a wiki where all these info sources could be collected please?
   DP Sounds really quite useful to the newbie.
 
  Just FYI - I have special page (http://alexott.net/en/clojure/video.html)
  with links to video lectures/screencasts about Clojure

 DP Thanks Alex.
 DP How to link to it from the clojure setup?

I don't know - we could ask Rich (or somebody else) to add link to this page

-- 
With best wishes, Alex Ott, MBA
http://alexott.blogspot.com/   http://alexott.net
http://alexott-ru.blogspot.com/

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Mersenne Twister

2010-05-28 Thread Lauri Pesonen
Hi Paul,

On 27 May 2010 23:24, Paul Moore p.f.mo...@gmail.com wrote:

 Can someone recommend a good Mersenne Twister implementation I could
 use? A web search finds a number of implementations in Java -
 presumably I can use these via Java interop - is that a sensible thing
 to do?

It is very sensible to use an existing java library in this case: i)
the code exitsts so you don't have to write it, ii) it will probably
have a reasonably nice interface to use from clojure, and iii) the
performance will most likely be better.

A quick Google found this page:
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/JAVA/java.html

If I'm not mistaken, these are the guys who wrote the original
Mersenne twister paper.

 I'm also looking to parallelise my simulation, so I'd want to have
 multiple threads all generating random numbers. I'm not an expert in
 this field, if I just naively generate random numbers in multiple
 threads is that OK, or could it compromise the randomness? If there is
 an issue, has anyone got a pointer to a thread-safe MT implementation
 that I could use?

First of all, the RNG will maintain internal state, so accessing it
from multiple thread willy-nilly will corrupt that state. It could be
that the implementation that you decide to go with will protect the
internal state with locks in which case you're ok. The other thing to
consider is speed: any kind of locking will slow down the RNG.

So if in your application it's ok to have one RNG instance per thread,
then you can avoid locking, and the speed penalty. On the other hand,
if you want all of the threads to use the same RNG instance for some
reason (e.g. deterministic behaviour) then you'll need to use a single
RNG instance that is shared across your threads. If you do need
deterministic behaviour it might be possible to seed all your RNG
instances the same and that way produce deterministic behaviour across
multiple RNG instances. I guess this depends on the MT implementation.
Also, I'm not sure if this is possible with MT or not.

 Paul.

-- 
  ! Lauri

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Elegant way of expressing this in Clojure?

2010-05-28 Thread Christophe Grand
On Thu, May 27, 2010 at 9:07 PM, CuppoJava patrickli_2...@hotmail.comwrote:

 The purpose is quite straightforward.
 I just have to call process() on every word in the w and d array.

 But I don't want to load docs if they have already been loaded.
 And I want to stop when it hits the first malformed document.


Reading this whole thread, I can't keep wondering how you build your d and w
arrays (are they the better data structure for the job) and what's the ratio
of words/doc.

Christophe

-- 
Brussels, 23-25/6 http://conj-labs.eu/
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Clojure script with shebangoid on windows

2010-05-28 Thread alux
Hello!

Short: It works, but is not perfect.

(this may need an windows expert to make it better)

After seeing a script for Scala using something shebang like for a
windows system:

scalascript.cmd
::#!
@echo off
call scala -savecompiled %0 %*
goto :eof
::!#
println(I didn't believe this.)

argv.toList foreach Console.println
end

I tried this for Clojure. It seems that the Scala people did some
special handling for this case, in order to let Scala ignore the lines
from ::# to ::#. For Clojure I had to do this somehow manually.

-clojurescript.cmd-

::#!
@echo off
REM (comment
call java -jar clojure.jar -e (ns script (:require [clojure.core]))
(do (def echo (ref nil)) (def off nil) (def goto nil) (def REM
nil) :starting) %0 %*
REM )
goto :eof
::!#

(println \nI still would like to make this easier.)

-end-

Output is:

D:\lang\clojuretestscript.cmd
:starting

I still would like to make this easier.

D:\lang\clojure


I actually dont completely understand whats happening. Any hints
appreciated.

Kind regards, alux

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


lein, slime, project management

2010-05-28 Thread Catonano
Hello people,

so, my questions are not about Clojure, they're about the tools of the
trade. I hope no one will be bothered. In my opinion the tools are a part of
this.

So, the swank-clojure-project is gonna be deprecated and I should settle on
slime-connect instead. Fine.

But being a beginner with both Emacs and Slime, I'd appreciate some insight
about what the usage patterns are supposed to be.

I mean, what is gonna happen when I ask slime to compile the contents of a
buffer ? Is it gonna produce a .class file ? Or a jar ? Where is it gonna
put it ?

Are the contents of the file gonna be available from that time on ? Or
should I add the thing to the dependencies ?

Right now, I connected to my lein based swank server, then I defined a small
hello world function in a file. From the SLIME menu I choose compile defun
and it doesn't complain about anything. I choose compile file and an error
pops up with a stacktrace (ugh) and the third line in the stacktrace says
something like

user$eval__1975.invoke(NO_SOURCE_FILE)

So, I wonder: what's going on ?

Thanks for ANY hint
Catonano

-- 
La difesa più sicura contro il male è l'estremo individualismo,
l'originalità di pensiero, la stravaganza, perfino, se volete,
l'eccentricità… Il male va matto per la solidarietà.

Less than one di Joseph Brodsky

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-28 Thread Matthew Elder
I will send patches!! get on github no.

;)

On 5/27/10, Luke VanderHart luke.vanderh...@gmail.com wrote:
 Thanks, Heinz... I may.

 Right now I'm still exploring what I want the API to be. I was hoping
 to achieve something a bit thicker that could insulate the user from
 Java classes completely. The user wouldn't even have to know Swing or
 handle JObjects or worry about the event thread... In other words, it
 wouldn't be a wrapper API for Swing, but a Clojure GUI api that,
 coincidentally, is /backed/ by Swing.

 This may be an unrealistic goal, but I've got pretty far down the path
 of designing it, though I definitely don't want to declare victory
 until I've figured out a strategy for covering every reasonably common
 use case.

 -Luke




 On May 27, 5:54 pm, Heinz N. Gies he...@licenser.net wrote:
 +1 For swing especially since I started this already. Look for clj-swing
 in github, since this seems quite a load of work I'd be glad for any help
 so :).

 Regards,
 Heinz
 On May 27, 2010, at 21:30 , Luc Préfontaine wrote:



  +1 for Swing.
  On Thu, 2010-05-27 at 11:59 -0700, Brian Schlining wrote:
  +1 Swing.
   +1 Swing.
+1 Swing.  There's a ton of documentation out there, and it got
some

 --
 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
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
Sent from my mobile device

Need somewhere to put your code? http://patch-tag.com
Want to build a webapp? http://happstack.com

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Datatype Usage Examples

2010-05-28 Thread SinDoc
L.S.,

I was wondering if someone could point me to recent usage examples of
deftype, defrecord, and reify. Reading [1] helped a lot but it wasn't
particularly easy to find it since it's not linked from the sidebar.

Specifically, what I'd like to know is:

 - How to define and access member data fields -also mutable in case
of deftype- to my ADTs.
 - Whether I can refer to type instances -an equivalent to the 'this'
keyword in Java.
 - How to define constructors.

Kind regards,
SinDoc

[1] http://clojure.org/datatypes

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Mersenne Twister

2010-05-28 Thread Artur Matos
Hi Paul,

I've used Sean Luke's implementation quite a few times before:

http://cs.gmu.edu/~sean/research/mersenne/MersenneTwister.java

It is pretty good, fast and battle tested (it is used extensively in
ECJ - an genetic algorithm and genetic programming java package,
another project of his).

Concerning generating random numbers in different threads, there is a
simple Mersenne Twister extension you can use to ensure that all
random generators are independent (or as independent as pseudorandom
generators can be). It is detailed in this paper here, by the author
of Mersenne Twister himself:

http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/DC/dgene.pdf

The only thing you will need is some sort of numerical unique ID for
each thread - it can be sequencial or even generated randomly using
Java UUIDs or the like.

Hope this helps,

Artur


On May 27, 11:24 pm, Paul Moore p.f.mo...@gmail.com wrote:
 I want to write a reasonably high-performance simulation program in
 Clojure. For the random numbers, I'd prefer to use Mersenne Twister
 (for a number of reasons - it's a well-known, good RNG, and it's
 commonly used in a number of other languages I use, so it's a good
 baseline for comparing implementations). The Java RNG, which Clojure
 uses, is not MT, but Knuth's linear congruential RNG.

 Can someone recommend a good Mersenne Twister implementation I could
 use? A web search finds a number of implementations in Java -
 presumably I can use these via Java interop - is that a sensible thing
 to do?

 I'm also looking to parallelise my simulation, so I'd want to have
 multiple threads all generating random numbers. I'm not an expert in
 this field, if I just naively generate random numbers in multiple
 threads is that OK, or could it compromise the randomness? If there is
 an issue, has anyone got a pointer to a thread-safe MT implementation
 that I could use?

 Thanks,
 Paul.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


57 varieties

2010-05-28 Thread Philip Hudson
I've been trying for the best part of a month to get SLIME/SWANK/ 
Clojure/clojure-mode working in emacs 23.2 on Mac OS X 10.5 without  
using ELPA, which unfortunately seems to break everything including  
itself in my setup.


Using Bill Clementson's checkout recommendations (see below) I've got  
to the point where I can type in the Clojure 1.2.0 *inferior-lisp*  
REPL buffer (with no prompt) and have the reader eval output appear in  
the SLIME REPL buffer, but SLIME seems to think I'm in some  
unspecified Common Lisp (the prompt is CL-USER ) and I can't enter  
anything in the SLIME REPL.


Here are the checkout URL recommendations I've gleaned:

Bill Clementson:
svn http://clojure.googlecode.com/svn/trunk/
git://github.com/jochu/clojure-mode.git
git://github.com/jochu/swank-clojure.git
svn http://clojure-contrib.googlecode.com/svn/trunk/
cvs common-lisp.net:/project/slime/cvsroot


# AEvar's version
git://github.com/richhickey/clojure.git
git://github.com/technomancy/clojure-mode.git
git://github.com/jochu/swank-clojure.git
git://github.com/richhickey/clojure-contrib.git
git://github.com/technomancy/slime.git


# Brent Millare's version
git://github.com/richhickey/clojure.git
git://github.com/jochu/clojure-mode.git
git://github.com/technomancy/swank-clojure.git
git://github.com/richhickey/clojure-contrib.git
git://github.com/technomancy/leiningen.git


# http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html:
git://github.com/jochu/clojure-mode.git
git://github.com/jochu/swank-clojure.git
git://git.boinkor.net/slime.git

I very much hope that you all can give me firm and final yes or no  
verdicts on each of these lines.


--
Phil Hudson  PGP/GnuPG ID: 0x887DCA63

--
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: M-X slime

2010-05-28 Thread Oleg
Hello!

Thank you. It was just not fully downloaded clojure 1.2
I've asked lein to update all deps again and now it works.

On 28 май, 04:10, Joost jo...@zeekat.nl wrote:
 On May 27, 8:24 pm, Oleg oleg.richa...@gmail.com wrote:

  Hello Guys!

  Yes, i know that i can run lein swank in my project directory and
  then use M-X + slime-connect in emacs. But all the time with clojure
  1.1.0 i used this procedure: M-X cd to project directory and them just
  M-X slime (classpath is set relative to current emacs dir, so it finds
  swank-clojure.jar in lib directory). I feel myself very comfortable
  with that sequence and don't want to change it. Can somebody help me
  to make my M-X + slime works again, because i don't want to have
  additional step with lein swank in console.

 As far as I know, as long as you've got some command that starts a
 REPL and has the swank code in its path, you can use it as swank-
 clojure-binary.

 I did a blog post about that some months 
 ago:http://joost.zeekat.nl/2009/12/03/choosing-your-clojure-startup-scrip...

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Mersenne Twister

2010-05-28 Thread dmathei
Hello Paul,

The following thread [1] mentions the MT by Sean Luke [2].
If you compile/jar the source and put it into your classpath (e.g. /
lib)  you should be able to use it directly
from your clojure project as shown in the thread. (Rich's answer)
There is a synch'ed version and a fast one ... I'm no expert on this
neither, but using multiple
single-threaded twisters with different seeds should leave your
randomness uncompromised I think.

Cheers,
-David

[1] 
http://groups.google.com/group/clojure/browse_thread/thread/776943086de213f9/c39d198158994860
[2] http://www.cs.gmu.edu/~sean/research/


-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure Master on android

2010-05-28 Thread MHOOO


On May 28, 9:26 am, Remco van 't Veer rwvtv...@gmail.com wrote:

 Try giving the dx command a bit more memory by adding something like:

   -Jmx1024m

 before --dex.

Unfortunately that didn't work quite so well. The java process ended
up using 1.4GB ram without terminating (waited approximately 10
minutes before I killed it).
I am using:
---
tho...@lisper:/$ java -version
java version 1.6.0_18
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

tho...@lisper:/$ uname -a
Linux lisper 2.6.32-22-generic #33-Ubuntu SMP Wed Apr 28 13:28:05 UTC
2010 x86_64 GNU/Linux

tho...@lisper:/$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION=Ubuntu 10.04 LTS
--
The script I am using (hello-dalvik.sh):
--
#!/bin/sh

export ANDROID_DIR=/home/thomas/sources/android-sdk-linux_86
export CLOJURE_JAR=/home/thomas/sources/clojure/clojure.jar

set -e
rm -rf hello-dalvik; mkdir hello-dalvik; cd hello-dalvik

echo '(ns HelloDalvik (:gen-class)) (defn -main [] (println (str
hello dalvik from clojure  (clojure-version'  HelloDalvik.clj
java -classpath $CLOJURE_JAR:. -Dclojure.compile.path=.
clojure.lang.Compile HelloDalvik

$ANDROID_DIR/platforms/android-8/tools/dx -Jmx1024m --dex --
output=classes.dex HelloDalvik*.class $CLOJURE_JAR
$ANDROID_DIR/platforms/android-8/tools/aapt add HelloDalvik.jar
classes.dex
jar uf HelloDalvik.jar -C ../src/clj clojure/version.properties
$ANDROID_DIR/tools/adb push HelloDalvik.jar /sdcard/

echo dalvikvm -classpath /sdcard/HelloDalvik.jar HelloDalvik \; exit |
$ANDROID_DIR/tools/adb shell
-
Anything wrong with my configuration?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-28 Thread Matthew Elder
Yes but not too much yak shaving, it is important to run with the
simplest thing that will work first.


On 5/27/10, Jason Smith ja...@lilypepper.com wrote:
 Why not design it so that it can be backed by Swing or SWT or HTML
 (perhaps with some AJAX) or whatever?  It seems kind of silly to do an
 abstraction on a single backend, don't you think?

 On May 27, 4:37 pm, Luke VanderHart luke.vanderh...@gmail.com wrote:
 Thanks, Heinz... I may.

 Right now I'm still exploring what I want the API to be. I was hoping
 to achieve something a bit thicker that could insulate the user from
 Java classes completely. The user wouldn't even have to know Swing or
 handle JObjects or worry about the event thread... In other words, it
 wouldn't be a wrapper API for Swing, but a Clojure GUI api that,
 coincidentally, is /backed/ by Swing.

 This may be an unrealistic goal, but I've got pretty far down the path
 of designing it, though I definitely don't want to declare victory
 until I've figured out a strategy for covering every reasonably common
 use case.

 -Luke

 On May 27, 5:54 pm, Heinz N. Gies he...@licenser.net wrote:



  +1 For swing especially since I started this already. Look for clj-swing
  in github, since this seems quite a load of work I'd be glad for any
  help so :).

  Regards,
  Heinz
  On May 27, 2010, at 21:30 , Luc Préfontaine wrote:

   +1 for Swing.
   On Thu, 2010-05-27 at 11:59 -0700, Brian Schlining wrote:
   +1 Swing.
+1 Swing.
 +1 Swing.  There's a ton of documentation out there, and it got
 some

 --
 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
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
Sent from my mobile device

Need somewhere to put your code? http://patch-tag.com
Want to build a webapp? http://happstack.com

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Elegant way to replace a few words in string

2010-05-28 Thread Oleg
Hello Guys!

I have a string for example Foo12 Bar130 Qoo20 and map like this
{Foo XF Bar XB Qoo XQ}.
I want get: XF12 XB130 XQ20

I want to replace words in string based on map association. What is
the elegant way to do it? Sure, i can use loop and recur
to make string enter the next replacement, but is there another way to
do it better?

Cheers, Oleg

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure Master on android

2010-05-28 Thread Remco van 't Veer
Hmm, I have a 32 bit setup to that's probably the issue:

  java version 1.6.0_18
  OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
  OpenJDK Server VM (build 14.0-b16, mixed mode)

Don't have a clue how to fix this.


On 2010/05/28 11:06, MHOOO wrote:

 On May 28, 9:26 am, Remco van 't Veer rwvtv...@gmail.com wrote:

 Try giving the dx command a bit more memory by adding something like:

   -Jmx1024m

 before --dex.

 Unfortunately that didn't work quite so well. The java process ended
 up using 1.4GB ram without terminating (waited approximately 10
 minutes before I killed it).
 I am using:
 ---
 tho...@lisper:/$ java -version
 java version 1.6.0_18
 OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
 OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

 tho...@lisper:/$ uname -a
 Linux lisper 2.6.32-22-generic #33-Ubuntu SMP Wed Apr 28 13:28:05 UTC
 2010 x86_64 GNU/Linux

 tho...@lisper:/$ cat /etc/*-release
 DISTRIB_ID=Ubuntu
 DISTRIB_RELEASE=10.04
 DISTRIB_CODENAME=lucid
 DISTRIB_DESCRIPTION=Ubuntu 10.04 LTS
 --
 The script I am using (hello-dalvik.sh):
 --
 #!/bin/sh

 export ANDROID_DIR=/home/thomas/sources/android-sdk-linux_86
 export CLOJURE_JAR=/home/thomas/sources/clojure/clojure.jar

 set -e
 rm -rf hello-dalvik; mkdir hello-dalvik; cd hello-dalvik

 echo '(ns HelloDalvik (:gen-class)) (defn -main [] (println (str
 hello dalvik from clojure  (clojure-version'  HelloDalvik.clj
 java -classpath $CLOJURE_JAR:. -Dclojure.compile.path=.
 clojure.lang.Compile HelloDalvik

 $ANDROID_DIR/platforms/android-8/tools/dx -Jmx1024m --dex --
 output=classes.dex HelloDalvik*.class $CLOJURE_JAR
 $ANDROID_DIR/platforms/android-8/tools/aapt add HelloDalvik.jar
 classes.dex
 jar uf HelloDalvik.jar -C ../src/clj clojure/version.properties
 $ANDROID_DIR/tools/adb push HelloDalvik.jar /sdcard/

 echo dalvikvm -classpath /sdcard/HelloDalvik.jar HelloDalvik \; exit |
 $ANDROID_DIR/tools/adb shell
 -
 Anything wrong with my configuration?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Elegant way to replace a few words in string

2010-05-28 Thread Laurent PETIT
(reduce
  (fn [#^String s [#^CharSequence what #^CharSequence with]]
(.replace s what with))
  Foo12 Bar130 Qoo20
  {Foo XF Bar XB Qoo XQ})

2010/5/28 Oleg oleg.richa...@gmail.com

 Hello Guys!

 I have a string for example Foo12 Bar130 Qoo20 and map like this
 {Foo XF Bar XB Qoo XQ}.
 I want get: XF12 XB130 XQ20

 I want to replace words in string based on map association. What is
 the elegant way to do it? Sure, i can use loop and recur
 to make string enter the next replacement, but is there another way to
 do it better?

 Cheers, Oleg

 --
 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
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Elegant way of expressing this in Clojure?

2010-05-28 Thread CuppoJava
d,w are arrays that are passed to me by a machine learning algorithm
so it's not something that I have control over. There are roughly 100
words per doc.

Thanks for everyone's help. I wonder if directly mutable primitives is
something that is hard to put into Clojure? Or something that's
explicitly avoided because it distracts from the FP paradigm. The lack
of them is making this code somewhat awkward to write.
  -Patrick

On May 28, 4:44 am, Christophe Grand christo...@cgrand.net wrote:
 On Thu, May 27, 2010 at 9:07 PM, CuppoJava patrickli_2...@hotmail.comwrote:

  The purpose is quite straightforward.
  I just have to call process() on every word in the w and d array.

  But I don't want to load docs if they have already been loaded.
  And I want to stop when it hits the first malformed document.

 Reading this whole thread, I can't keep wondering how you build your d and w
 arrays (are they the better data structure for the job) and what's the ratio
 of words/doc.

 Christophe

 --
 Brussels, 23-25/6http://conj-labs.eu/
 Professional:http://cgrand.net/(fr)
 On Clojure:http://clj-me.cgrand.net/(en)

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: 57 varieties

2010-05-28 Thread Ramakrishnan Muthukrishnan
On Fri, May 28, 2010 at 4:09 PM, Philip Hudson phil.hud...@iname.com wrote:
 I've been trying for the best part of a month to get
 SLIME/SWANK/Clojure/clojure-mode working in emacs 23.2 on Mac OS X 10.5
 without using ELPA, which unfortunately seems to break everything including

Here are my instructions for a completely manual setup which works
very well for me, I keep syncing with technomancy's branch:

 http://github.com/vu3rdd/swank-clojure/raw/master/config.txt
 http://github.com/vu3rdd/swank-clojure

-- 
  Ramakrishnan

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Elegant way of expressing this in Clojure?

2010-05-28 Thread Meikel Brandmeyer
Hi,

On May 28, 3:09 pm, CuppoJava patrickli_2...@hotmail.com wrote:

 Thanks for everyone's help. I wonder if directly mutable primitives is
 something that is hard to put into Clojure? Or something that's
 explicitly avoided because it distracts from the FP paradigm. The lack
 of them is making this code somewhat awkward to write.

Wasn't deftype providing mutable primitive fields if necessary?

Sincerely
Meikel

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Newbie question about vector performance

2010-05-28 Thread Rubén Béjar

Hi all,

I am new to the list and to Clojure. I have been working in
implementing some 2D cellular automata (CA) just to have a project
to teach Clojure to myself. After some work I have something that
works, but it is pretty slow. The function that takes a CA
of 500x500 cells (integers) and returns an updated (*) copy
takes 4 s. (using Clojure vectors), while doing more or less 
the same in Java (using arrays and primitive types) takes more or

less 16 *ms.*. I expected some difference, but not that big. Before
trying to use Java arrays and primitive types
in Clojure, I would like to know how my Clojure approach can
be improved  (I am willing to sacrifice some performance to keep
it more Clojure, but not that much).

As I do not want to post a bunch of horrible code full of comments
and not properly indented, I have extracted what i hope are the
main pieces, written some comments and posted it here:
http://snipt.org/Okpk

Pasting that code in a new file in Eclipse (I am using
counterclockwise) and running it in the REPL prints this:

Clojure 1.1.0-alpha-SNAPSHOT
Elapsed time: 4355.363706 msecs
Elapsed time: 4416.98562 msecs
1:1 user= #Namespace cellular-automata-basic
1:2 cellular-automata-basic=

I would thank a lot any hint, suggestion, comment, or
whatever... :-)

Best regards,

   Rubén

(*) The update consists on adding the values of the 8 neighbours
of every cell and changing it if that sum is between two fixed
numbers.

--
Rubén BÉJAR HERNÁNDEZ

Dpto. de Informática e Ingeniería de Sistemas - Universidad de Zaragoza
(Computing and Systems Engineering Department - Universidad de Zaragoza)
c/ María de Luna 1, 50018 Zaragoza, Spain

Tel: (+34) 976 76 2332 (Fax: 1914)  
e-mail: rbe...@unizar.es


Grupo IA3 (IA3 Laboratory) - http://iaaa.cps.unizar.es



--
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-28 Thread Sean Devlin
For those of you complaining about the Swing LAF, learn to use the
UIManager class :)

(defn set-laf!
  [laf-name]
  (javax.swing.UIManager/setLookAndFeel laf-name))

On May 27, 7:51 pm, Armando Blancas armando_blan...@yahoo.com wrote:
  Remember, the actual API won't matter - that will be completely
  abstracted away. So try to focus on the framework's look and feel.
  Thanks!
  -Luke

 SWT, because of the native look and feel. I really don't like the
 looks of Swing. As a user of some Swing app, I don't find solace from
 thinking how convenient it was for the programmers to deliver that
 thing to me. As a developer, dealing with the packaging/deployment
 just comes with the job and the results, I think, are well worth the
 effort.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Elegant way of expressing this in Clojure?

2010-05-28 Thread Christophe Grand
On Fri, May 28, 2010 at 3:09 PM, CuppoJava patrickli_2...@hotmail.comwrote:

 d,w are arrays that are passed to me by a machine learning algorithm
 so it's not something that I have control over. There are roughly 100
 words per doc.


ok


 Thanks for everyone's help. I wonder if directly mutable primitives is
 something that is hard to put into Clojure? Or something that's
 explicitly avoided because it distracts from the FP paradigm. The lack
 of them is making this code somewhat awkward to write.


In this case there is no need for mutable primitives.
You can try a direct translation of your java code:

(let [n (alength w)]
  (loop [doc (int -1) i (int 0)]
(when ( i n)
  (let [new-doc (aget d i)
(when-not (= doc new-doc)
  (load doc))
(when-not (malformed doc)
  (process new-doc (aget w i))
  (recur new-doc (inc i)))

You can tweeak it here and there (== and unchecked-inc for example) and
don't forget to typehint d and w if Clojure doesn't infer their type.

Christophe

-- 
Brussels, 23-25/6 http://conj-labs.eu/
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-28 Thread mmwaikar
I work on .Net, so my observation could be totally wrong, but I think
JavaFx could be an option to consider (specially because of its JSON
kind of syntax).
I am working on a WPF project currently, and although WPF is big and
complex, the kind of UIs one can build with it is amazing, and JavaFx
looked similar to me in intent and purpose.

So I am really surprised why no one mentioned JavaFx. Is it because
it's new?

On May 27, 11:18 am, Luke VanderHart luke.vanderh...@gmail.com
wrote:
 My side project is a fairly complex GUI application written in
 Clojure. Recently, I've become irritated with using Java interop for
 everything. It's not that Clojure doesn't have nice java interop - it
 does. It's just that when interacting with a GUI framework, which is a
 large part of my app, I have to be back in mutable object-oriented
 land, worrying about class hierarchies, mutable state, locks, etc.
 Yucky.

 So, with a perhaps dangerous lack of sanity and without any guarantee
 of success, I've decided to try my hand at writing an idiomatic
 Clojure GUI library. If I have success (which I doubt) I will of
 course make it available as open source.

 I intend for it to be mostly declarative, with a nice DSL for defining
 GUI elements. Each component will also implement map, and use one of
 Clojure's reference types as an interface for inspecting / updating
 its state. I may also implement some aspects of Functional Reactive
 Programming wherever it's convenient to do so.

 What you all must help me decide is what GUI framework to use as the
 underpinnings of it. It's genuinely hard to decide. I have at least
 some experience with all of them, so I have no strong preference, but
 I'd like to get your input. I did consider trying to make it abstract
 enough that you could plug in *any* of them under the hood, but
 there's enough differences between the frameworks that that would get
 very ugly very fast.

 Possibilities are:

 AWT
 Pros: native widgets, bundled with Java, low-level
 Cons: few widgets, considered somewhat obselete

 Swing
 Pros: bundled with Java, good widget selection
 Cons: non-native widgets

 SWT
 Pros: native widgets, widely used
 Cons: requires platform-specific libs

 QT Jambi
 Pros: native widgets, huge widget selection, highly-regarded framework
 Cons: requires platform-specific libs, writing custom widgets is
 hairy, momentum and support seem to be lagging since Nokia dropped
 official support.

 Remember, the actual API won't matter - that will be completely
 abstracted away. So try to focus on the framework's look and feel.
 Also let me know if I've missed any of the framework's key
 characteristics.

 Thanks!

 -Luke

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Datatype Usage Examples

2010-05-28 Thread Meikel Brandmeyer
Hi,

On May 28, 9:52 am, SinDoc s...@khakbaz.com wrote:

 I was wondering if someone could point me to recent usage examples of
 deftype, defrecord, and reify. Reading [1] helped a lot but it wasn't
 particularly easy to find it since it's not linked from the sidebar.

 Specifically, what I'd like to know is:

  - How to define and access member data fields -also mutable in case
 of deftype- to my ADTs.
  - Whether I can refer to type instances -an equivalent to the 'this'
 keyword in Java.
  - How to define constructors.

The modified memoize sparked some examples for this:
http://kotka.de/blog/2010/03/memoize_done_right.html#protocols

Sincerely
Meikel

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-28 Thread Martin DeMello
On Fri, May 28, 2010 at 7:29 PM, mmwaikar mmwai...@gmail.com wrote:
 QT Jambi
 Pros: native widgets, huge widget selection, highly-regarded framework
 Cons: requires platform-specific libs, writing custom widgets is
 hairy, momentum and support seem to be lagging since Nokia dropped
 official support.

I would love to see an idiomatic clojure QtJambi wrapper that solves
the writing custom widgets is hairy problem.

martin

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-28 Thread Luke VanderHart
My understanding may be wrong, but I think JavaFX is intended more as
a competitor to Flash or Silverlight than a GUI toolkit. It'd probably
be great for a Clojure games framework, or for simple graphical
drawing and such, but I'm not sure it's appropriate for a complex,
high performance GUI. In fact, according to the Wiki page, if you want
to use desktop style widgets, you actually end up embedding Swing
components *within* JavaFX anyway.

On May 28, 9:59 am, mmwaikar mmwai...@gmail.com wrote:
 I work on .Net, so my observation could be totally wrong, but I think
 JavaFx could be an option to consider (specially because of its JSON
 kind of syntax).
 I am working on a WPF project currently, and although WPF is big and
 complex, the kind of UIs one can build with it is amazing, and JavaFx
 looked similar to me in intent and purpose.

 So I am really surprised why no one mentioned JavaFx. Is it because
 it's new?

 On May 27, 11:18 am, Luke VanderHart luke.vanderh...@gmail.com
 wrote:

  My side project is a fairly complex GUI application written in
  Clojure. Recently, I've become irritated with using Java interop for
  everything. It's not that Clojure doesn't have nice java interop - it
  does. It's just that when interacting with a GUI framework, which is a
  large part of my app, I have to be back in mutable object-oriented
  land, worrying about class hierarchies, mutable state, locks, etc.
  Yucky.

  So, with a perhaps dangerous lack of sanity and without any guarantee
  of success, I've decided to try my hand at writing an idiomatic
  Clojure GUI library. If I have success (which I doubt) I will of
  course make it available as open source.

  I intend for it to be mostly declarative, with a nice DSL for defining
  GUI elements. Each component will also implement map, and use one of
  Clojure's reference types as an interface for inspecting / updating
  its state. I may also implement some aspects of Functional Reactive
  Programming wherever it's convenient to do so.

  What you all must help me decide is what GUI framework to use as the
  underpinnings of it. It's genuinely hard to decide. I have at least
  some experience with all of them, so I have no strong preference, but
  I'd like to get your input. I did consider trying to make it abstract
  enough that you could plug in *any* of them under the hood, but
  there's enough differences between the frameworks that that would get
  very ugly very fast.

  Possibilities are:

  AWT
  Pros: native widgets, bundled with Java, low-level
  Cons: few widgets, considered somewhat obselete

  Swing
  Pros: bundled with Java, good widget selection
  Cons: non-native widgets

  SWT
  Pros: native widgets, widely used
  Cons: requires platform-specific libs

  QT Jambi
  Pros: native widgets, huge widget selection, highly-regarded framework
  Cons: requires platform-specific libs, writing custom widgets is
  hairy, momentum and support seem to be lagging since Nokia dropped
  official support.

  Remember, the actual API won't matter - that will be completely
  abstracted away. So try to focus on the framework's look and feel.
  Also let me know if I've missed any of the framework's key
  characteristics.

  Thanks!

  -Luke

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-28 Thread Luke VanderHart
 I would love to see an idiomatic clojure QtJambi wrapper that solves
 the writing custom widgets is hairy problem.

I think QT Jambi's basic architecture precludes this. Jambi is
basically a bunch of JNI calls to a backend C++ QT app. As soon as you
start delving into Jambi's internals, you end up in C++ land.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Android 'dex' stage takes a very long time with Clojure

2010-05-28 Thread Matt Clark
I'm new to Android, but I've been wanting to give it a try for a while
so I thought I'd try using Clojure's master branch.  It all seems to
be working fairly well except the dex stage of installation takes
around 2 minutes for a simple Hello World app.  How do others get
around this lag?

I'm pretty sure it's caused by the large clojure.core namespace, as
I've already taken everything else that I can out of the clojure jar
file.  I'm just not sure if there's anything else I can do.  I am
using emacs and android-mode, if that is of any help.  I've also tried
giving it more memory as suggested here: 
http://groups.google.com/group/clojure/msg/c38e015582cf7623

Thanks a lot

Matt

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-28 Thread laseray
+1 Swing

If I had my druthers I would go with QtJambi, but since Nokia dropped
development for that it has not been able to keep pace with Qt. So
that would be immediately out of sync. Plus the need for platform
native compiled code is a minus. Fine for the main three (Linux, Mac,
Windows) with precompiled libs, but separate compile for anything else
equals ongoing maintenance effort. This defeats the point of having a
cross-platform language. Java and Clojure will work (.e.g, on FreeBSD,
OpenSolaris, AIX), but the GUI won't unless you make extra C/C++
coding effort?

SWT is a minus due to native code needs, too much XML configuration,
and the fact that it does not look nearly as good as some people think
when used cross-platform. Looks fine on Windows, the Mac side is
getting better now that they are starting to use Cocoa underneath,
Linux side is questionable with varying appearance across different
window managers. Other OS? This is the same as for QtJambi, extra C/C+
+ coding effort needed to be really cross-platform.

No reason to go with AWT exclusively. A lot of Swing wraps parts of or
needs AWT anyway. You can't really get away from it and will be
cutting off a limb, so to speak, if you go with it rather than Swing
first.

A lot of the misgivings about Swing look and feel across platform
boils down to bad GUI development efforts. I have seen this many
times. Many developers just do not understand the specific interface
needs across different platforms and just leave parameters at the
default settings, which only by luck will be near optimal. I have
developed a number of Swing applications that look pretty close to
native (at least on Linux, Mac, Windows, Solaris) so I can say that it
takes some attention to platform specific details to make this happen
(and access to multiple OS).  That is what it takes to develop a
serious professional cross-platform desktop application, no way around
it (you would even have to do this if going with QtJambi or SWT).

Overall, I would go with Swing. The main reason is that it will
already be cross-platform on any Java compliant OS that can run
Clojure. I think that is the most important thing if you want a GUI to
go along with the language. Nothing additional is needed to complicate
matters, besides the GUI layer/framework on top of Clojure.

Nonetheless, the best idea would be to ensure you have enough
abstraction in your implementation so that other GUI toolkits could be
almost dropped in place later on. That is, it should not close out
other toolkits, but going with what will work now or sooner than later
is better. Going with Swing is a way to get something out soon without
having to spend additional effort worrying about C/C++ libraries,
packaging and so on. Get something to work, then the additional
toolkits can come.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-28 Thread Mikhail Kryshen
I vote for Swing.

Swing components conform to JavaBeans specification, so a generic
Clojure library to construct and manipulate JavaBeans would make
a large part of the GUI framework.

On 27 май, 19:18, Luke VanderHart luke.vanderh...@gmail.com wrote:
 My side project is a fairly complex GUI application written in
 Clojure. Recently, I've become irritated with using Java interop for
 everything. It's not that Clojure doesn't have nice java interop - it
 does. It's just that when interacting with a GUI framework, which is a
 large part of my app, I have to be back in mutable object-oriented
 land, worrying about class hierarchies, mutable state, locks, etc.
 Yucky.

 So, with a perhaps dangerous lack of sanity and without any guarantee
 of success, I've decided to try my hand at writing an idiomatic
 Clojure GUI library. If I have success (which I doubt) I will of
 course make it available as open source.

 I intend for it to be mostly declarative, with a nice DSL for defining
 GUI elements. Each component will also implement map, and use one of
 Clojure's reference types as an interface for inspecting / updating
 its state. I may also implement some aspects of Functional Reactive
 Programming wherever it's convenient to do so.

 What you all must help me decide is what GUI framework to use as the
 underpinnings of it. It's genuinely hard to decide. I have at least
 some experience with all of them, so I have no strong preference, but
 I'd like to get your input. I did consider trying to make it abstract
 enough that you could plug in *any* of them under the hood, but
 there's enough differences between the frameworks that that would get
 very ugly very fast.

 Possibilities are:

 AWT
 Pros: native widgets, bundled with Java, low-level
 Cons: few widgets, considered somewhat obselete

 Swing
 Pros: bundled with Java, good widget selection
 Cons: non-native widgets

 SWT
 Pros: native widgets, widely used
 Cons: requires platform-specific libs

 QT Jambi
 Pros: native widgets, huge widget selection, highly-regarded framework
 Cons: requires platform-specific libs, writing custom widgets is
 hairy, momentum and support seem to be lagging since Nokia dropped
 official support.

 Remember, the actual API won't matter - that will be completely
 abstracted away. So try to focus on the framework's look and feel.
 Also let me know if I've missed any of the framework's key
 characteristics.

 Thanks!

 -Luke

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure script with shebangoid on windows

2010-05-28 Thread Paul Moore
On 28 May 2010 09:48, alux alu...@googlemail.com wrote:
 Hello!

 Short: It works, but is not perfect.

 (this may need an windows expert to make it better)

Try this:

--- myscript.bat ---
:x (comment
@echo off
java -cp clojure.jar clojure.main %~f0 %*
goto eof
)

(println Hi! *command-line-args*)

--

The way it works:

The line starting with :x is treated as a label by cmd.exe (and so, in
effect, ignored). In Clojure, it's treated as a keyword :x followed by
the start of a multiline comment - (comment

So everything down to the closing ) is ignored by clojure, but
executed by cmd.exe

The next bits:
@echo off - suppress cmd.exe's annoying habit of displaying everything
java... Run the clojure script. %~f0 is the script name - I quote it
in case it has spaces, and %* is the rest of the command line.
Then, goto eof terminates the batch file (goto end of file), ignoring
the rest of the file, which can therefore be arbitrary clojure.

Paul.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Lazy map implementation

2010-05-28 Thread Robert Luo
I need a lazy map in my compojure based application to inject data
into handlers. I searched the web for an implementation, I got one
from Meikel which was written in 2008. Is there any recommendation?

Thanks.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Datatype Usage Examples

2010-05-28 Thread Krukow


On May 28, 9:52 am, SinDoc s...@khakbaz.com wrote:
 L.S.,

 I was wondering if someone could point me to recent usage examples of
 deftype, defrecord, and reify. Reading [1] helped a lot but it wasn't
 particularly easy to find it since it's not linked from the sidebar.

I've used protocols and defrecords to implement Michael Nygaard's
Circuit-breaker pattern.

The circuit breaker is basically a state-machine, with transitions
that occur on various events.

To me, it was very natural to model the transition functions as a
protocol

(defprotocol CircuitBreakerTransitions
  Transition functions for circuit-breaker states
  (proceed [s] true if breaker should proceed with call in this
state)
  (on-success [s] transition from s to this state after a successful
call)
  (on-error [s] transition from s to this state after an unsuccessful
call)
  (on-before-call [s] transition from s to this state before a
call))

The states are then datatypes (records in this case) that are extended
to reach this protocol, e.g.,

(defrecord ClosedState [#^TransitionPolicy policy #^int fail-count])
...
(extend ClosedState CircuitBreakerTransitions ...)

Blog: http://blog.higher-order.net/2010/05/05/circuitbreaker-clojure-1-2/

Code: http://github.com/krukow/clojure-circuit-breaker

 Specifically, what I'd like to know is:

  - How to define and access member data fields -also mutable in case
 of deftype- to my ADTs.

The example is there for immutable fields. Why do you need mutability?

  - Whether I can refer to type instances -an equivalent to the 'this'
 keyword in Java.

The first argument to a protocol function corresponds to the this
keyword in Java, e.g.,

(extend ClosedState CircuitBreakerTransitions
  ...
 :on-success
   (fn [{f :fail-count p :policy, :as s}] ;; note we can destructure
the 'this' argument (s)
 (if (zero? f) s (ClosedState. p 0)))
...)

  - How to define constructors.

A single constructor is automatically defined for you. In my case with
two params:

(ClosedState. policy fail-count)

If you need more flexibility, I believe you need gen-class, but I am
unsure.


 Kind regards,
 SinDoc

 [1]http://clojure.org/datatypes

Hope that helps. Kind Regards,
- Karl

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Lazy map implementation

2010-05-28 Thread Sean Devlin
Can memoize do the job for you?

On May 28, 10:39 am, Robert Luo robort...@gmail.com wrote:
 I need a lazy map in my compojure based application to inject data
 into handlers. I searched the web for an implementation, I got one
 from Meikel which was written in 2008. Is there any recommendation?

 Thanks.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure script with shebangoid on windows

2010-05-28 Thread alux
Hello Paul,

thats much better, many thanks!

Regards, alux

On 28 Mai, 16:09, Paul Moore p.f.mo...@gmail.com wrote:
 On 28 May 2010 09:48, alux alu...@googlemail.com wrote:

  Hello!

  Short: It works, but is not perfect.

  (this may need an windows expert to make it better)

 Try this:

 --- myscript.bat ---
 :x (comment
 @echo off
 java -cp clojure.jar clojure.main %~f0 %*
 goto eof
 )

 (println Hi! *command-line-args*)

 --

 The way it works:

 The line starting with :x is treated as a label by cmd.exe (and so, in
 effect, ignored). In Clojure, it's treated as a keyword :x followed by
 the start of a multiline comment - (comment

 So everything down to the closing ) is ignored by clojure, but
 executed by cmd.exe

 The next bits:
 @echo off - suppress cmd.exe's annoying habit of displaying everything
 java... Run the clojure script. %~f0 is the script name - I quote it
 in case it has spaces, and %* is the rest of the command line.
 Then, goto eof terminates the batch file (goto end of file), ignoring
 the rest of the file, which can therefore be arbitrary clojure.

 Paul.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: lein, slime, project management

2010-05-28 Thread Catonano
I reply to myself.

The answer is here: http://clojure.org/compilation

http://clojure.org/compilationSorry

2010/5/28 Catonano caton...@gmail.com

 Hello people,

 so, my questions are not about Clojure, they're about the tools of the
 trade. I hope no one will be bothered. In my opinion the tools are a part of
 this.

 So, the swank-clojure-project is gonna be deprecated and I should settle on
 slime-connect instead. Fine.

 But being a beginner with both Emacs and Slime, I'd appreciate some insight
 about what the usage patterns are supposed to be.

 I mean, what is gonna happen when I ask slime to compile the contents of a
 buffer ? Is it gonna produce a .class file ? Or a jar ? Where is it gonna
 put it ?

 Are the contents of the file gonna be available from that time on ? Or
 should I add the thing to the dependencies ?

 Right now, I connected to my lein based swank server, then I defined a
 small hello world function in a file. From the SLIME menu I choose compile
 defun and it doesn't complain about anything. I choose compile file and an
 error pops up with a stacktrace (ugh) and the third line in the stacktrace
 says something like

 user$eval__1975.invoke(NO_SOURCE_FILE)

 So, I wonder: what's going on ?

 Thanks for ANY hint
 Catonano

 --
 La difesa più sicura contro il male è l'estremo individualismo,
 l'originalità di pensiero, la stravaganza, perfino, se volete,
 l'eccentricità… Il male va matto per la solidarietà.

 Less than one di Joseph Brodsky




-- 
La difesa più sicura contro il male è l'estremo individualismo,
l'originalità di pensiero, la stravaganza, perfino, se volete,
l'eccentricità… Il male va matto per la solidarietà.

Less than one di Joseph Brodsky

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Elegant way to replace a few words in string

2010-05-28 Thread John Cromartie
I feel like the type hints should be left out until you really need
them, since they kind of clobber the routine's readability.

-John

On May 28, 9:07 am, Laurent PETIT laurent.pe...@gmail.com wrote:
 (reduce
   (fn [#^String s [#^CharSequence what #^CharSequence with]]
     (.replace s what with))
   Foo12 Bar130 Qoo20
   {Foo XF Bar XB Qoo XQ})

 2010/5/28 Oleg oleg.richa...@gmail.com



  Hello Guys!

  I have a string for example Foo12 Bar130 Qoo20 and map like this
  {Foo XF Bar XB Qoo XQ}.
  I want get: XF12 XB130 XQ20

  I want to replace words in string based on map association. What is
  the elegant way to do it? Sure, i can use loop and recur
  to make string enter the next replacement, but is there another way to
  do it better?

  Cheers, Oleg

  --
  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
  Note that posts from new members are moderated - please be patient with
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com 
  
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Newbie question about vector performance

2010-05-28 Thread Rubén Béjar




Hi again,

I have tried a few more things:

I have done the same in Java but using an array 
of Integers, instead of an array of ints. It just takes 
78 ms. (more than 16, still far less than 4 secs).

I have also tried with an update function which just returns a 
fixed 1. It still takes some 400 ms. to update de
data vector of the CA. This is similar to the time 
it is giving me to create a vector of 1's with this function:
(time (vec (repeat 25 1))).

I was not expecting Clojure vectors so much slower than
Java arrays. Is that comparison so "unfair"? Next thing
I am trying is using Java Vectors in my Java 
implementation...

 Rubn

Rubn Bjar escribi:
Hi all,
  
  
I am new to the list and to Clojure. I have been working in
  
implementing some 2D cellular automata (CA) just to have a project
  
to teach Clojure to myself. After some work I have something that
  
works, but it is pretty slow. The function that takes a CA
  
of 500x500 cells (integers) and returns an updated (*) copy
  
takes 4 s. (using Clojure vectors), while doing more or less the same
in Java (using arrays and primitive types) takes more or
  
less 16 *ms.*. I expected some difference, but not that big. Before
  
trying to use Java arrays and primitive types
  
in Clojure, I would like to know how my Clojure approach can
  
be improved (I am willing to sacrifice some performance to keep
  
it "more Clojure", but not that much).
  
  
As I do not want to post a bunch of horrible code full of comments
  
and not properly indented, I have extracted what i hope are the
  
main pieces, written some comments and posted it here:
  
http://snipt.org/Okpk
  
  
Pasting that code in a new file in Eclipse (I am using
  
counterclockwise) and running it in the REPL prints this:
  
  
Clojure 1.1.0-alpha-SNAPSHOT
  
"Elapsed time: 4355.363706 msecs"
  
"Elapsed time: 4416.98562 msecs"
  
1:1 user= #Namespace cellular-automata-basic
  
1:2 cellular-automata-basic=
  
  
I would thank a lot any hint, suggestion, comment, or
  
whatever... :-)
  
  
Best regards,
  
  
 Rubn
  
  
(*) The update consists on adding the values of the 8 neighbours
  
of every cell and changing it if that sum is between two fixed
  
numbers.
  
  



-- 
Rubn BJAR HERNNDEZ

Dpto. de Informtica e Ingeniera de Sistemas - Universidad de Zaragoza
(Computing and Systems Engineering Department - Universidad de Zaragoza)
c/ Mara de Luna 1, 50018 Zaragoza, Spain

Tel: (+34) 976 76 2332 (Fax: 1914)  
e-mail: rbe...@unizar.es

Grupo IA3 (IA3 Laboratory) - http://iaaa.cps.unizar.es








-- 
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
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Newbie question about vector performance

2010-05-28 Thread Michael Gardner
On May 28, 2010, at 8:47 AM, Rubén Béjar wrote:

 I would thank a lot any hint, suggestion, comment, or
 whatever... :-)

As a style issue I'd suggest using inc, dec, neg?, pos?, and zero? instead of 
the various (+ x 1), ( x 0), etc. in your code. This actually seems to improve 
performance a bit on my laptop, but it's nothing amazing. To get good 
performance you're likely going to need to do some type hinting.

http://clojure.org/java_interop#Java%20Interop-Type%20Hints

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Elegant way of expressing this in Clojure?

2010-05-28 Thread CuppoJava
Thanks Christophe.
That looks relatively clean as well. (As clean as the Java version
anyway). And it's the fastest version shown so far.
  -Patrick

On May 28, 9:57 am, Christophe Grand christo...@cgrand.net wrote:
 On Fri, May 28, 2010 at 3:09 PM, CuppoJava patrickli_2...@hotmail.comwrote:

  d,w are arrays that are passed to me by a machine learning algorithm
  so it's not something that I have control over. There are roughly 100
  words per doc.

 ok

  Thanks for everyone's help. I wonder if directly mutable primitives is
  something that is hard to put into Clojure? Or something that's
  explicitly avoided because it distracts from the FP paradigm. The lack
  of them is making this code somewhat awkward to write.

 In this case there is no need for mutable primitives.
 You can try a direct translation of your java code:

 (let [n (alength w)]
   (loop [doc (int -1) i (int 0)]
     (when ( i n)
       (let [new-doc (aget d i)
         (when-not (= doc new-doc)
           (load doc))
         (when-not (malformed doc)
           (process new-doc (aget w i))
           (recur new-doc (inc i)))

 You can tweeak it here and there (== and unchecked-inc for example) and
 don't forget to typehint d and w if Clojure doesn't infer their type.

 Christophe

 --
 Brussels, 23-25/6http://conj-labs.eu/
 Professional:http://cgrand.net/(fr)
 On Clojure:http://clj-me.cgrand.net/(en)

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Lazy map implementation

2010-05-28 Thread Robert Luo

On 5月28日, 下午11时01分, Sean Devlin francoisdev...@gmail.com wrote:
 Can memoize do the job for you?

No. What I need is something can act as a map to replace the request
map in compojure/ring so that it can be used in any middleware/
handles.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Lazy map implementation

2010-05-28 Thread Joost
On May 28, 4:39 pm, Robert Luo robort...@gmail.com wrote:
 I need a lazy map in my compojure based application to inject data
 into handlers. I searched the web for an implementation, I got one
 from Meikel which was written in 2008. Is there any recommendation?

 Thanks.

I don't really see what you're trying to do with this, but as an
alternative, you can assoc lazy-seqs to a standard map. That is, if
your values are going to be seqs (IME, most of the things you want
lazy evaluation for are).

Joost.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Newbie question about vector performance

2010-05-28 Thread Luke VanderHart
I can't see your code due to the IT policies here, but I can make some
generalizations - these are assuming your code is correct and you're
not accidentally using an exponential algorithm (which I wouldn't
preclude, 4 minutes does sound truly excessively slow, even for
vectors).

Vectors are significantly slower than Java arrays due to their copy-on-
write semantics.

You have a few options, both of which are considered perfectly
acceptable Clojure for high-performance numerical code:

1. Use transients (http://clojure.org/transients) when you update your
vectors. This should give you a pretty significant speed increase.
2. Alternatively, use native java arrays. Clojure provides a complete
set of functions for creating and mutating raw Java arrays
3. Use type hints to eliminate reflection at choke points in your
processing.

If you do 2 and 3, you should get pretty close to native Java speeds.


On May 28, 12:20 pm, Rubén Béjar ruben.be...@gmail.com wrote:
 Hi again,
 I have tried a few more things:
 I have done the same in Java but using an array
 of Integers, instead of an array of ints. It just takes
 78 ms. (more than 16, still far less than 4 secs).
 I have also tried with an update function which just returns a
 fixed 1. It still takes some 400 ms. to update de
 data vector of the CA. This is similar to the time
 it is giving me to create a vector of 1's with this function:
 (time (vec (repeat 25 1))).
 I was not expecting Clojure vectors so much slower than
 Java arrays. Is that comparison so unfair? Next thing
 I am trying is using Java Vectors in my Java
 implementation...
Rubén
 Rubén Béjar escribió:Hi all,
 I am new to the list and to Clojure. I have been working in
 implementing some 2D cellular automata (CA) just to have a project
 to teach Clojure to myself. After some work I have something that
 works, but it is pretty slow. The function that takes a CA
 of 500x500 cells (integers) and returns an updated (*) copy
 takes 4 s. (using Clojure vectors), while doing more or less the same in Java 
 (using arrays and primitive types) takes more or
 less 16 *ms.*. I expected some difference, but not that big. Before
 trying to use Java arrays and primitive types
 in Clojure, I would like to know how my Clojure approach can
 be improved  (I am willing to sacrifice some performance to keep
 it more Clojure, but not that much).
 As I do not want to post a bunch of horrible code full of comments
 and not properly indented, I have extracted what i hope are the
 main pieces, written some comments and posted it here:http://snipt.org/Okpk
 Pasting that code in a new file in Eclipse (I am using
 counterclockwise) and running it in the REPL prints this:
 Clojure 1.1.0-alpha-SNAPSHOT
 Elapsed time: 4355.363706 msecs
 Elapsed time: 4416.98562 msecs
 1:1 user= #Namespace cellular-automata-basic
 1:2 cellular-automata-basic=
 I would thank a lot any hint, suggestion, comment, or
 whatever... :-)
 Best regards,
Rubén
 (*) The update consists on adding the values of the 8 neighbours
 of every cell and changing it if that sum is between two fixed
 numbers.-- Rubén BÉJAR HERNÁNDEZ Dpto. de Informática e Ingeniería de 
 Sistemas - Universidad de Zaragoza (Computing and Systems Engineering 
 Department - Universidad de Zaragoza) c/ María de Luna 1, 50018 Zaragoza, 
 Spain Tel: (+34) 976 76 2332 (Fax: 1914) e-mail:rbe...@unizar.esgrupo IA3 
 (IA3 Laboratory) -http://iaaa.cps.unizar.es

On May 28, 12:20 pm, Rubén Béjar ruben.be...@gmail.com wrote:
 Hi again,
 I have tried a few more things:
 I have done the same in Java but using an array
 of Integers, instead of an array of ints. It just takes
 78 ms. (more than 16, still far less than 4 secs).
 I have also tried with an update function which just returns a
 fixed 1. It still takes some 400 ms. to update de
 data vector of the CA. This is similar to the time
 it is giving me to create a vector of 1's with this function:
 (time (vec (repeat 25 1))).
 I was not expecting Clojure vectors so much slower than
 Java arrays. Is that comparison so unfair? Next thing
 I am trying is using Java Vectors in my Java
 implementation...
    Rubén
 Rubén Béjar escribió:Hi all,
 I am new to the list and to Clojure. I have been working in
 implementing some 2D cellular automata (CA) just to have a project
 to teach Clojure to myself. After some work I have something that
 works, but it is pretty slow. The function that takes a CA
 of 500x500 cells (integers) and returns an updated (*) copy
 takes 4 s. (using Clojure vectors), while doing more or less the same in Java 
 (using arrays and primitive types) takes more or
 less 16 *ms.*. I expected some difference, but not that big. Before
 trying to use Java arrays and primitive types
 in Clojure, I would like to know how my Clojure approach can
 be improved  (I am willing to sacrifice some performance to keep
 it more Clojure, but not that much).
 As I do not want to post a bunch of horrible code full of comments
 and not 

Re: Elegant way to replace a few words in string

2010-05-28 Thread Laurent PETIT
The rule should really always be: no warning at all (with
*warn-on-reflection* set to true, of course).

And in this case, I did what is necessary to avoid reflection warnings. Try
it yourself.

2010/5/28 John Cromartie jcromar...@gmail.com

 I feel like the type hints should be left out until you really need
 them, since they kind of clobber the routine's readability.

 -John

 On May 28, 9:07 am, Laurent PETIT laurent.pe...@gmail.com wrote:
  (reduce
(fn [#^String s [#^CharSequence what #^CharSequence with]]
  (.replace s what with))
Foo12 Bar130 Qoo20
{Foo XF Bar XB Qoo XQ})
 
  2010/5/28 Oleg oleg.richa...@gmail.com
 
 
 
   Hello Guys!
 
   I have a string for example Foo12 Bar130 Qoo20 and map like this
   {Foo XF Bar XB Qoo XQ}.
   I want get: XF12 XB130 XQ20
 
   I want to replace words in string based on map association. What is
   the elegant way to do it? Sure, i can use loop and recur
   to make string enter the next replacement, but is there another way to
   do it better?
 
   Cheers, Oleg
 
   --
   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
   Note that posts from new members are moderated - please be patient with
   your first post.
   To unsubscribe from this group, send email to
   clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 clojure%2bunsubscr...@googlegroups.comclojure%252bunsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en

 --
 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
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Elegant way to replace a few words in string

2010-05-28 Thread Michael Gardner
On May 28, 2010, at 12:42 PM, Laurent PETIT wrote:

 The rule should really always be: no warning at all (with 
 *warn-on-reflection* set to true, of course).

I strongly disagree. Why should you care about those sorts of warnings unless 
you've already identified a bottleneck that needs elimination? IMO the rule 
should be: write it the simplest way you can first, then optimize only what 
your benchmarks tell you needs optimizing.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: 57 varieties

2010-05-28 Thread Steve Purcell
On 28 May 2010, at 11:39, Philip Hudson wrote:

 I've been trying for the best part of a month to get 
 SLIME/SWANK/Clojure/clojure-mode working in emacs 23.2 on Mac OS X 10.5 
 without using ELPA, which unfortunately seems to break everything including 
 itself in my setup.
 


If it helps, I've got a working non-ELPA set-up which you can browse here:

  http://github.com/purcell/emacs.d

It uses git versions of Slime, Clojure-mode and Swank-clojure (as git 
submodules). Feel free to mail me off-list with any questions.

-Steve

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Lazy map implementation

2010-05-28 Thread Meikel Brandmeyer
Hi,

On Fri, May 28, 2010 at 07:39:55AM -0700, Robert Luo wrote:
 I need a lazy map in my compojure based application to inject data
 into handlers. I searched the web for an implementation, I got one
 from Meikel which was written in 2008. Is there any recommendation?

Just FYI:
It's still maintained and will soon move to deftype to be ready
for 1.2. Then I will also put a release on Clojars.

Sincerely
Meikel

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Elegant way to replace a few words in string

2010-05-28 Thread Laurent PETIT
2010/5/28 Michael Gardner gardne...@gmail.com

 On May 28, 2010, at 12:42 PM, Laurent PETIT wrote:

  The rule should really always be: no warning at all (with
 *warn-on-reflection* set to true, of course).

 I strongly disagree. Why should you care about those sorts of warnings
 unless you've already identified a bottleneck that needs elimination?


Because in this world of non typed vars and highly generic code, I tend to
consider compiler warnings being of similar importance to compiler errors in
statically typed languages.
With the additional benefit that since they are warnings, they don't get in
your way while you're experimenting and shaping your project's code. But one
should consider with care, when commiting code, letting the warnings
accumulate out of control to the point you're not able to spot the
apparition of new ones.


 IMO the rule should be: write it the simplest way you can first, then
 optimize only what your benchmarks tell you needs optimizing.


Reflection warnings not only reflect potential optimization problems, but
also potential bugs, like for the reflection warnings I added in the above
example: the String.replace() function is highly overloaded in such a way
that if you pass 2 String to it, one function will be taken, but if you
explicitly cast the Strings to CharSequences, another implementation (not
considering the first string to be a regexp) is taken.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Elegant way to replace a few words in string

2010-05-28 Thread Laurent PETIT
2010/5/28 Michael Gardner gardne...@gmail.com

 On May 28, 2010, at 12:42 PM, Laurent PETIT wrote:

  The rule should really always be: no warning at all (with
 *warn-on-reflection* set to true, of course).

 I strongly disagree. Why should you care about those sorts of warnings
 unless you've already identified a bottleneck that needs elimination?



Said differently than my previous answer : consider removing warnings as the
act of keeping your code in a good state/shape. I tend to not get rid of
warnings enough in my own java code, but for clojure production code, I
would take warnings wayy more  seriously than e.g. java warnings.

My 0,02€,

-- 
Laurent

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Datatype Usage Examples

2010-05-28 Thread Sina K. Heshmati
Hi Meikel,

Meikel Brandmeyer wrote:
 SinDoc wrote:
 I was wondering if someone could point me to recent usage examples of
 deftype, defrecord, and reify. Reading [1] helped a lot but it wasn't
 particularly easy to find it since it's not linked from the sidebar.

 Specifically, what I'd like to know is:

  - How to define and access member data fields -also mutable in case
 of deftype- to my ADTs.
  - Whether I can refer to type instances -an equivalent to the 'this'
 keyword in Java.
  - How to define constructors.
 
 The modified memoize sparked some examples for this:
 http://kotka.de/blog/2010/03/memoize_done_right.html#protocols

Thank you for the link, Meikel. It's very well-written.

Kind regards,
SinDoc

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Datatype Usage Examples

2010-05-28 Thread Sina K. Heshmati
Hi Krukow,

Krukow wrote:
 SinDoc wrote:
 I was wondering if someone could point me to recent usage examples of
 deftype, defrecord, and reify. Reading [1] helped a lot but it wasn't
 particularly easy to find it since it's not linked from the sidebar.
 
 Blog: http://blog.higher-order.net/2010/05/05/circuitbreaker-clojure-1-2/
 
 Code: http://github.com/krukow/clojure-circuit-breaker

This is a good example. I like the way merge is used to avoid redundancy while 
dispatching methods. Deftype is not being used in the example but if I want the 
map, I should go for defrecord anyway.

The only member data _I'm_ able find are the ones that are passed to the 
default constructor, namely at the time that the abstraction is reified. What 
if I'd have to give create a member field that is not necessarily known by the 
caller or instantiator. That is, it's the abstraction itself that has to create 
and maintain the value of that field.

One of the abstraction that I was hoping to implement in Clojure is a 
Scheme-like pair in order to demonstrate various memory management techniques. 
Once we do (cons a b), an abstract pair should be made that only contains a 
pointer to its location in memory: (tag address). Here's the pair 
implementation [2] in Scheme R5RS.

I'm thinking optional parameters could be used. Since callers don't have to 
provide values for them, I can use them to maintain the state for each 
instance. I might be missing the obvious here since these are data types and 
there should be an explicit way to say that this _thing_ is my data.

 Specifically, what I'd like to know is:

  - How to define and access member data fields -also mutable in case
 of deftype- to my ADTs.
 
 The example is there for immutable fields. Why do you need mutability?

I don't need it. Just wanted to see some examples. I'd rather go immutable 
anyway ;)

  - Whether I can refer to type instances -an equivalent to the 'this'
 keyword in Java.
 
 The first argument to a protocol function corresponds to the this
 keyword in Java, e.g.,
 
 (extend ClosedState CircuitBreakerTransitions
   ...
  :on-success
(fn [{f :fail-count p :policy, :as s}] ;; note we can destructure
 the 'this' argument (s)
  (if (zero? f) s (ClosedState. p 0)))
 ...)

Nice!

  - How to define constructors.
 
 A single constructor is automatically defined for you. In my case with
 two params:
 
 (ClosedState. policy fail-count)
 
 If you need more flexibility, I believe you need gen-class, but I am
 unsure.

I can live with one constructor for now.

 [1]http://clojure.org/datatypes
[2] http://is.gd/ctoSg

 Hope that helps. Kind Regards,

Thank you very much, Krukow. It sure did help.

Kind regards,
SinDoc

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: do clojure and la(tex) have something in common ?

2010-05-28 Thread Perry Trolard
Hi Mike,

On May 25, 9:04 am, Mike Meyer mwm-keyword-googlegroups.
620...@mired.org wrote:

 I find the reference to old fashioned xslt amusing, considering that
 how new it is. Or maybe how old I am. Of course, part of the point of
 XML is that you have a wide variety of tools to pick from for working
 with it; xslt is just one of them. I've had good experiences just
 adding an xpath library to a good language. A clojure xpath library
 that returned result sets as lazy sequences sounds like a really cool
 way to do this, though that would again be just a single component in
 such a system.

Re: a clojure XPath/XQuery library that returns a lazy seq of the
results, check out my wrapper of Michael Kay's Saxon library:

  http://github.com/pjt/saxon

Saxon computes XPath results mostly lazily,  I retain this laziness
in my wrapper. (I say somewhat because Saxon stays one result
element ahead of realization.)

Best,
Perry


-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Anyone experienced in using clojure as a database

2010-05-28 Thread Erik Söhnel

 I haven't had a chance to play with your code yet but at first glance
 it looks good. Does the above mean that all set operations are
 automatically supported and the accelerated?

Unfortunately not for all operations. For example, clojure.set/join
uses its own index function, which builds an index for every join
invokation. On the other hand, difference, union and intersection use
the primary-key index (through .equals), which may be a bit faster
than hashing whole tuples.

 Do you think it is possible to implement join/union etc so that they
 produce lazy relations (or just lazy-seq of rows)? That would be very
 useful in many common use cases (instead of cursors).

I tried it once, but I was too ambigious. Providing lazy relations and
hiding the implementation details (SQL or clojure) while wrapping it
in a relational algebra API just didn't work out to be practical :).
Maybe that snippet is a good foundation to start a more humble
approach.

But with clojure you get already a general-purpose, lazy select and
project
operations (filter and map). Adding lazy joins and set-operations
isn't
that hard. Making them efficient beyond basic index usage is harder.

 As for the storage persistence - that's a low priority (at least for
 me), but it would be good to have at least some method for tying a
 relation to such storage (like a tie function in Perl).

 Can you tell me more about these hooks to Clojure STM and Cells?

Currently, there are no Hooks, and Cells are just an idea:

http://www.assembla.com/wiki/show/clojure/Cells
http://groups.google.com/group/clojure/browse_thread/thread/aa22a709501a64ac

Erik

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure script with shebangoid on windows

2010-05-28 Thread Paul Moore
On 28 May 2010 16:17, alux alu...@googlemail.com wrote:
 Hello Paul,

 thats much better, many thanks!

I've added it to the Wikibooks page,
http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Shebang_Scripting_in_Clojure

Paul.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Datatype Usage Examples

2010-05-28 Thread Krukow


On May 28, 9:59 pm, Sina K. Heshmati s...@khakbaz.com wrote:
 Hi Krukow,
[snip]
 The only member data _I'm_ able find are the ones that are passed to the 
 default constructor, namely at the time that the abstraction is reified. What 
 if I'd have to give create a member field that is not necessarily known by 
 the caller or instantiator. That is, it's the abstraction itself that has to 
 create and maintain the value of that field.

You mean something like a private field in Java that is not supplied
as a constructor argument, but computed as a function of the other
fields, and which is not necessarily accessible from callers. If I
understand correctly what it is you want, I think you are moving away
from Clojure, trying to somehow encapsulate an object. See RH's note
on encapsulation: Encapsulation of information is folly. Fields are
public. Use protocols/interfaces to avoid dependencies [1].

Again, I believe that you can use gen-class if you really need to do
this.


 One of the abstraction that I was hoping to implement in Clojure is a 
 Scheme-like pair in order to demonstrate various memory management 
 techniques. Once we do (cons a b), an abstract pair should be made that only 
 contains a pointer to its location in memory: (tag address). Here's the pair 
 implementation [2] in Scheme R5RS.


So you want a mutable pair (fst, snd) where fst and snd can be mutated
arbitrarily? This is definately not the Clojure way :) In Clojure,
you'd either use a pair of atoms or refs, giving you managed
mutability, or you'd simply write a functional pair.


[snip]
 Thank you very much, Krukow. It sure did help.

 Kind regards,
 SinDoc

Glad it did :)

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: API in Clojure for Java folklore

2010-05-28 Thread ka
I've also added a :class-doc key to the macro -

(gen-class+javadoc
  :class-doc Class Docs
 ul li One /li li Two /li /ul
 
  :name a.b.c.MyCoolClass
  :methods [
  #^{:static true} [method1
[clojure.lang.PersistentArrayMap] int]
  #^{:static true} [method2 [int int float]
clojure.lang.LazySeq]
  #^{:static true} [method3 [] Object]
  ])

Thanks

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Some suggestions for transients

2010-05-28 Thread ka
Oops didn't know that Rich had already answered.  Google seems to
think that our posts are commutative :/ (often they're not, or are
they? I can't take a stand on this) and just uses the commute fn
instead of using alter and failing the transaction (informing us); but
it does allow for more concurrency as Rich mentions in the docs of
commute :P.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure Master on android

2010-05-28 Thread MHOOO
Worked around the issue by removing some unnecessary stuff from the
clojure build.xml, thus making the final clojure.jar smaller. (In
particular the dx program would halt on generating code for zip
$remove).

On May 28, 2:59 pm, Remco van 't Veer rwvtv...@gmail.com wrote:
 Hmm, I have a 32 bit setup to that's probably the issue:

   java version 1.6.0_18
   OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
   OpenJDK Server VM (build 14.0-b16, mixed mode)

 Don't have a clue how to fix this.

 On 2010/05/28 11:06, MHOOO wrote:

  On May 28, 9:26 am, Remco van 't Veer rwvtv...@gmail.com wrote:

  Try giving the dx command a bit more memory by adding something like:

    -Jmx1024m

  before --dex.

  Unfortunately that didn't work quite so well. The java process ended
  up using 1.4GB ram without terminating (waited approximately 10
  minutes before I killed it).
  I am using:
  ---
  tho...@lisper:/$ java -version
  java version 1.6.0_18
  OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
  OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

  tho...@lisper:/$ uname -a
  Linux lisper 2.6.32-22-generic #33-Ubuntu SMP Wed Apr 28 13:28:05 UTC
  2010 x86_64 GNU/Linux

  tho...@lisper:/$ cat /etc/*-release
  DISTRIB_ID=Ubuntu
  DISTRIB_RELEASE=10.04
  DISTRIB_CODENAME=lucid
  DISTRIB_DESCRIPTION=Ubuntu 10.04 LTS
  --
  The script I am using (hello-dalvik.sh):
  --
  #!/bin/sh

  export ANDROID_DIR=/home/thomas/sources/android-sdk-linux_86
  export CLOJURE_JAR=/home/thomas/sources/clojure/clojure.jar

  set -e
  rm -rf hello-dalvik; mkdir hello-dalvik; cd hello-dalvik

  echo '(ns HelloDalvik (:gen-class)) (defn -main [] (println (str
  hello dalvik from clojure  (clojure-version'  HelloDalvik.clj
  java -classpath $CLOJURE_JAR:. -Dclojure.compile.path=.
  clojure.lang.Compile HelloDalvik

  $ANDROID_DIR/platforms/android-8/tools/dx -Jmx1024m --dex --
  output=classes.dex HelloDalvik*.class $CLOJURE_JAR
  $ANDROID_DIR/platforms/android-8/tools/aapt add HelloDalvik.jar
  classes.dex
  jar uf HelloDalvik.jar -C ../src/clj clojure/version.properties
  $ANDROID_DIR/tools/adb push HelloDalvik.jar /sdcard/

  echo dalvikvm -classpath /sdcard/HelloDalvik.jar HelloDalvik \; exit |
  $ANDROID_DIR/tools/adb shell
  -
  Anything wrong with my configuration?



-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Android 'dex' stage takes a very long time with Clojure

2010-05-28 Thread MHOOO
I've just started with development on android myself, but from what
I've read on the internets, you could probably write a .dex loader in
the default classes.dex (which will be loaded when you start your
application) and write your actual program in other .dex files. This
way you'll be able to compile the entire clojure system into the
classes.dex and will only have to update your custom .dex files.
This is actually something I'm currently trying to get to work.
For further info, see:
http://code.google.com/p/android/issues/detail?id=7147
http://developer.android.com/reference/dalvik/system/DexClassLoader.html

On May 28, 4:12 pm, Matt Clark matt.clar...@gmail.com wrote:
 I'm new to Android, but I've been wanting to give it a try for a while
 so I thought I'd try using Clojure's master branch.  It all seems to
 be working fairly well except the dex stage of installation takes
 around 2 minutes for a simple Hello World app.  How do others get
 around this lag?

 I'm pretty sure it's caused by the large clojure.core namespace, as
 I've already taken everything else that I can out of the clojure jar
 file.  I'm just not sure if there's anything else I can do.  I am
 using emacs and android-mode, if that is of any help.  I've also tried
 giving it more memory as suggested 
 here:http://groups.google.com/group/clojure/msg/c38e015582cf7623

 Thanks a lot

 Matt

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Lazy map implementation

2010-05-28 Thread Robert Luo


 Just FYI:
 It's still maintained and will soon move to deftype to be ready
 for 1.2. Then I will also put a release on Clojars.

 Sincerely
 Meikel

Thanks Meikel, I will try your implementation in my application.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Lazy map implementation

2010-05-28 Thread Robert Luo

On 5月29日, 上午12时50分, Joost jo...@zeekat.nl wrote:


 I don't really see what you're trying to do with this, but as an
 alternative, you can assoc lazy-seqs to a standard map. That is, if
 your values are going to be seqs (IME, most of the things you want
 lazy evaluation for are).

 Joost.

The reason is very simple:

Existing code base (ring) choose map as the data structure, I want my
new feature seamless merge into it, then I can use all the existing
functions, and new codes become normal citizen in the design.

The reason I ask is that I think this is so common a need, and its
idea fits into clojure's philosophy. I do not want to reinvent wheels
on a common need.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


(apply interleave [[1 2]])

2010-05-28 Thread Eugen Dück
When I do

(apply interleave some-colls)

and some-colls is a sequence/collection of only one sequence/
collection, it will throw:

user= (apply interleave [[1 2]])
java.lang.IllegalArgumentException: Wrong number of args passed to:
core$interleave (NO_SOURCE_FILE:0)

(Of course I don't need the apply to cause that exception, but calling
interleave directly with just one parameter doesn't make any sense.
But in the case you use apply, having only one sequence in a sequence
is a possible corner case that can arise at run time)

In order to make interleave more general, I'd like to add a one param
overload to interleave like

(defn interleave
  Returns a lazy seq of the first item in each coll, then the second
etc.
  ([c] (seq c))
  ...

or even just

(defn interleave
  ([c] c)

but that would break the contract of interleave, in that it returns
whatever you pass in, which might not be a sequence, as is the case in
my example.

Any thoughts on this?

Eugen

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any issues with launching in clojure, calling Java code, Java code calling clojure

2010-05-28 Thread BerlinBrown
So a lot of Clojure variables are set at the JVM/Class level

Hmm...

On May 27, 10:29 pm, Jason Smith ja...@lilypepper.com wrote:
 The issue that you'll run into is that there is one lexical scope that
 is shared by all calls toClojure.  The only ways around this are (1)
 run it in another process, and (2) load theClojureJARs into a
 ClassLoader at runtime, and throw the ClassLoader away after every
 call.

 The overhead for option 2 is between 0.5 and 1 second per call,
 becauseClojurehas to be re-inited.  For option 1, it's even more
 because you are starting Java, then initing Java.

 Threads have nothing to do with theClojurelexical scoping.  If you
 run 100 threads, they normally all share the same variables,
 namespaces, and functions.

 For more info, you can check 
 outhttp://sandflea.googlecode.com/svn/site/maven-clojure-plugin/1.1.0/cl...
 (http://code.google.com/p/sandflea/source/browse/maven-clojure-plugin/
 trunk/clojure-commons/src/main/java/sandflea/clojure/scripting/
 ClojureScripting.java).

 On May 27, 3:46 pm, BerlinBrown berlin.br...@gmail.com wrote:

  I enjoyclojureand I think I am breaking all the rules.  I have an
  app that I originally created inclojure.  It has been a year off and
  on.  And I merged that code with some existing java database code.

  Theclojurecode invokes the java code.  Now, I want to have a script
  environment where users can invoke their ownclojurecode.  But I was
  think theclojurecode should run in a completely new, separate
  environment, via a thread.

  Basically.

  1.Clojureis invokved (clojure.main)
  2. I haveclojurecode that invokes code originally written in Java
  3. That java code creates another separateclojureinstance, parsing a
 clojurescript. (an embedded dsl)

  It isn't that confusing.  It is almost akin to invoking a JSP page
  from a running web server.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any issues with launching in clojure, calling Java code, Java code calling clojure

2010-05-28 Thread BerlinBrown
I don't think option 2 would take that long.  Even my clojure startup
is not half a second on a modern machine.

On May 27, 10:29 pm, Jason Smith ja...@lilypepper.com wrote:
 The issue that you'll run into is that there is one lexical scope that
 is shared by all calls toClojure.  The only ways around this are (1)
 run it in another process, and (2) load theClojureJARs into a
 ClassLoader at runtime, and throw the ClassLoader away after every
 call.

 The overhead for option 2 is between 0.5 and 1 second per call,
 becauseClojurehas to be re-inited.  For option 1, it's even more
 because you are starting Java, then initing Java.

 Threads have nothing to do with theClojurelexical scoping.  If you
 run 100 threads, they normally all share the same variables,
 namespaces, and functions.

 For more info, you can check 
 outhttp://sandflea.googlecode.com/svn/site/maven-clojure-plugin/1.1.0/cl...
 (http://code.google.com/p/sandflea/source/browse/maven-clojure-plugin/
 trunk/clojure-commons/src/main/java/sandflea/clojure/scripting/
 ClojureScripting.java).

 On May 27, 3:46 pm, BerlinBrown berlin.br...@gmail.com wrote:

  I enjoyclojureand I think I am breaking all the rules.  I have an
  app that I originally created inclojure.  It has been a year off and
  on.  And I merged that code with some existing java database code.

  Theclojurecode invokes the java code.  Now, I want to have a script
  environment where users can invoke their ownclojurecode.  But I was
  think theclojurecode should run in a completely new, separate
  environment, via a thread.

  Basically.

  1.Clojureis invokved (clojure.main)
  2. I haveclojurecode that invokes code originally written in Java
  3. That java code creates another separateclojureinstance, parsing a
 clojurescript. (an embedded dsl)

  It isn't that confusing.  It is almost akin to invoking a JSP page
  from a running web server.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Android activity fails because of dependency on java.beans.Introspector

2010-05-28 Thread MHOOO
I've just now tried to get an android activity to run, however when
executing the application (hello world, really) I get the following
error:

I/ActivityManager(   59): Starting activity: Intent
{ act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x1020
cmp=tk.clojure/.core }
I/ActivityManager(   59): Start proc tk.clojure for activity
tk.clojure/.core: pid=307 uid=10031 gids={1015}
I/global  (  307): Default buffer size used in BufferedReader
constructor. It would be better to be explicit if an 8k-char buffer is
required.
D/dalvikvm(  307): GC_FOR_MALLOC freed 5960 objects / 281936 bytes in
86ms
D/dalvikvm(  307): GC_FOR_MALLOC freed 8151 objects / 362960 bytes in
72ms
D/dalvikvm(  307): GC_FOR_MALLOC freed 8754 objects / 393960 bytes in
73ms
I/dalvikvm(  307): Could not find method
java.beans.Introspector.getBeanInfo, referenced from method
clojure.core$bean.invoke
W/dalvikvm(  307): VFY: unable to resolve static method 15023: Ljava/
beans/Introspector;.getBeanInfo (Ljava/lang/Class;)Ljava/beans/
BeanInfo;
D/dalvikvm(  307): VFY: replacing opcode 0x71 at 0x0044
D/dalvikvm(  307): VFY: dead code 0x0047-012c in Lclojure/core
$bean;.invoke (Ljava/lang/Object;)Ljava/lang/Object;
D/dalvikvm(  307): GC_FOR_MALLOC freed 9136 objects / 387744 bytes in
74ms
D/dalvikvm(  307): GC_FOR_MALLOC freed 11975 objects / 465912 bytes in
84ms
D/dalvikvm(  307): GC_FOR_MALLOC freed 11467 objects / 506384 bytes in
81ms
D/dalvikvm(  307): GC_FOR_MALLOC freed 12562 objects / 507344 bytes in
87ms
W/dalvikvm(  307): Exception Ljava/lang/NullPointerException; thrown
during Lclojure/core__init;.clinit
W/dalvikvm(  307): Exception Ljava/lang/ExceptionInInitializerError;
thrown during Lclojure/lang/RT;.clinit
W/dalvikvm(  307): Exception Ljava/lang/ExceptionInInitializerError;
thrown during Ltk/clojure/core;.clinit
W/dalvikvm(  307): Class init failed in newInstance call (Ltk/clojure/
core;)
D/AndroidRuntime(  307): Shutting down VM
W/dalvikvm(  307): threadid=1: thread exiting with uncaught exception
(group=0x4001d800)
E/AndroidRuntime(  307): FATAL EXCEPTION: main
E/AndroidRuntime(  307): java.lang.ExceptionInInitializerError
E/AndroidRuntime(  307):at
java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(  307):at
java.lang.Class.newInstance(Class.java:1429)
E/AndroidRuntime(  307):at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime(  307):at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2577)
E/AndroidRuntime(  307):at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2679)
E/AndroidRuntime(  307):at android.app.ActivityThread.access
$2300(ActivityThread.java:125)
E/AndroidRuntime(  307):at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(  307):at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  307):at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime(  307):at
android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(  307):at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  307):at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  307):at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(  307):at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(  307):at
dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  307): Caused by:
java.lang.ExceptionInInitializerError
E/AndroidRuntime(  307):at
clojure.lang.Namespace.init(Namespace.java:34)
E/AndroidRuntime(  307):at
clojure.lang.Namespace.findOrCreate(Namespace.java:173)
E/AndroidRuntime(  307):at
clojure.lang.Var.internPrivate(Var.java:94)
E/AndroidRuntime(  307):at tk.clojure.core.clinit(Unknown
Source)
E/AndroidRuntime(  307):... 15 more
E/AndroidRuntime(  307): Caused by:
java.lang.ExceptionInInitializerError
E/AndroidRuntime(  307):at java.lang.Class.classForName(Native
Method)
E/AndroidRuntime(  307):at java.lang.Class.forName(Class.java:
235)
E/AndroidRuntime(  307):at
clojure.lang.RT.loadClassForName(RT.java:1569)
E/AndroidRuntime(  307):at clojure.lang.RT.load(RT.java:398)
E/AndroidRuntime(  307):at clojure.lang.RT.load(RT.java:380)
E/AndroidRuntime(  307):at clojure.lang.RT.doInit(RT.java:415)
E/AndroidRuntime(  307):at clojure.lang.RT.clinit(RT.java:
301)
E/AndroidRuntime(  307):... 19 more
E/AndroidRuntime(  307): Caused by: java.lang.NullPointerException
E/AndroidRuntime(  307):at
java.util.Properties.load(Properties.java:290)
E/AndroidRuntime(  307):at clojure.core
$fn__5418.invoke(core.clj:5444)
E/AndroidRuntime(  307):

Re: Android activity fails because of dependency on java.beans.Introspector

2010-05-28 Thread MHOOO
Doing some digging I found the problem:
I forgot to include the clojure/version.properties file in my .apk.

On May 29, 4:02 am, MHOOO thomas.karol...@googlemail.com wrote:
 I've just now tried to get an android activity to run, however when
 executing the application (hello world, really) I get the following
 error:
 
 I/ActivityManager(   59): Starting activity: Intent
 { act=android.intent.action.MAIN
 cat=[android.intent.category.LAUNCHER] flg=0x1020
 cmp=tk.clojure/.core }
 I/ActivityManager(   59): Start proc tk.clojure for activity
 tk.clojure/.core: pid=307 uid=10031 gids={1015}
 I/global  (  307): Default buffer size used in BufferedReader
 constructor. It would be better to be explicit if an 8k-char buffer is
 required.
 D/dalvikvm(  307): GC_FOR_MALLOC freed 5960 objects / 281936 bytes in
 86ms
 D/dalvikvm(  307): GC_FOR_MALLOC freed 8151 objects / 362960 bytes in
 72ms
 D/dalvikvm(  307): GC_FOR_MALLOC freed 8754 objects / 393960 bytes in
 73ms
 I/dalvikvm(  307): Could not find method
 java.beans.Introspector.getBeanInfo, referenced from method
 clojure.core$bean.invoke
 W/dalvikvm(  307): VFY: unable to resolve static method 15023: Ljava/
 beans/Introspector;.getBeanInfo (Ljava/lang/Class;)Ljava/beans/
 BeanInfo;
 D/dalvikvm(  307): VFY: replacing opcode 0x71 at 0x0044
 D/dalvikvm(  307): VFY: dead code 0x0047-012c in Lclojure/core
 $bean;.invoke (Ljava/lang/Object;)Ljava/lang/Object;
 D/dalvikvm(  307): GC_FOR_MALLOC freed 9136 objects / 387744 bytes in
 74ms
 D/dalvikvm(  307): GC_FOR_MALLOC freed 11975 objects / 465912 bytes in
 84ms
 D/dalvikvm(  307): GC_FOR_MALLOC freed 11467 objects / 506384 bytes in
 81ms
 D/dalvikvm(  307): GC_FOR_MALLOC freed 12562 objects / 507344 bytes in
 87ms
 W/dalvikvm(  307): Exception Ljava/lang/NullPointerException; thrown
 during Lclojure/core__init;.clinit
 W/dalvikvm(  307): Exception Ljava/lang/ExceptionInInitializerError;
 thrown during Lclojure/lang/RT;.clinit
 W/dalvikvm(  307): Exception Ljava/lang/ExceptionInInitializerError;
 thrown during Ltk/clojure/core;.clinit
 W/dalvikvm(  307): Class init failed in newInstance call (Ltk/clojure/
 core;)
 D/AndroidRuntime(  307): Shutting down VM
 W/dalvikvm(  307): threadid=1: thread exiting with uncaught exception
 (group=0x4001d800)
 E/AndroidRuntime(  307): FATAL EXCEPTION: main
 E/AndroidRuntime(  307): java.lang.ExceptionInInitializerError
 E/AndroidRuntime(  307):        at
 java.lang.Class.newInstanceImpl(Native Method)
 E/AndroidRuntime(  307):        at
 java.lang.Class.newInstance(Class.java:1429)
 E/AndroidRuntime(  307):        at
 android.app.Instrumentation.newActivity(Instrumentation.java:1021)
 E/AndroidRuntime(  307):        at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
 2577)
 E/AndroidRuntime(  307):        at
 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
 2679)
 E/AndroidRuntime(  307):        at android.app.ActivityThread.access
 $2300(ActivityThread.java:125)
 E/AndroidRuntime(  307):        at android.app.ActivityThread
 $H.handleMessage(ActivityThread.java:2033)
 E/AndroidRuntime(  307):        at
 android.os.Handler.dispatchMessage(Handler.java:99)
 E/AndroidRuntime(  307):        at android.os.Looper.loop(Looper.java:
 123)
 E/AndroidRuntime(  307):        at
 android.app.ActivityThread.main(ActivityThread.java:4627)
 E/AndroidRuntime(  307):        at
 java.lang.reflect.Method.invokeNative(Native Method)
 E/AndroidRuntime(  307):        at
 java.lang.reflect.Method.invoke(Method.java:521)
 E/AndroidRuntime(  307):        at com.android.internal.os.ZygoteInit
 $MethodAndArgsCaller.run(ZygoteInit.java:868)
 E/AndroidRuntime(  307):        at
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
 E/AndroidRuntime(  307):        at
 dalvik.system.NativeStart.main(Native Method)
 E/AndroidRuntime(  307): Caused by:
 java.lang.ExceptionInInitializerError
 E/AndroidRuntime(  307):        at
 clojure.lang.Namespace.init(Namespace.java:34)
 E/AndroidRuntime(  307):        at
 clojure.lang.Namespace.findOrCreate(Namespace.java:173)
 E/AndroidRuntime(  307):        at
 clojure.lang.Var.internPrivate(Var.java:94)
 E/AndroidRuntime(  307):        at tk.clojure.core.clinit(Unknown
 Source)
 E/AndroidRuntime(  307):        ... 15 more
 E/AndroidRuntime(  307): Caused by:
 java.lang.ExceptionInInitializerError
 E/AndroidRuntime(  307):        at java.lang.Class.classForName(Native
 Method)
 E/AndroidRuntime(  307):        at java.lang.Class.forName(Class.java:
 235)
 E/AndroidRuntime(  307):        at
 clojure.lang.RT.loadClassForName(RT.java:1569)
 E/AndroidRuntime(  307):        at clojure.lang.RT.load(RT.java:398)
 E/AndroidRuntime(  307):        at clojure.lang.RT.load(RT.java:380)
 E/AndroidRuntime(  307):        at clojure.lang.RT.doInit(RT.java:415)
 E/AndroidRuntime(  307):        at clojure.lang.RT.clinit(RT.java:
 301)
 E/AndroidRuntime(  

Re: Running Clojure scripts in Maven

2010-05-28 Thread Jason Smith
Yeah, I might still eventually move it over. I decided to keep it
separate for several reasons:

* I need to work out some classloader issues that might affect other
mojos in the same plugin.  Clojure maintains lexical scope for
everything run in the same classloader, and I think this can bleed
between mojos.
* I might want to add a report mojo to the execute mojo, that
would let you more easily generate in-line reports.  Something I've
been thinking about, but I won't touch until I understand the changes
to this feature in Maven 3.
* Putting it into another project means being beholden to that
project's release schedule. I've already integrated and released
several enhancements and a couple of bug fixes, and am on the third
release.  It's nice being able to drop code when it's ready.
* I wanted to write documentation with Maven site docs. The clojure-
maven-plugin doesn't have that at this time (or at least it isn't
apparent that it does). Maven site allows me to have documentation
that lives with each tag and branch, so you can always see the docs
for the version you are using.  This will matter more when Clojure is
10 years old.  :-)
* I still want to experiment with stub generation and integrating
Clojure documentation into Maven site, which is a whole other research
project.

Oh, yeah, and I'm on Windows. So it's kind of painful to work with the
GIT tools. I think the GIT client implementation for Windows needs
another year to become usable.

So yeah, I decided to go down the path less traveled, just because
this isn't anywhere near finished (although I think the *execute* mojo
is looking stable), and it's more cumbersome to work in a larger
project.  When the feature set is solid and stable and I know it won't
interfere with other software, maybe then it's time to move the code.
Besides - this is Maven.  It's just another (plugin) dependency.  Easy
peasey.

I'm hoping that people will find this to be useful, and that people
will be able to find it. :-)  I'm using it.  I like it.

http://programmingperils.blogspot.com
http://code.google.com/p/sandflea/wiki/MavenClojurePlugin

On May 19, 9:46 pm, Mark Derricutt m...@talios.com wrote:
 Ahh is this where your contrib. ended up?  I was waiting for you to post it
 to github or somewhere to merge into the master repo of
 clojure-maven-plugin.

 Would be good to keep things to one mojo imho.

 --
 Pull me down under...





 On Sun, May 16, 2010 at 1:54 PM, Jason Smith ja...@lilypepper.com wrote:

 http://sandflea.googlecode.com/svn/site/SNAPSHOT/maven-clojure-plugin...

  I was originally going to try to put this into *clojure-maven-plugin*,
  but realized that there are lots of subtleties to cover that would be
  difficult as a sub-contributor.  So I have created
  sandflea.clojure:maven-clojure-plugin.  It currently has one goal,
  *execute*, that lets you execute Clojure scripts at any lifecycle
  state in the Maven build, with in-process access to various Maven
  objects (project, session, log, etc.).

  The link above shows an example.  It's fairly simple.  I'll add a few
  more, including adding new artifacts using Clojure, and maybe some ANT
  stuff.

  If you're into Maven, this might interest you.  Still at an early
  stage in development, and I welcome feedback.  This is not going to be
  a replacement for *clojure-maven-plugin*.  I am not planning to add
  any functions that overlap what they are already doing so very well!

  --
  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
  Note that posts from new members are moderated - please be patient with
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com 
  
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

 --
 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
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/clojure?hl=en

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: do clojure and la(tex) have something in common ?

2010-05-28 Thread Dave Pawson
On 28 May 2010 21:15, Perry Trolard trol...@gmail.com wrote:

 Re: a clojure XPath/XQuery library that returns a lazy seq of the
 results, check out my wrapper of Michael Kay's Saxon library:

  http://github.com/pjt/saxon

 Saxon computes XPath results mostly lazily,  I retain this laziness
 in my wrapper. (I say somewhat because Saxon stays one result
 element ahead of realization.)

Thanks Perry.

Which Saxon have you wrapped please?
saxon655 or Saxon9he?

regards

-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


JIT Compilation on Android

2010-05-28 Thread MHOOO
I've got 1.2.0-master running on android froyo with a repl. Froyo
supports JIT compilation, but whenever I call code which is defining a
new class (e.g.: (defn blub [] nil)), I get an Exception:
-
clojure.core= (defn blub [] 1)
java.lang.RuntimeException: java.lang.UnsupportedOperationException:
can't load this type of class file (NO_SOURCE_FILE:15)
clojure.core=
-
And the following error inside the android logs:
-
E/dalvikvm(  522): ERROR: defineClass(0x43e6e188, clojure.core$blub,
0x43f83a58, 0, 984, 0x0)
-
Am I doing something wrong/impossible or is there a way to fix this?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en