Re: Array of primitives

2009-04-02 Thread David Nolen
you should look into float-array and friends. On Fri, Apr 3, 2009 at 12:04 AM, 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 ne

Array of primitives

2009-04-02 Thread 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? --~--~-~--~~~---~--~~ You recei

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

2009-04-02 Thread dysinger
Maven2 is atrocious for big Java projects. Lots of people have had the same experience you mentioned. In fact the first few lines of the readme on my clojure pom project on github says "Dont run away with your hair on fire" :) Give it a try. It is really simple. I think I'll give Ant + Ivy anoth

Re: Fresh Clojure Tutorial

2009-04-02 Thread e
On Tue, Mar 31, 2009 at 8:17 PM, Laurent PETIT wrote: > Yes, you're certainly right, but I'm only 35 old, and I don't want to yet > let my dreams behind me, given that I will certainly (I hope so!) play at > least 35 more years in this industry :-) > > I was thinking about an approach that would l

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

2009-04-02 Thread dysinger
I said that the java world has rallied around maven _repos_. Ivy uses maven repos. So your 200 developers _have_ in fact embraced maven repos like most people. It is the only package repository game in town. :) I think Ant + Ivy is a very nice solution for Java. If there was a DRY way to adapt i

Re: Java interoperability and Clojure

2009-04-02 Thread Stuart Halloway
Hi Geoff, You should have no trouble using setAccessible. There are several demos of this in the source code for the book [1] that use setAccessible to check private fields in a unit test. (See lancet/test/ step-2-complete.clj [2], for instance). Hope this helps, Stu [1] http://github.com

Re: doseq vs. map

2009-04-02 Thread Sean
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. On Apr 2, 10:29 pm, Matt Revelle wrote: > Were you in #clojure earlier?  This came up there and pjsta

Re: doseq vs. map

2009-04-02 Thread Matt Revelle
Were you in #clojure earlier? This came up there and pjstadig and I raced to implement "domap" and then slashus2 pointed out there was no need for it to be a macro. http://gist.github.com/89249 (defn domap "A map for side-effects. The argument order is the same as map, but unlike map the fun

Re: Java interoperability and Clojure

2009-04-02 Thread Rayne
As far as I know, there is no limit. On Apr 2, 11:22 am, Geoff Wozniak wrote: > What are the limitations of Clojure and Java interoperability? Are > they clearly stated somewhere? > > I have been experimenting with using Clojure to test some existing > Java code (being able to do so makes a conv

Re: doseq vs. map

2009-04-02 Thread Daniel Jomphe
Daniel Jomphe wrote: > Basically, since your map wasn't needed, it wasn't "realized"/ > executed. Laziness. Better said: Basically, since your map's results weren't used, it wasn't "realized"/ evaluated. That's why you didn't see your expected side effects. Laziness. --~--~-~--~~

Re: speed question

2009-04-02 Thread Dmitri
yeah I definitely agree that it would be nice if constants could be used without the parens. On Apr 2, 11:48 am, Paul Stadig wrote: > Yeah that works the same as defining a function, just more explicit. I was > looking for a way to define a constant and just use it as "my-const" without > having

Re: doseq vs. map

2009-04-02 Thread Daniel Jomphe
>From map's docstring: "Returns a lazy sequence [...]" So I guess you applied map at the top level and wondered why side- effects didn't happen. Try: (dorun (map #(form-with-side-effects %) a-list)) Or, for fun: (take 1 (map #(form-with-side-effects %)) Basically, since your map wasn't n

Re: speed question

2009-04-02 Thread Dmitri
nifty :) On Apr 2, 5:10 pm, Raffael Cavallaro wrote: > If you change the color constructor you can get some nice color > effects: > > (. setColor (let [scaled (Math/round (* value color-scale))] >                      (Color.   255 (- 255 scaled) scaled))) > > will give you yellow and magenta fo

doseq vs. map

2009-04-02 Thread Sean
Hi everyone, I'm working with awt to do create an image renderer. This is obviously an application where side effects are desired. My first attempt was this: (map #(form-with-side-effects %) a-list) This didn't do what I expected. After a little while, I found the doseq macro. I re-wrote my

How do you parse xml files with different encodings?

2009-04-02 Thread Daniel Jomphe
Let's say I have this file to parse: Québécois français I spent many hours trying different ways of doing it, but still haven't found one. Here are probably my best attempts: (def n "ISO-8859-1") (defmacro with-out-encoded [encoding & body] `(binding [*out* (java.io.OutputStreamWr

Lisp web book proposal for O'Reilly

2009-04-02 Thread Vladimir Sedach
Hi, At ILC 2009, O'Reilly Media released a statement that they were soliciting proposals for books about Lisp. This is a reversal of their previous policy that explicitly stated that they were not interested in publishing Lisp books. I'm planning to put together a proposal for a book about web de

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

2009-04-02 Thread Korny Sietsma
On Fri, Apr 3, 2009 at 4:39 AM, dysinger wrote: > The Java world for good or bad has rallied > around maven repos. There are 10s of thousands of libs "up in there". While there are lots of Java / Maven users, there are also a lot who *don't* use it, and indeed many who actively avoid stuff tha

Re: Clojure + Terracotta Update

2009-04-02 Thread Jeffrey Straszheim
You're doing amazing work! I look forward to the result. On Thu, Apr 2, 2009 at 5:37 PM, Paul Stadig wrote: > I've been speaking with the Terracotta engineers, so here is an update on a > couple of the issues: > > 1) array.clone(). It turns out this is a bug in Terracotta. They have > acknowled

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

2009-04-02 Thread dysinger
It's not hard to add a pom.xml to a project that is not maven enabled. I did it for clojure and clojure-contrib in 2 minutes total. If it's a git project you can just include them in as a submodule (or ftree in hg or svn externals in svn) and setup up multi- module builds. Clojure "Ties" would

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

2009-04-02 Thread Laurent PETIT
Hello, 2009/4/2 Jason Sankey > > Laurent PETIT wrote: > > Hi, > > > > 2009/4/2 Jason Sankey mailto:ja...@zutubi.com>> > > > > Ivy [ ... ] also supports pluggable resolvers, so > > you can host your Jars/dependency information in multiple ways. > > > > > > Does that mean one could write r

Re: Clojure + Terracotta Update

2009-04-02 Thread Paul Stadig
I've been speaking with the Terracotta engineers, so here is an update on a couple of the issues: 1) array.clone(). It turns out this is a bug in Terracotta. They have acknowledged it, and will be working to resolve it. However, they mentioned (as I have found else where on the interweb[1][2]) tha

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

2009-04-02 Thread Jason Sankey
Laurent PETIT wrote: > Hi, > > 2009/4/2 Jason Sankey mailto:ja...@zutubi.com>> > > Ivy [ ... ] also supports pluggable resolvers, so > you can host your Jars/dependency information in multiple ways. > > > Does that mean one could write resolvers to automagically get libraries > from "

Re: speed question

2009-04-02 Thread Raffael Cavallaro
If you change the color constructor you can get some nice color effects: (. setColor (let [scaled (Math/round (* value color-scale))] (Color. 255 (- 255 scaled) scaled))) will give you yellow and magenta for example --~--~-~--~~~---~--~~ You

Re: speed question

2009-04-02 Thread Bradbev
It seems to me that the real solution is that the Clojure compiler needs to support global constants. You could probably emulate the behaviour by rebinding global vars inside the let though. (def *foo* 100) (defn bar [] (let [foo *foo*] ...)) Brad On Apr 2, 7:57 am, Paul Stadig wrote: > I

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

2009-04-02 Thread Laurent PETIT
Hi, 2009/4/2 Jason Sankey > Ivy [ ... ] also supports pluggable resolvers, so > you can host your Jars/dependency information in multiple ways. > Does that mean one could write resolvers to automagically get libraries from "source" repositories such as github, bitbucket, ... (as long as a minim

Java interoperability and Clojure

2009-04-02 Thread Geoff Wozniak
What are the limitations of Clojure and Java interoperability? Are they clearly stated somewhere? I have been experimenting with using Clojure to test some existing Java code (being able to do so makes a convincing argument to use it where I work) and I've noticed that there doesn't seem to be an

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

2009-04-02 Thread dysinger
Embracing Maven may sound like madness for a dynamic language when you are trying to break free from Static Languages Land. There _ARE_ compelling arguments for using simple maven pom files though. 1 - You get access to repository managers like http://archiva.apache.org/ 2 - You get access to a

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

2009-04-02 Thread Jason Sankey
Paul Stadig wrote: > This works great for Java libraries, but only libraries that are in a > maven repo. How hard is it to get code into a repo? What about java > libraries not in a maven repo, or clojure code like clojure-json on GitHub? I don't think it is terribly hard to get in the repo, bu

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

2009-04-02 Thread dysinger
Comments below mixed in... On Apr 2, 3:35 am, Paul Stadig wrote: > This works great for Java libraries, but only libraries that are in a maven > repo. How hard is it to get code into a repo? What about java libraries not > in a maven repo, or clojure code like clojure-json on GitHub? > You can

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

2009-04-02 Thread dysinger
This approach won't get you very far IMHO working on lots of projects. At some point you will have conflicts on which library version you need. On Apr 1, 8:29 pm, mikel wrote: > On Apr 2, 12:27 am, dysinger wrote: > > > > > Dogh!  Plz pardon my spelling. :D (embarrassed) > > > On Apr 1, 7:25 p

Re: test-is now supports TAP

2009-04-02 Thread Jason Sankey
Stuart Sierra wrote: > On Apr 1, 12:21 pm, Jason Sankey wrote: >> Out of interest, are you interested in other output formats for test-is? >> I chose JUnit compatible as a defacto-standard -- it integrates with >> the unofficial build server I have been working on as well as many other >> tools

Re: Questions about Clojure and Common Lisp

2009-04-02 Thread David Nolen
On Apr 1, 11:41 am, Chanwoo Yoo wrote: > Hello. Yesterday, I talked with a representative of a publisher about > a translation of Lisp books. There are books about Ruby, Lua, Erlang, > and Groovy in South Korea, but there is no book about Lisp except > SICP. So he is considering printing the fi

Re: speed question

2009-04-02 Thread Paul Stadig
Yeah that works the same as defining a function, just more explicit. I was looking for a way to define a constant and just use it as "my-const" without having to use the parens to call a function or a macro. I guess that would be something like a symbol macro in CL? Paul On Thu, Apr 2, 2009 at 1

Re: speed question

2009-04-02 Thread MikeM
There is definline which seems appropriate in place of the constant macros. (definline my-const [] 1) (my-const) ;= 1 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema

Re: speed question

2009-04-02 Thread Paul Stadig
I think you are right, Brad. However, I wonder though if there is a better way to define a constant. Neither the macro nor function seems clean. I like David's wrapping-the-whole-thing-in-a-let, but what if you wanted to access the value of "width" in a different file? Would one have to resort to

Re: speed question

2009-04-02 Thread Bradbev
It would seem that macros in this case should not be required. A normal function that simply returns a constant should get inlined by the JIT. Cheers, Brad On Apr 2, 5:20 am, Dmitri wrote: > Thanks a lot, that's really helpful. I never thought of using a macro > to define constants > like that

Re: Full Clojure, Right Now! (tm)

2009-04-02 Thread Ilya Sergey
Oh, yes. It actually replaces dashes. Never mind. :) Ilya 2009/4/2 Daniel Jomphe > > Oh, that's it. I think I fiddled with this last week. :\ > > So now, I've got these working: > > eclipse, intellij > > -- NetBeans -- > enclojure still complains contrib isn't on the classpath, whatever I > do

Re: Full Clojure, Right Now! (tm)

2009-04-02 Thread Ilya Sergey
Daniel, How have you added clojure-contrib.jar to your module? The most common way to do this is to create global/project/module library, attaching this jat to it and adding this library to module dependencies. If it doesn't help, could you provide little example to reproduce it? I guess, this is

Re: Full Clojure, Right Now! (tm)

2009-04-02 Thread Daniel Jomphe
Oh, that's it. I think I fiddled with this last week. :\ So now, I've got these working: eclipse, intellij -- NetBeans -- enclojure still complains contrib isn't on the classpath, whatever I do. -- Emacs -- No more works since I've pulled emacs-starter-kit's latest changes. 'M- x slime' does

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

2009-04-02 Thread Paul Stadig
This works great for Java libraries, but only libraries that are in a maven repo. How hard is it to get code into a repo? What about java libraries not in a maven repo, or clojure code like clojure-json on GitHub? 1. You could set up your own repo. Ok. Cool, but not the easiest to setup and mainta

Re: Full Clojure, Right Now! (tm)

2009-04-02 Thread Laurent PETIT
in order to be compatible with package and java class names, your clojure files must not have the - , so clojure automatically replaces them with underscores _ when searching for a file / folder / package fragment. But inside clojure itself, when you reference the namespace by its symbol/name, you

Re: Full Clojure, Right Now! (tm)

2009-04-02 Thread Daniel Jomphe
Thanks to everybody for their (sometimes highly detailed) answers. -- ECLIPSE -- It's nice that contrib is indeed bundled in clojuredev. Core clojure works, but I get the following: (ns myns (:use clojure.contrib.duck_streams)) ==> [...].Exception: namespace 'clojure.contrib.duck_stre

Re: Print a Large Lazy Seq - Heap Error

2009-04-02 Thread fitzpatrick...@googlemail.com
That did it! I just used the functions that created my-row-data in place of my-row-data. Thanks very much for the help. PJ On Apr 2, 1:34 pm, Laurent PETIT wrote: > Difficult without seeing the code. > > the idea is to try not storing what is currently in my-row-data anywhere. > > So if you can

Re: Print a Large Lazy Seq - Heap Error

2009-04-02 Thread Laurent PETIT
Difficult without seeing the code. the idea is to try not storing what is currently in my-row-data anywhere. So if you can create a function that returns what is currently stored in my-row-data, and pass that function to your function t, then the head of your sequence will not be retained in any

Re: Print a Large Lazy Seq - Heap Error

2009-04-02 Thread fitzpatrick...@googlemail.com
Apologies for my ignorance ,i am new to clojure, but can you give an example of what the code should look like. I understand my-row-data is lexical as it defined outside the function but i don't understand how to implement this new function. tks, PJ On Apr 2, 1:03 pm, Laurent PETIT wrote: > You'

Re: speed question

2009-04-02 Thread Dmitri
Thanks a lot, that's really helpful. I never thought of using a macro to define constants like that, it's definitely a good trick and it does seem to result in the biggest performance gain. On Apr 2, 7:25 am, Paul Stadig wrote: > I got it down to about 3 seconds. I did what William said, but the

Re: speed question

2009-04-02 Thread David Sletten
On Apr 2, 2009, at 2:05 AM, MikeM wrote: > > Starting with your version, I got about a 2x improvement with the > following: > > (defn check-bounds [x y] >(let [f2 (float 2.0) > f4 (float 4.0)] >(loop [px (float x) > py (float y) > zx (float 0.0) > z

Re: speed question

2009-04-02 Thread Dmitri
like Paul said earlier changing the globals to macros makes seems to make a huge impact. and the check-bounds and draw-line get called for each line on the screen so it makes sense that optimizations there will make a big impact. On Apr 2, 8:05 am, MikeM wrote: > Starting with your version, I go

Re: speed question

2009-04-02 Thread MikeM
Starting with your version, I got about a 2x improvement with the following: (defn check-bounds [x y] (let [f2 (float 2.0) f4 (float 4.0)] (loop [px (float x) py (float y) zx (float 0.0) zy (float 0.0) zx2 (float 0.0) zy2 (float 0.0

Re: Print a Large Lazy Seq - Heap Error

2009-04-02 Thread Laurent PETIT
You're holding the head, because my-row-data is defined in the lexical or dynamic scope of the function, and holds the head. Try creating a function returning the seq that is currently stored in my-row-data and call it instead : (my-row-data) -- Laurent 2009/4/2 fitzpatrick...@googlemail.com

Re: speed question

2009-04-02 Thread Dmitri
thanks a lot, that's really helpful. On Apr 2, 7:25 am, Paul Stadig wrote: > I got it down to about 3 seconds. I did what William said, but the biggest > improvement was from changing the way *width*, *height*, and *max-steps* > were defined. I noticed that in the Java version they are constants

Re: Print a Large Lazy Seq - Heap Error

2009-04-02 Thread fitzpatrick...@googlemail.com
Hi, Thanks for the replies. I have adapted the code above with my example. I still get the heap error! my-row-data is the lazy sequence. each element in the seq is a 2 element vector of Java String[] output-array is just a printing function for the String[]. For convenience i place a @ between th

Re: Full Clojure, Right Now! (tm)

2009-04-02 Thread e
i didn't know about this one. thanks On Thu, Apr 2, 2009 at 4:51 AM, Rayne wrote: > La Clojure --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegr

Re: speed question

2009-04-02 Thread Paul Stadig
I got it down to about 3 seconds. I did what William said, but the biggest improvement was from changing the way *width*, *height*, and *max-steps* were defined. I noticed that in the Java version they are constants, but in the Clojure version they are Vars which means that inside your tight inner

Re: Print a Large Lazy Seq - Heap Error

2009-04-02 Thread Christian Vest Hansen
On Thu, Apr 2, 2009 at 11:58 AM, fitzpatrick...@googlemail.com wrote: > > Hi, > I am attempting to print a large lazy seq to file. I have attempted > various approaches and obviously am missing something obvious. > I have attempted do use do-seq and also iterated manually through the > sequence b

Re: Print a Large Lazy Seq - Heap Error

2009-04-02 Thread Laurent PETIT
e.g. the following code works very well for me (so I had to stop it before the file size became > to 1 Gbyte :-) : ;; file test.clj (ns test) (defn infinite [] (repeat "a line")) (defn t [] (with-open [w (java.io.FileWriter. (java.io.File. "/tmp/test"))] (doseq [l (infinite)]

Re: Print a Large Lazy Seq - Heap Error

2009-04-02 Thread Laurent PETIT
Can you post the code that poses problem ? 2009/4/2 fitzpatrick...@googlemail.com > > Hi, > I am attempting to print a large lazy seq to file. I have attempted > various approaches and obviously am missing something obvious. > I have attempted do use do-seq and also iterated manually through the

Print a Large Lazy Seq - Heap Error

2009-04-02 Thread fitzpatrick...@googlemail.com
Hi, I am attempting to print a large lazy seq to file. I have attempted various approaches and obviously am missing something obvious. I have attempted do use do-seq and also iterated manually through the sequence but i always come up with the heap error. Has anyone got any suggestions? tks, PJ --

Re: Find the function you need

2009-04-02 Thread Rayne
I already have this function. It's called channel #Clojure on freenode :p. All I got to do is wave my magic wand at hiredman and CLABANGO!. On Apr 1, 8:17 pm, Mitch wrote: > While still learning clojure, I often times need a function and am not > sure if it already exists or where to look for it

Re: I feel I'm making an elementary mistake with proxy, but I don't know what...

2009-04-02 Thread Christian Vest Hansen
On Thu, Apr 2, 2009 at 2:33 AM, Luke VanderHart wrote: > > Ugh, I hate it when I make a fool of myself and realize the answer to > a question 1 minute after posting it, even when wrestling with it for > an hour beforehand... > > The reason the example doesn't work is that the method is of a > dif

Re: Full Clojure, Right Now! (tm)

2009-04-02 Thread Rayne
Every one of those IDE's work with adding stuff like Clojure-contrib to the classpath. In La Clojure, it's as simple as going to File -> Project Structure -> Libraries -> Attach Classes and finding the correct directory of Clojure-contrib. In Enclojure, it's as simple as right clicking Libraries i

Re: basic question on structuring refs

2009-04-02 Thread Laurent PETIT
Referring to http://clojure.org/refs : Rule 1. states that all your reads will be consistent as of the starting point of the transaction Rule 2. states that no changes will have been made by any other transactions to any Refs that have been *ref-set**/altered**/ensured* by this transaction. So by

Re: basic question on structuring refs

2009-04-02 Thread Korny Sietsma
Hmm - I'm unclear. I had the impression that if thread a *reads* ref "world" and thread b *alters* ref "world" that would cause one of them to retry... is that wrong? It probably doesn't matter to my code, but it'd be good to know. - Korny On Thu, Apr 2, 2009 at 6:11 PM, Laurent PETIT wrote: >

Re: Full Clojure, Right Now! (tm)

2009-04-02 Thread Laurent PETIT
Hi, 2009/4/1 Daniel Jomphe > > Would you fellow clojurians have wise advice for me? While I await > your answers, I'm going to try eclipse. I think I've read Laurent > Petit, the other day, saying his eclipse plugin automatically handles > classpaths. > Indeed, with clojuredev, initializing a n

Re: basic question on structuring refs

2009-04-02 Thread Laurent PETIT
Hello, 2009/4/2 Korny Sietsma > > If I understand correctly, two threads calling do_something_to with > different keys won't collide, as they read @world but don't change it. I'll > get a collision if one thread changes @world and another changes an > individual structure - but I guess that's n