Re: doseq vs. map

2009-04-03 Thread Eric Tschetter
Thanks for the response everyone!  I was able to get it working.  If I understand what everyone is saying, the following statement is true: In Clojure, laziness is the rule not the exception. Rather than that, I'd say that you are thinking about map wrong (hope that doesn't come across as

Keeping a ref and a DB in sync

2009-04-03 Thread Brian Carper
Is there a safe way to keep the data in a Clojure ref and the data in a table in an external (e.g. mysql) database in sync, given concurrent creates/updates/deletes from within Clojure? I can't do a DB update from within a dosync because of retries. If I send-off an agent for the DB update from

Re: Keeping a ref and a DB in sync

2009-04-03 Thread Adrian Cuthbertson
Perhaps you could do the db update as an agent action and then the ref update within the agent action if it is successful - see http://groups.google.co.za/group/clojure/browse_thread/thread/d645d77a8b51f01/667e833c1ea381d7 Regards, Adrian. On Fri, Apr 3, 2009 at 11:02 AM, Brian Carper

suitability of Clojure for implementing new languages?

2009-04-03 Thread alex
I'm currently working on a research project which involves the implementation of several new programming languages in a variety of paradigms. Our current work in being done in PLT Scheme. However, we have several other requirements which suggest that Clojure might be a better choice: support for

Re: doseq vs. map

2009-04-03 Thread André Ferreira
Laziness is the rule only on sequence operations. On Apr 2, 11:34 pm, Sean francoisdev...@gmail.com wrote: Thanks for the response everyone!  I was able to get it working.  If I understand what everyone is saying, the following statement is true: In Clojure, laziness is the rule not the

Re: Array of primitives

2009-04-03 Thread Albert Cardona
Sean wrote: I'm working with AWT, and there is a method that requires a float[] (The java.awt.BasicStroke constructor). Is it possible to directly create an array of primitives directly in Clojure, or do I need to create a utility class in Java? See: (doc make-array) (doc into-array)

patch: bit-count function

2009-04-03 Thread Alec Berryman
The Clojure bit functions do not currently provide a way to query the count of set bits in a number. Attached is a small patch to implement this feature. I've found it useful for implementing an immutable bit array in Clojure. I sent my CA in earlier this week.

Re: Ironicly Maven2 is the lightest I could come up with

2009-04-03 Thread Jason Warner
I'd be interested in seeing the ivy+ant solution. We use maven2 at work and there are obvious pros and cons. With clojure, part of the pain is initial setup and config. Maven2/ant+ivy might really help that. Post when you get a chance...am very interested. Thanks, jason On Apr 2, 8:56 pm,

Re: Java interoperability and Clojure

2009-04-03 Thread Geoff Wozniak
Thanks for the links, Stuart, although I managed to figure out what I was doing wrong: I didn't realize that the Java vararg type Object... mapped to a sequence in Clojure, so I wasn't properly calling 'invoke' in java.lang.reflect.Method. Again, thanks for the links. I'm sure they'll be helpful

Re: Keeping a ref and a DB in sync

2009-04-03 Thread MikeM
In case you haven't seen this thread: http://groups.google.com/group/clojure/browse_frm/thread/aa22a709501a64ac/79b1c858c6d50497?lnk=gstq=transaction+database#79b1c858c6d50497 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: Array of primitives

2009-04-03 Thread Meikel Brandmeyer
Hi, Am 03.04.2009 um 06:04 schrieb Sean: I'm working with AWT, and there is a method that requires a float[] (The java.awt.BasicStroke constructor). Is it possible to directly create an array of primitives directly in Clojure, or do I need to create a utility class in Java? find-doc might

Every function is a thread in Clojure?

2009-04-03 Thread BerlinBrown
Someone correct me if I go wrong here. But, from my understanding, every defined function in Clojure is an implementation of a thread? What is the goal in implementing in this fashion? For example, if I am writing in imperative style: (println First line) (println Second line) (println Third

Re: Ironicly Maven2 is the lightest I could come up with

2009-04-03 Thread Berlin Brown
On Apr 3, 8:18 am, Jason Warner jasoncwar...@gmail.com wrote: I'd be interested in seeing the ivy+ant solution. We use maven2 at work and there are obvious pros and cons. With clojure, part of the pain is initial setup and config. Maven2/ant+ivy might really help that. Post when you get a

Re: Every function is a thread in Clojure?

2009-04-03 Thread Paul Stadig
The operations will happen synchronously. Clojure will not add threading to your code without you asking it to, but when you want to add threading there are lots of great tools built-in to make it Easy On You (TM). Paul On Fri, Apr 3, 2009 at 9:36 AM, BerlinBrown berlin.br...@gmail.com wrote:

Re: Every function is a thread in Clojure?

2009-04-03 Thread Laurent PETIT
Implementing Runnable does not mean they will be called via an intermediate thread. I remember having seen it's there for efficiency reasons when one wants to provide a function in lieu of where the java method expects a Runnable : so clojure does not have to wrap the function call with another

Re: Every function is a thread in Clojure?

2009-04-03 Thread Stephen C. Gilardi
On Apr 3, 2009, at 9:36 AM, BerlinBrown wrote: Someone correct me if I go wrong here. But, from my understanding, every defined function in Clojure is an implementation of a thread? The example you gave would all happen on one thread. Perhaps what you're thinking of is that every Clojure

Re: Ironicly Maven2 is the lightest I could come up with

2009-04-03 Thread Laurent PETIT
2009/4/3 Berlin Brown berlin.br...@gmail.com I cringe and throw up a little inside everytime I hear maven. It's so easy to bash something ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post

Re: Keeping a ref and a DB in sync

2009-04-03 Thread Paul Stadig
I'll just throw this out there. It may not be exactly what you're looking for, but you could use a Terracotta cluster. Terracotta will persist the cluster to disk. If you have an existing database that you are working with, then this may not help, but if you are starting from scratch you may not

Re: Every function is a thread in Clojure?

2009-04-03 Thread Stuart Halloway
No threads: (ancestors (class (fn[]))) - #{java.lang.Runnable java.io.Serializable clojure.lang.AFn clojure.lang.Obj java.lang.Object clojure.lang.Fn clojure.lang.AFunction clojure.lang.IObj clojure.lang.IFn java.util.concurrent.Callable clojure.lang.IMeta java.util.Comparator} What you

proposed new contrib: java-utils

2009-04-03 Thread Stuart Halloway
Hi all, I would like to pull together functions that help with Java interop and place them in a new contrib: java-utils. Some examples: (1) Pull out SteveG's properties fn, currently hidden in the internals of clojure.contrib.sql (2) reflective helpers for accessing private and protected

Re: How do you print to standard output without using *out*?

2009-04-03 Thread Daniel Jomphe
Since I can't find the way to solve this issue, let's tackle it at a more fundamental level. First, I need to make sure I can print to standard output without using *out*, so I can later, temporarily bind *out* to something else. Also, I don't want to print directly to System/out. Later, I'll

Re: How do you print to standard output without using *out*?

2009-04-03 Thread Kyle Schaffrick
On Fri, 3 Apr 2009 07:20:39 -0700 (PDT) Daniel Jomphe danieljom...@gmail.com wrote: Since I can't find the way to solve this issue, let's tackle it at a more fundamental level. First, I need to make sure I can print to standard output without using *out*, so I can later, temporarily bind

Possible bug in proxy: NPE for unqualified class

2009-04-03 Thread Paul Drummond
The following works - note ActionListener is fully qualified: - user= (.addActionListener (javax.swing.JButton.) (proxy [java.awt.event.ActionListener] [] (actionPerformed [evt] (println button press nil

Re: How do you print to standard output without using *out*?

2009-04-03 Thread Daniel Jomphe
Oh, somehow, auto-flushing doesn't work, and that's why I wasn't seeing anything else than nil: user= (def w (PrintWriter. (PrintStream. System/out) true)) #'user/w user= (.print w bonjour) nil user= (.flush w) bonjournil So although I asked for auto-flushing, I need to do so

Re: How do you print to standard output without using *out*?

2009-04-03 Thread Daniel Jomphe
Kyle Schaffrick wrote: Could you just make a new Var (like *always-stdout* or something) and assign *out* to it at program start? This way the dynamic bindings on *out* don't affect your new Var and you can continue using it to access the real stdout. As long as I'm willing to lose the

Re: proposed new contrib: java-utils

2009-04-03 Thread Stephen C. Gilardi
On Apr 3, 2009, at 10:17 AM, Stuart Halloway wrote: If this is interesting to others (or at least inoffensive) I will move forward with it. I'm in favor. I'd also like to get your latest thinking on your suggestions from some time ago about clojure.contrib.lazy-seqs. If they can be

Static blocks via gen-class

2009-04-03 Thread Greg Harman
Does anybody know if there's a way to coerce gen-class into creating a static block in the generated class? thanks, Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: doseq vs. map

2009-04-03 Thread wlr
On Apr 3, 3:29 am, Eric Tschetter eched...@gmail.com wrote: That is, map is more geared towards type conversion of the elements in a collection, but it is only converting the elements in the collection, not the collection itself. (some ellided text here...) Reduce (also known as fold left)

Saving repl functions

2009-04-03 Thread Joshua Fox
When I have been experimenting on the REPL, I sometimes want to save my work. Is there a way of serializing an image of the REPL into Clojure sourcecode? Joshua --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: How do you handle different string encodings?

2009-04-03 Thread Daniel Jomphe
Now that I know for sure how to bind *out* to something else over System/out, it's time to bring back my encoding issues into scope: (import '(java.io PrintWriter PrintStream)) (defmacro with-out-encoded [encoding body] `(binding [*out* (java.io.PrintWriter. (java.io.PrintStream.

Re: How do you handle different string encodings?

2009-04-03 Thread Paul Stadig
Works For Me (TM). user= (def s québécois français) #'user/s user= (print s) québécois françaisnil Are you running on Windows, Mac, or Linux? Using the Sun JVM? Which revision of Clojure? p...@pstadig-laptop:~$ lsb_release -a No LSB modules are available. Distributor ID:Ubuntu Description:

Re: How do you handle different string encodings?

2009-04-03 Thread Daniel Jomphe
Sorry for all these posts. I pasted my last post's code into a fresh repl (not in my IDE), and here's what I got (cleaned up): #'user/s québécois françaisnil qu?b?cois fran?aisnil #'user/snc québécois françaisnil qu?b?cois fran?aisnil I'm not sure what to make out of it. My

Re: speed question

2009-04-03 Thread rzeze...@gmail.com
Could Clojure have something similar to CL's 'defconstant'? http://gigamonkeys.com/book/variables.html On Apr 2, 4:09 pm, Bradbev brad.beveri...@gmail.com wrote: It seems to me that the real solution is that the Clojure compiler needs to support global constants.  You could probably emulate

Re: How do you handle different string encodings?

2009-04-03 Thread Daniel Jomphe
I'm running on Mac. In IDE (IntelliJ): Java: Apple's 1.6 Clojure: LaClojure's version (I don't know) In Terminal: Java: Apple's 1.5.0_16 Clojure: 1338, 2009-04-01 Paul Stadig wrote: Works For Me (TM). user= (def s québécois français) #'user/s user= (print s) québécois françaisnil Are

Re: proposed new contrib: java-utils

2009-04-03 Thread Kyle Schaffrick
On Fri, 3 Apr 2009 10:17:33 -0400 Stuart Halloway stuart.hallo...@gmail.com wrote: Hi all, I would like to pull together functions that help with Java interop and place them in a new contrib: java-utils. Some examples: [...] If this is interesting to others (or at least

Re: How do you handle different string encodings?

2009-04-03 Thread Daniel Jomphe
I tried under eclipse. Default console encoding configuration (MacRoman): #'user/s quÔøΩbÔøΩcois franÔøΩaisnil qu?b?cois fran?aisnil #'user/snc qu?b?cois fran?aisnil qu?b?cois fran?aisnil Console configured to print using ISO-8859-1: #'user/s qu�b�cois fran�aisnil

Re: speed question

2009-04-03 Thread Raffael Cavallaro
this one is nice too: (defn draw-line [#^Graphics g y] (let [dy (- 1.25 (* y height-factor))] (doseq [x (range 0 width)] (let [dx (- (* x width-factor) 2.0)] (let [value (check-bounds dx dy) scaled (Math/round (* value color-scale))

Re: Full Clojure, Right Now! (tm)

2009-04-03 Thread Phil Hagelberg
Daniel Jomphe danieljom...@gmail.com writes: -- Emacs -- No more works since I've pulled emacs-starter-kit's latest changes. 'M- x slime' doesn't fire up clojure anymore; slime no more exists, in fact. The last commit actually removed clojure-mode.el. Maybe they're in the middle of

Re: doseq vs. map

2009-04-03 Thread Phil Hagelberg
Sean francoisdev...@gmail.com writes: And now everything works great. What I don't understand is why the doseq macro is required instead of the mapping operation. Could somebody explain why Clojure has this different form for functions that have side effects? My take on this is that map

Re: Keeping a ref and a DB in sync

2009-04-03 Thread rzeze...@gmail.com
Brian, I imagine you are asking this in relation to your blog engine? I came up with solution, that is, if you don't mind writing the persistent data fresh every time. http://paste.lisp.org/display/77987 Basically, I added a watch to the *comment* ref, which set the *db* ref to the new state

Re: How do you handle different string encodings?

2009-04-03 Thread Daniel Jomphe
I made some progress. [By the way, NetBean's console displays *everything* 100% fine. I decided to use one of the worst repl consoles: that of IntelliJ. I want to make sure I really understand what's the point behind all this.] (import '(java.io PrintWriter PrintStream FileInputStream)

Re: Possible bug in proxy: NPE for unqualified class

2009-04-03 Thread Rich Hickey
On Apr 3, 10:33 am, Paul Drummond paul.drumm...@iode.co.uk wrote: The following works - note ActionListener is fully qualified: - user= (.addActionListener (javax.swing.JButton.) (proxy [java.awt.event.ActionListener] [] (actionPerformed [evt]

Re: Ironicly Maven2 is the lightest I could come up with

2009-04-03 Thread Korny Sietsma
Sorry, missed the crucial point :) The maven *repository* I have no problems with! Even Maven itself, in appropriate environments. I just think the set of appropriate is much smaller than Maven fans seem to think it is! - Korny On Fri, Apr 3, 2009 at 2:48 PM, dysinger dysin...@gmail.com

Re: A clojure server

2009-04-03 Thread christ...@mvonessen.de
On Apr 1, 6:21 pm, christ...@mvonessen.de wrote: What nailgun has (beside the way cooler name) is the ability to map *err* to stderr and *out* to stdout, which are just merged into one datastream in my code. OTOH, my code is written in Clojure, so it wins by default :P This is done as of

The Game Loop ... the Clojure way?

2009-04-03 Thread Curran Kelleher
Hi all, I'm trying to get started with an OpenGL (JOGL) application in Clojure, and one of the first orders of business is establishing a thread that repeatedly calls the display function - the game loop. I'm not sure what the idiomatic way to do this in Clojure is. The below code works, but is

A syntax feature request: splitting literal strings

2009-04-03 Thread samppi
I wish I could do this: (code... Long error string that doesn't fit within 80 characters but is descriptive, \ which is good, right? ...more code...) (The string above would say, Long error string that doesn't fit within 80 characters but is descriptive, which is good, right?)

Re: A syntax feature request: splitting literal strings

2009-04-03 Thread William D. Lipe
This is how java strings work (including their workaround involving StringBuilder objects), so I guess it's no worse than that. But I tried adding it, and it seems like this can be implemented by adding a single case statement to LispReader.java with no other problems. Something like case '\n':

Re: The Game Loop ... the Clojure way?

2009-04-03 Thread Eric Tschetter
The only thing I might change is the way you are incrementing the counter: (defn counter-animation [running counter] (when running (send-off *agent* counter-animation (+ counter 1))) (println counter) (. Thread sleep 500) running) (defn start-animation [] (send animator (fn [x]