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
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
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,
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
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=
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
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))
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
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
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
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
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
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
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
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
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
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
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
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
+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
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
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
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
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,
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)
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
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
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
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
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
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
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)
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
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=
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
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
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
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
38 matches
Mail list logo