Re: Constructing Java Interop calls

2009-10-28 Thread John Harrop
On Wed, Oct 28, 2009 at 10:15 PM, Alex Osborne wrote: > > Tiago Antão wrote: > > Again, the point here is to be able to construct method names (full > > call signatures, really) on runtime. > > > > I am lost. As in newbie clueless :( > > As others have suggested you need to use either Java's refl

Re: Infinite sequences hang sets and maps

2009-10-28 Thread John Harrop
On Wed, Oct 28, 2009 at 9:35 PM, Alex Osborne wrote: > John Harrop wrote: > > Probably the seq .hashCode should consider only the first N elements > > for some maximum N and if two longer (or even infinite) sequences > > collide so be it. > > I strongly disagree. Choosing some arbitrary magic cu

Re: Java 7, nio, and createFile

2009-10-28 Thread Alex Osborne
youngblood.carl wrote: > When I try and call createFile from clojure: > (.createFile path) > > I get an exception that there is no field named createFile. If I remember correctly variable argument Java methods, which is what that "..." syntax means: abstract Path createFile(FileAttribute...

Re: ANN: Clojure live-repl

2009-10-28 Thread Alex Osborne
David Powell wrote: > >> Under Linux I had to fix the paths in liverepl.sh to include the >> build folder: >> >> java -cp "$LIVEREPL_HOME/build/*:$JDK_HOME/lib/tools.jar" >> net.djpowell.liverepl.client.Main "$CLOJURE_JAR" >> "$LIVEREPL_HOME/build/liverepl-agent.jar" >> "$LIVEREPL_HOME/build/

Re: cannot cast error java char-array to java string

2009-10-28 Thread ataggart
Also you can substitute #^"[C" with the more legible #^chars. On Oct 28, 7:27 pm, Alex Osborne wrote: > Chick Corea wrote: > > What is wrong with this code?  I want to instantiate a Java String > > from a Java character-array. > > But I want it to be fast, hence the need to cast per the "warn o

Re: cannot cast error java char-array to java string

2009-10-28 Thread Alex Osborne
Chick Corea wrote: > What is wrong with this code? I want to instantiate a Java String > from a Java character-array. > But I want it to be fast, hence the need to cast per the "warn on > reflection" message. > > user=> (set! *warn-on-reflection* true) > true > user=> (new String #^

Re: Constructing Java Interop calls

2009-10-28 Thread Alex Osborne
Tiago Antão wrote: > Again, the point here is to be able to construct method names (full > call signatures, really) on runtime. > > I am lost. As in newbie clueless :( As others have suggested you need to use either Java's reflection or Clojure's eval. Here's some examples: Using reflection:

Re: Infinite sequences hang sets and maps

2009-10-28 Thread Alex Osborne
John Harrop wrote: > Probably the seq .hashCode should consider only the first N elements > for some maximum N and if two longer (or even infinite) sequences > collide so be it. I strongly disagree. Choosing some arbitrary magic cutoff point just seems cause for trouble and much confusion. Put

Java 7, nio, and createFile

2009-10-28 Thread youngblood.carl
Howdy all, I'm trying to call the createFile method from the Path class specified here: http://java.sun.com/javase/7/docs/api/java/nio/file/Path.html The following text: The following code snippet creates a file with default attributes: Path file = ...; try { file.createFile(); //Create

Re: Infinite sequences hang sets and maps

2009-10-28 Thread Tim Clemons
On Oct 28, 4:33 pm, Richard Newman wrote: > I think John's point is this: > > user=> (take 3 (repeatedly rand)) > (0.07020342855887218 0.590736243072285 0.04997104958104426) > user=> (take 3 (repeatedly rand)) > (0.6445602419794128 0.12488917903865004 0.5784287452848529) > > Different sequences,

Re: ANN: Clojure live-repl

2009-10-28 Thread David Powell
> Under Linux I had to fix the paths in liverepl.sh to include the build > folder: > > java -cp "$LIVEREPL_HOME/build/*:$JDK_HOME/lib/tools.jar" > net.djpowell.liverepl.client.Main "$CLOJURE_JAR" > "$LIVEREPL_HOME/build/liverepl-agent.jar" > "$LIVEREPL_HOME/build/liverepl-server.jar" "$@" I thi

cannot cast error java char-array to java string

2009-10-28 Thread Chick Corea
What is wrong with this code? I want to instantiate a Java String from a Java character-array. But I want it to be fast, hence the need to cast per the "warn on reflection" message. user=> (set! *warn-on-reflection* true) true user=> (new String #^"[C" (make-array Character/TYPE 3 \

Re: pointfree library

2009-10-28 Thread Paul Barry
Would love to see some examples usages of these On Sun, Oct 25, 2009 at 4:16 PM, harrison clarke wrote: > > so i was using haskell, and the pointfree stuff is fun, so naturally i > had to implement some of it in clojure. > > this is what i have so far. library and examples within: > http://github

bugs in cl-format.clj

2009-10-28 Thread carlitos
Hello, I've encountered a couple of issues with the cl-format function included in contrib.pprint (cl-format nil "~1,1$" -12.0) ;; => "12.0" the sign is lost I think the problem is the following assignment in the dollar-float function add-sign (and (:at params) (not (neg? arg))) ;;

Re: Infinite sequences hang sets and maps

2009-10-28 Thread Richard Newman
> So when the resulting lazy sequence has its hash code requested, it > could return a value similar to the following: > > (+ (.hashCode rand) (* 37 (.hashCode repeatedly))) I think John's point is this: user=> (take 3 (repeatedly rand)) (0.07020342855887218 0.590736243072285 0.04997104958104426

Re: Infinite sequences hang sets and maps

2009-10-28 Thread Tim Clemons
On Oct 28, 1:34 pm, John Harrop wrote: > This runs into problems with things like (repeatedly rand) though. How so? The repeatedly function returns a lazy sequence that (presumably) stores a reference to repeatedly as its generator function. That instance of repeatedly would, in turn, have to

Re: Scientific computing

2009-10-28 Thread harrison clarke
maps could also be an option. you can use vectors of ints as keys. (and you can stick dimensions and such in there with keywords) i'm not sure how that compares to nested vectors for perforance. you have the overhead of the hash function, but you don't have any nesting. it's also pretty handy if

Re: ANN: Clojure live-repl

2009-10-28 Thread ronen
Under Linux I had to fix the paths in liverepl.sh to include the build folder: java -cp "$LIVEREPL_HOME/build/*:$JDK_HOME/lib/tools.jar" net.djpowell.liverepl.client.Main "$CLOJURE_JAR" "$LIVEREPL_HOME/build/ liverepl-agent.jar" "$LIVEREPL_HOME/build/liverepl-server.jar" "$@" --~--~-~--~

Re: Constructing Java Interop calls

2009-10-28 Thread Kevin Downey
you can always just construct the call as a string or as a datastructure and pass it through read/eval On Wed, Oct 28, 2009 at 2:04 PM, Meikel Brandmeyer wrote: > Hi, > > Am 28.10.2009 um 20:46 schrieb Tiago Antão: > >> But my point is to be able to construct the method name in runtime. > > You'

Re: Scientific computing

2009-10-28 Thread Rock
Your analysis is crystal clear and very helpful Konrad. But you haven't addressed the issue of dealing with useful information regarding the data structure itself. What if, for example, a function wanted to know the rank and dimensions of a multidimensional array it was being passed, and that arra

Re: Constructing Java Interop calls

2009-10-28 Thread Meikel Brandmeyer
Hi, Am 28.10.2009 um 20:46 schrieb Tiago Antão: > But my point is to be able to construct the method name in runtime. You'll need reflection for that. AFAIU method calls are wired in the bytecode and hence the method name must be known at compile time. Sincerely Meikel smime.p7s Descriptio

Re: Constructing Java Interop calls

2009-10-28 Thread Michael Wood
2009/10/28 Tiago Antão : [...] > Again, the point here is to be able to construct method names (full > call signatures, really) on runtime. > > I am lost. As in newbie clueless :( I suspect you want reflection, but I don't know off hand how to do it. -- Michael Wood --~--~-~--~~--

Re: feedback on this code

2009-10-28 Thread ataggart
I second Tim's comment regarding holding onto calculated values. That's at best a performance optimization, and likely an unnecessary one. Also, by using the product itself as a key simplifies the case where you try to "add" the same product as multiple line-items (though this may be what you wan

Re: Is it time to move the mailing list off of Google Groups?

2009-10-28 Thread Michael Wood
2009/10/28 Kyle Schaffrick : > > Don't forget those of us who dislike web-forum software and prefer to > interact with the group via email: I very seldom use the GG site itself. > I find threaded email is a *very* good way of following discussions. I > can have a "I didn't know that" moment delive

Re: Infinite sequences hang sets and maps

2009-10-28 Thread John Harrop
On Wed, Oct 28, 2009 at 3:56 PM, Tim Clemons wrote: > How about having hashCode() on infinite sequences drill down into the > composite infinite sequences until we arrive at the generative > function? Given that values are generated on demand, the generators > themselves can be compared. This

Re: Infinite sequences hang sets and maps

2009-10-28 Thread Tim Clemons
How about having hashCode() on infinite sequences drill down into the composite infinite sequences until we arrive at the generative function? Given that values are generated on demand, the generators themselves can be compared. To take from your fibs example: hashCode(iterate f x) = hashCode(x

Re: Constructing Java Interop calls

2009-10-28 Thread Tiago Antão
On Wed, Oct 28, 2009 at 7:34 PM, Wilson MacGyver wrote: > > Is there a reason you don't want to use doto? > > http://clojure.org/java_interop#toc15 > > ie (doto Bla (.setProperty "x" 1)) I really want to do something different: (def x (new StringBuffer "")) (doto x (.setLength 2)) But my p

Re: Infinite sequences hang sets and maps

2009-10-28 Thread John Harrop
On Wed, Oct 28, 2009 at 12:05 PM, Mark Engelberg wrote: > This is basically the behavior I would expect. I expect that when I > put two sequences into a set, they are compared for equality, which is > clearly impossible if they are infinite. I don't think I'd want some > automatically truncated

Re: Constructing Java Interop calls

2009-10-28 Thread John Harrop
2009/10/28 Tiago Antão > > Hi, > > Sorry for the newbie question, but I am trying to understand how to > construct and call java dynamically from clojure. > As an example, imagine that there is a bean property called "Bla" and > one wants to set Bla to 1 on object x, which has that property. > So

Re: Constructing Java Interop calls

2009-10-28 Thread Wilson MacGyver
Is there a reason you don't want to use doto? http://clojure.org/java_interop#toc15 ie (doto Bla (.setProperty "x" 1)) 2009/10/28 Tiago Antão : > > Hi, > > Sorry for the newbie question, but I am trying to understand how to > construct and call java dynamically from clojure. > As an example, im

Constructing Java Interop calls

2009-10-28 Thread Tiago Antão
Hi, Sorry for the newbie question, but I am trying to understand how to construct and call java dynamically from clojure. As an example, imagine that there is a bean property called "Bla" and one wants to set Bla to 1 on object x, which has that property. So, the objective would be to construct,

Re: Scientific computing

2009-10-28 Thread Konrad Hinsen
On 27.10.2009, at 18:07, Rock wrote: > these things. Why? Because they're just that: nested vectors. They're > not truly multidimensional vectors, and the more I think about them, > the more they really suck from that point of view. For instance, first > of all they're not that safe to use (for t

Re: Is it time to move the mailing list off of Google Groups?

2009-10-28 Thread Kyle Schaffrick
Don't forget those of us who dislike web-forum software and prefer to interact with the group via email: I very seldom use the GG site itself. I find threaded email is a *very* good way of following discussions. I can have a "I didn't know that" moment delivered to my inbox every day, without havi

Re: Is it time to move the mailing list off of Google Groups?

2009-10-28 Thread offwhite
I think John made some very good points in that blog post. I am running a Google Group and I am finding for smaller groups it is possible to give a few people moderator rights so that any new members are able to get their posts in at a reasonable time. Still, the points that John raises are valid

Re: Embedding Clojure in NetKernel

2009-10-28 Thread Tony Butterfield
Tom Hicks has just pointed me to an old thread which answers questions about namespaces and isolation. Let me read and absorb all that work first - I suspect it answers a lot of my questions. Cheers, Tony On Oct 28, 11:43 am, Tony Butterfield wrote: > Hi Everybody > > this is my first post to t

Re: Infinite sequences hang sets and maps

2009-10-28 Thread Wilson MacGyver
agreed, I'm not sure how meaningful it would be to compare two infinite "things". On Wed, Oct 28, 2009 at 12:05 PM, Mark Engelberg wrote: > > This is basically the behavior I would expect.  I expect that when I > put two sequences into a set, they are compared for equality, which is > clearly im

Re: Infinite sequences hang sets and maps

2009-10-28 Thread Mark Engelberg
This is basically the behavior I would expect. I expect that when I put two sequences into a set, they are compared for equality, which is clearly impossible if they are infinite. I don't think I'd want some automatically truncated comparison. If I really wanted truncated comparison, there are

Embedding Clojure in NetKernel

2009-10-28 Thread Tony Butterfield
Hi Everybody this is my first post to this group so please tell me If I'm posting in the wrong place. I've been looking at integrating Clojure into NetKernel as language runtime library but I'm struggling a bit for a lack of examples. There are two things I'm trying to achieve: 1) start and stop

Infinite sequences hang sets and maps

2009-10-28 Thread John Harrop
and it's not hard to guess, and then prove, why: user=> (defn fibs [] (map first (iterate (fn [[a b]] [b (+ a b)]) [1 1]))) #'user/fibs user=> (take 10 (fibs)) (1 1 2 3 5 8 13 21 34 55) user=> (.hashCode 12) 12 user=> (.hashCode "foo") 101574 user=> (.hashCode (take 10 (fibs))) -1796812414 user=>

Re: PATCH: AFn.java, RestFN.java (a better throwArity message)

2009-10-28 Thread Meikel Brandmeyer
Hi, On Oct 28, 7:56 am, John Harrop wrote: > That was correct. I just wanted to avoid any confusion between the #() read > macro and anonymous functions; the read macro is one way of writing an > anonymous function but it is not the only way so the two aren't quite > interchangeable. #() is in

Re: take-nth

2009-10-28 Thread John Harrop
On Wed, Oct 28, 2009 at 4:20 AM, Timothy Pratley wrote: > On Oct 28, 6:04 pm, John Harrop wrote: > > It always starts with the zeroth item and skips ahead however many > elements > > were specified. The second argument is the n in > > "every nth item". (You can think of it as the index of the SEC

Re: take-nth

2009-10-28 Thread Timothy Pratley
On Oct 28, 6:04 pm, John Harrop wrote: > It always starts with the zeroth item and skips ahead however many elements > were specified. The second argument is the n in > "every nth item". (You can think of it as the index of the SECOND item to > take, so (take-nth 3 foo) takes index 0 of foo, then

Re: take-nth

2009-10-28 Thread John Harrop
On Tue, Oct 27, 2009 at 9:50 PM, Josh Daghlian wrote: > The docs could use clarification, but it looks like take-nth is doing > what's advertised. > I don't see anything odd about the behavior of take-nth in regards to indexing: user=> (take 10 (take-nth 1 (range 100))) (0 1 2 3 4 5 6 7 8 9) us