Re: recur question

2008-10-16 Thread michael frericks
Hi all, thanks a lot for clarifying. Regards, Michael Frericks --~--~-~--~~~---~--~~ 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 To unsubscribe from this

Re: Ruby => Clojure for Enumerable and Array

2008-10-16 Thread mb
Hi, On 17 Okt., 00:14, Mark McGranaghan <[EMAIL PROTECTED]> wrote: > When I first started working with Clojure a while back I tried to get > my bearings by figuring out how to do some basic things in Clojure > that I had previously done in Ruby.  With all the recent talk about > the seq api, I th

Re: Casting java arguments...

2008-10-16 Thread Stephen C. Gilardi
On Oct 16, 2008, at 11:18 PM, Luc Prefontaine wrote: > Looking at classForName in the RT.java module (in trunk, checked out > a few days ago): > > static public Class classForName(String name) throws > ClassNotFoundException{ > > return Class.forName(name, false, baseLoader()); > } >

Re: Casting java arguments...

2008-10-16 Thread Luc Prefontaine
Yep, Class/forName does the job. I like the consistency of the JVM implementations (glup !), I run on Ubuntu wih: java version "1.6.0_03" Java(TM) SE Runtime Environment (build 1.6.0_03-b05) Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode) I do have the mysql jar file in my classpath

Re: Clojure's first year

2008-10-16 Thread Parth Malwankar
On Oct 16, 9:36 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: > A year ago today I 'released' Clojure, by sending a message to my jFli > and Foil mailing lists. It got blogged, picked up by Planet Lisp and > redditted in the course of a day or so, and has been a wild ride ever > since. I couldn't h

Re: Ruby => Clojure for Enumerable and Array

2008-10-16 Thread Parth Malwankar
On Oct 17, 3:14 am, Mark McGranaghan <[EMAIL PROTECTED]> wrote: > When I first started working with Clojure a while back I tried to get > my bearings by figuring out how to do some basic things in Clojure > that I had previously done in Ruby.  With all the recent talk about > the seq api, I thou

Re: Casting java arguments...

2008-10-16 Thread Achim Passen
Hi, Am 17.10.2008 um 03:12 schrieb Luc Prefontaine: > This means that (clojure.lang.RT/classForName > "com.mysql.jdbc.Driver") has no effect on the static code in the > class. You're right, RT/classForName doesn't do initialization. Does this work for you?: (Class/forName "com.mysql.jdbc

Exposing ancestral protected fields with gen-class

2008-10-16 Thread Matt Revelle
The previously attached patch didn't make find-field private, sorry about that. genclass_find-field.patch Description: Binary data

Re: Casting java arguments...

2008-10-16 Thread Stephen C. Gilardi
On Oct 16, 2008, at 9:12 PM, Luc Prefontaine wrote: > Ouf ! I'm not insane, (at least regarding this bug :))) > This means that (clojure.lang.RT/classForName > "com.mysql.jdbc.Driver") has no effect on the static code in the > class. > This is done in the sql contrib library but it has no e

Exposing ancestral protected fields with gen-class

2008-10-16 Thread Matt Revelle
The gen-class function supports generation of getter/setter functions for protected fields of the super class, but as currently implemented it does not support exposing protected fields declared further up the class hierarchy. The attached patch adds a private find-field function to genclass

Re: Casting java arguments...

2008-10-16 Thread .Bill Smith
I see the same problem trying to connect using the mysql driver. I wonder if it might be a classloader issue. Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: max

2008-10-16 Thread Martin DeMello
On Oct 16, 1:45 pm, Stuart Halloway <[EMAIL PROTECTED]> wrote: > Just to add to the confusion: I want compact to remove nil and   > false. :-) They'll revoke your ruby license :) irb(main):031:0> [1,2,3,4,false,nil,5,6].compact => [1, 2, 3, 4, false, 5, 6] martin --~--~-~--~~---

Re: Casting java arguments...

2008-10-16 Thread Luc Prefontaine
Ouf ! I'm not insane, (at least regarding this bug :))) I just realized that when I explicitly register the driver, there are now two instances begin added: Clojure user=> (println (enumeration-seq (. java.sql.DriverManager getDrivers))) ([EMAIL PROTECTED]) ;; No instance registered nil user=> (c

Re: Non Local Exits

2008-10-16 Thread Rich Hickey
On Oct 16, 10:16 am, "Matthew D. Swank" <[EMAIL PROTECTED]> wrote: > So, I'm trying to clear up some flow control issues in my head, and I > want to confirm that my thinking is at least in the right direction. > > Let's say I implement a very simple restart facility with the > following style: >

Re: splat operator

2008-10-16 Thread Timothy Pratley
Maybe something along these lines? (defn myreplace [str [a b]] (.replace str a b)) (myreplace target search-replace) -> "heo world" I can see how it would be nice to 'splice in' from a variable like the [EMAIL PROTECTED] splicing from within a macro --~--~-~--~~~---

Re: Clojure's first year

2008-10-16 Thread Mark H.
Congrats Rich and HBD Clojure! I'm getting back into Clojure for scripting and am loving it. The sequence functions work great on strings and are fabulous for simple text manipulation without invoking the heavy hammer of the regex engine. It's a nice puzzle to make my brain work that way again

Ruby => Clojure for Enumerable and Array

2008-10-16 Thread Mark McGranaghan
When I first started working with Clojure a while back I tried to get my bearings by figuring out how to do some basic things in Clojure that I had previously done in Ruby. With all the recent talk about the seq api, I thought I'd clean up my notes on Ruby => Clojure for the Enumerable and Array

Re: Style question

2008-10-16 Thread Meikel Brandmeyer
Hi, Am 16.10.2008 um 23:36 schrieb Tom Emerson: I'd like to solicit comments on better ways I could have written it: (defn- split-line [line] (let [parts (seq (.split line ":"))] (loop [mills (drop 1 parts) result (list (first parts))] (if (nil? mills) (reverse result)

Re: Style question

2008-10-16 Thread Tom Emerson
Meikel, Many thanks: I *knew* there had to be a more succinct way to do it... think I need to stare at the Clojure API documentation a bit more. :) Kind regards, -tree On Thu, Oct 16, 2008 at 5:48 PM, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote: > Hi, > > Am 16.10.2008 um 23:36 schrieb Tom

Re: Style question

2008-10-16 Thread Rich Hickey
On Oct 16, 5:36 pm, "Tom Emerson" <[EMAIL PROTECTED]> wrote: > Hello all, > > I wrote a function that behaves as: > > user> (split-line "785:3:39334:1:43103") > ("785" ("3" "39334") ("1" "43103")) > > I'd like to solicit comments on better ways I could have written it: > > (defn- split-line >

max-key/min-key ... while we're on the subject

2008-10-16 Thread Paul Stadig
While were on the subject, wouldn't it make sense to rename max-key to max-fn or something? I gather that it is called max-key because you can pass a keyword as a way to index into a map, but since keywords implement IFn and in this case they are actually being used as a function, and you can actua

Style question

2008-10-16 Thread Tom Emerson
Hello all, I wrote a function that behaves as: user> (split-line "785:3:39334:1:43103") ("785" ("3" "39334") ("1" "43103")) I'd like to solicit comments on better ways I could have written it: (defn- split-line [line] (let [parts (seq (.split line ":"))] (loop [mills (drop 1 parts)

Re: max

2008-10-16 Thread Paul Stadig
Thanks, Rich. That's easier on the eyes. Also, that set trick is pretty cool! Paul On Thu, Oct 16, 2008 at 5:20 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > I've been meaning to add remove for a while. It's certainly more > general than compact, and (filter (complement ...)) gets cumbersome >

Re: max

2008-10-16 Thread Rich Hickey
On Oct 16, 4:57 pm, "Paul Stadig" <[EMAIL PROTECTED]> wrote: > More options: I was browsing through the docs and I couldn't find a function > that is the "opposite" of filter, which would allow something like: > > (remove nil? coll) > > Or alternatively if we had not-nil? > > (filter not-nil? co

Re: clojure.zip/goto proposal

2008-10-16 Thread Meikel Brandmeyer
Hi, Am 16.10.2008 um 20:20 schrieb Chouser: actually want to use in navigation, "filename" or whatever. Perhaps you could simply pass in a filter function to your original goto, to allow partial application-specific comparisons. I had a look in clojure.contrib.zip-filter.xml. I think it works

Re: max

2008-10-16 Thread Brian Doyle
The complement would work in terms of "opposite" of filter like: (filter (complement nil?) [1 2 nil]) -> (1 2) but I like remove since it is a bit more clear and less typing. On Thu, Oct 16, 2008 at 2:57 PM, Paul Stadig <[EMAIL PROTECTED]> wrote: > More options: I was browsing through the docs

Re: max

2008-10-16 Thread Paul Stadig
More options: I was browsing through the docs and I couldn't find a function that is the "opposite" of filter, which would allow something like: (remove nil? coll) Or alternatively if we had not-nil? (filter not-nil? coll) Are either of those more palatable? In regards to compact removing fals

Re: max

2008-10-16 Thread Stuart Halloway
Just to add to the confusion: I want compact to remove nil and false. :-) > Perhaps another nudge for compact is that it's not as simple as > (filter identity coll), to wit: > > user> (filter identity [1 2 nil false 4]) > (1 2 4) > > user> (filter #(not (nil? %)) [1 2 nil false 4]) > (1 2 fal

Re: max

2008-10-16 Thread Paul Stadig
Perhaps another nudge for compact is that it's not as simple as (filter identity coll), to wit: user> (filter identity [1 2 nil false 4]) (1 2 4) user> (filter #(not (nil? %)) [1 2 nil false 4]) (1 2 false 4) So unless you want to catch false in your net you really need to be doing the latter, w

Re: max

2008-10-16 Thread Stuart Halloway
I am going to vote twice on this one. +2 for adding compact to Clojure. :-) (1) This idiom will occur everywhere. It certainly does in the other languages I use. (2) Clojure needs compact *more* than these other languages, if functions like max are going to fall out with NPE. I like the id

Re: max

2008-10-16 Thread Paul Stadig
It's maybe more a matter of taste, but we have funtions like frest, rfirst, etc. We have dotimes. We have not=, not-any?, not-every?, etc. Even defn is a convenience macro that isn't strictly necessary. I think that (maybe) people will come to Clojure expecting the "standard" list processing funct

Re: max

2008-10-16 Thread Chouser
On Thu, Oct 16, 2008 at 3:26 PM, Paul Stadig <[EMAIL PROTECTED]> wrote: > > Something like (filter #(identity %) coll) works, but would it be possible > to add a 'squeeze or 'compact function so we could do something like (apply > max (compact coll))? I like how few functions clojure has built in

Re: max

2008-10-16 Thread Stephen C. Gilardi
On Oct 16, 2008, at 3:26 PM, Paul Stadig wrote: > OK. Then next question. > > Is there some reason we don't have a "remove the nils" function in > the 'clojure namespace? > > Something like (filter #(identity %) coll) works, but would it be > possible to add a 'squeeze or 'compact function so

Re: max

2008-10-16 Thread Stuart Halloway
+1. And I like compact as a name (my Ruby is showing). Stuart > OK. Then next question. > > Is there some reason we don't have a "remove the nils" function in > the 'clojure namespace? > > Something like (filter #(identity %) coll) works, but would it be > possible to add a 'squeeze or 'comp

Re: max

2008-10-16 Thread Paul Stadig
OK. Then next question. Is there some reason we don't have a "remove the nils" function in the 'clojure namespace? Something like (filter #(identity %) coll) works, but would it be possible to add a 'squeeze or 'compact function so we could do something like (apply max (compact coll))? Paul On

Re: max

2008-10-16 Thread Stuart Halloway
Hi Paul, I think the current behavior is reasonable. It is consistent across all the numeric functions. And if the nil got into max by being a sentinel value from some other function, I don't think there is a right way to interpret it. Stuart > Currently, "(max 1 2 nil 4)" throws a NPE. W

max

2008-10-16 Thread Paul Stadig
Currently, "(max 1 2 nil 4)" throws a NPE. Would it be reasonable to expect it to return "4"? Or is it right that it throws an NPE? Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: clojure.zip/goto proposal

2008-10-16 Thread Chouser
On Thu, Oct 16, 2008 at 2:10 PM, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote: > > So I need some external way of navigation. Maybe one can also > provide a function how to compare nodes. ad-hoc trees like > [1 [2 3] [[[4 5] 6] 7 8]] then only have identical? as a predicate, > which does not compar

Re: clojure.zip/goto proposal

2008-10-16 Thread Meikel Brandmeyer
Hello, Am 16.10.2008 um 16:56 schrieb Chouser: >> I'd like to propose a clojure.zip/goto function. It is basically >> the inverse of the clojure.zip/path function, ie. it takes a >> location and a path and walks through the zipper to the given >> node and returns its loc. Wouldn't each step of

Fiji release: Fiji is Just ImageJ (with Clojure)

2008-10-16 Thread Albert Cardona
Dear all, We are releasing today Fiji: Fiji is Just ImageJ, batteries included -- that means. among other things, Clojure. [Quite unknowingly that today was Clojure 1st release anniversary: congratulations! We are loving it.] http://pacific.mpi-cbg.de Fiji is an ImageJ distribution that bundle

Re: Clojure's first year

2008-10-16 Thread Shawn Hoover
On Thu, Oct 16, 2008 at 9:36 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > A year ago today I 'released' Clojure, by sending a message to my jFli > and Foil mailing lists. It got blogged, picked up by Planet Lisp and > redditted in the course of a day or so, and has been a wild ride ever > since.

Clojure's first year

2008-10-16 Thread Rich Hickey
A year ago today I 'released' Clojure, by sending a message to my jFli and Foil mailing lists. It got blogged, picked up by Planet Lisp and redditted in the course of a day or so, and has been a wild ride ever since. I couldn't have possibly imagined the year Clojure (and I) have had. Community

Re: is clojure known to work on any phones with javame?

2008-10-16 Thread Randall R Schulz
On Wednesday 15 October 2008 09:23, Michel Salim wrote: > A related question would be: does it work on Android? And a related answer is that some Scala folks have gotten its bytecodes to work on Android: . > Thanks, > > -- > Michel Salim Randall Schulz --

Re: Can't use Java class in default package. Bug?

2008-10-16 Thread Jim Menard
On Thu, Oct 16, 2008 at 10:54 AM, Randall R Schulz <[EMAIL PROTECTED]> wrote: > > On Thursday 16 October 2008 07:22, Jim Menard wrote: >> On Thu, Oct 16, 2008 at 9:59 AM, Rich Hickey <[EMAIL PROTECTED]> > wrote: >> > Clojure doesn't support classes not in packages. >> >> Why not? Please don't take

Re: clojure.zip/goto proposal

2008-10-16 Thread Chouser
On Thu, Oct 16, 2008 at 10:42 AM, mb <[EMAIL PROTECTED]> wrote: > > I'd like to propose a clojure.zip/goto function. It is basically > the inverse of the clojure.zip/path function, ie. it takes a > location and a path and walks through the zipper to the > given node and returns its loc. Wouldn't

Re: Can't use Java class in default package. Bug?

2008-10-16 Thread Randall R Schulz
On Thursday 16 October 2008 07:22, Jim Menard wrote: > On Thu, Oct 16, 2008 at 9:59 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > Clojure doesn't support classes not in packages. > > Why not? Please don't take this question as a criticism. I'd really > like to know the reasoning. Was the choice

clojure.zip/goto proposal

2008-10-16 Thread mb
Dear Clojurians, I'd like to propose a clojure.zip/goto function. It is basically the inverse of the clojure.zip/path function, ie. it takes a location and a path and walks through the zipper to the given node and returns its loc. (defn goto "Follow along the path from the given loc. In case t

Re: Can't use Java class in default package. Bug?

2008-10-16 Thread Rich Hickey
On Oct 16, 9:40 am, "Jim Menard" <[EMAIL PROTECTED]> wrote: > I tried using a class in the default package, but kept seeing > > (new Foo) > java.lang.IllegalArgumentException: Unable to resolve classname: Foo > ... > > As soon as I put Foo into a package, everything worked fine. > > (new

Re: Can macros be used for blunt token-pasting?

2008-10-16 Thread Allen Rohner
> > I've wanted to do this type of thing before (with CL) and generally > try to avoid it, so I'll share my reason: the declaration does not > appear in source code.   I completely agree with you. That being said, clojure does have a very useful, underrated feature that makes this kind of problem

Re: (map f coll) using memfn

2008-10-16 Thread Timothy Pratley
Slam dunk Rich! Yes I can see that is much better. Thanks for taking the time to understand what I was trying to do instead of what I thought I was trying to do :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clo

interpose enhancement

2008-10-16 Thread MikeM
I'd like to offer the following version of interpose as a replacement for the current interpose in boot.clj. It's been useful for me and I think it may be for others. (defn intpose "(intpose n sep coll) Returns a lazy seq of the elements of coll separated by sep, with sep inserted after every

Re: Can't use Java class in default package. Bug?

2008-10-16 Thread Jim Menard
On Thu, Oct 16, 2008 at 9:59 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > Clojure doesn't support classes not in packages. Why not? Please don't take this question as a criticism. I'd really like to know the reasoning. Was the choice technical or philosophical? Jim -- Jim Menard, [EMAIL PROTE

Non Local Exits

2008-10-16 Thread Matthew D. Swank
So, I'm trying to clear up some flow control issues in my head, and I want to confirm that my thinking is at least in the right direction. Let's say I implement a very simple restart facility with the following style: (def current-handler) (def current-restart nil) In some code I want to handle

Re: toUpperCase on java.lang.String

2008-10-16 Thread Parth Malwankar
On Oct 16, 4:29 pm, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Oct 15, 11:47 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote: > > > > > Hi Parth, > > > > But if I do this in a doto, it doesn't seem to work but > > > I don't get any error message. > > > > user=> (doto (new java.lang.String "h

Can't use Java class in default package. Bug?

2008-10-16 Thread Jim Menard
I tried using a class in the default package, but kept seeing (new Foo) java.lang.IllegalArgumentException: Unable to resolve classname: Foo ... As soon as I put Foo into a package, everything worked fine. (new bar.Foo) [EMAIL PROTECTED] Is this a bug? Jim -- Jim Menard, [EMAIL PRO

Re: toUpperCase on java.lang.String

2008-10-16 Thread Stephen C. Gilardi
On Oct 16, 2008, at 7:29 AM, Rich Hickey wrote: > Another semantic marker here is 'do'. do in Clojure implies side- > effects. Since you can't uppercase a string by side effect, doto isn't > the right tool for this job. Neat. I explored the "do..." marker a little with Clojure: - user

Re: Help writing this Lazy Sequence Macro

2008-10-16 Thread Rich Hickey
On Oct 16, 1:18 am, CuppoJava <[EMAIL PROTECTED]> wrote: > Thanks again Rich. > > Another question about agents. I understand that the actions are > executed automatically by the thread pool. Is there any manual way to > schedule the actions to agents, in case I need some manual control? Hmm..

Re: (map f coll) using memfn

2008-10-16 Thread Rich Hickey
On Oct 15, 11:13 pm, Timothy Pratley <[EMAIL PROTECTED]> wrote: > Thanks so much for all the replies, that showed the way to what I > wanted (simplified example using substring): > > (defn lazy-self [me] > ((fn rfib [a] (lazy-cons a (rfib a))) me)) > (defmacro map-obj [jobj jmeth argbinds & co

Re: (map f coll) using memfn

2008-10-16 Thread Timothy Pratley
Neat tip. Applying that, this is what I've come up with: (defn jcall [obj name & args] (clojure.lang.Reflector/invokeInstanceMethod obj (str name) (if args (to-array args) clojure.lang.RT/EMPTY_ARRAY))) (defn map-obj [jobj jmeth coll & colls] (apply map #(apply jcall jobj jmeth %&) coll c

Re: toUpperCase on java.lang.String

2008-10-16 Thread Rich Hickey
On Oct 15, 11:47 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote: > Hi Parth, > > > But if I do this in a doto, it doesn't seem to work but > > I don't get any error message. > > > user=> (doto (new java.lang.String "hello") (toUpperCase)) > > "hello" > > user=> (class (new java.lang.String))

Re: toUpperCase on java.lang.String

2008-10-16 Thread Timothy Pratley
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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options,

Re: Calling static methods on a variable holding a class

2008-10-16 Thread mb
Hi, On 16 Okt., 09:14, "V.Quixote" <[EMAIL PROTECTED]> wrote: > So after (def OpenGL GL11): > > user=> (.GL_QUADS GL11) > 7 > user=> (.GL_QUADS OpenGL) > java.lang.IllegalArgumentException: No matching field found: GL_QUADS > for class clojure.lang.Symbol (NO_SOURCE_FILE:0) > > Using (def OpenGL

Calling static methods on a variable holding a class

2008-10-16 Thread V.Quixote
So after (def OpenGL GL11): user=> (.GL_QUADS GL11) 7 user=> (.GL_QUADS OpenGL) java.lang.IllegalArgumentException: No matching field found: GL_QUADS for class clojure.lang.Symbol (NO_SOURCE_FILE:0) Using (def OpenGL 'GL11) doesn't work either, and using (defmacro OpenGL [] 'GL11) means I have t

Re: toUpperCase on java.lang.String

2008-10-16 Thread mb
Hi, On 16 Okt., 08:17, Timothy Pratley <[EMAIL PROTECTED]> wrote: > What does 'mix in non-methods' means? I read the (doc ->) but I really > don't follow that explination. -> is more general than .. . .. only works on objects. (.. foo (bar baz) (frob nicate)) is equivalent to (. (. foo ba