Re: toUpperCase on java.lang.String

2008-10-16 Thread Timothy Pratley
Oh wow, powerful syntax! user= (- hello .toUpperCase (.replace H J)) JELLO .. would also work, but I pretty much always prefer - because you can mix in non-methods, and the methods are clearly indicated with a leading dot.  In fact, I could imagine lobbying to have .. removed (while we're

Re: (map f coll) using memfn

2008-10-16 Thread mb
Hi, On 16 Okt., 05:13, Timothy Pratley [EMAIL PROTECTED] wrote: Just a few follow on questions... 1) Is there any way to do away with the input bindings altogether? map doesn't need input bindings, but memfn does. I don't quite grasp why they are needed for memfn, or how to construct an

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: (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

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=

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

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 hello) (toUpperCase))

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

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)) #=java.lang.String

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 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: 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 each

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 this question

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: http://www.scala-lang.org/node/160. Thanks, -- Michel Salim Randall Schulz

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. I

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 the

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 compare the

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 this

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
+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 'compact

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 we

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 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

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,

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 false 4)

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

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 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 and

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) result

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

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 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: 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: 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=

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

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 have

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: 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()); } false