Re: Error when tried to compile with C-c C-k in emacs.
I only got it to half work. Using elpa, have done the same as others. Using mvn w/clojure plugin to do "mvn clojure:swank"; changed to use swank 1.2.1. C-c C-k works fine... C-c C-c bombs with Java.lang.exception (No such namespace) like so: Backtrace: 0: swank.commands.basic $eval__1235$compile_string_for_emacs__1237$fn__1239.invoke(basic.clj: 170) 1: swank.commands.basic $eval__1235$compile_string_for_emacs__1237.invoke(basic.clj:166) 2: clojure.lang.Var.invoke(Var.java:375) .. SLIME is 20100404 (thats the version elpa is pushing now); Clojure mode is 1.7.1; swank-clojure is 1.2.1 If I throw a (in-ns) at the top of the file it goes away ex: (in-ns 'user) -- almost like clojure-mode can't figure out what NS its in. Some files I open don't have a (ns) or (in-ns) at the top. Under previous versions of clojure-mode/slime it defaulted to the current ns that the repl happened to be in when you did C-c C-c against areas of a file that that didn't set a ns (for example a clj script). Is there any way to get the previous behavior? On May 18, 3:38 pm, Robbie Vanbrabant wrote: > OK I got it to work, but it was painful. > > - I didn't see a swank-clojure 1.2.1 on GitHub (1.2.0 is listed as the > latest release) > - Decided to follow the Leinigen instructions > onhttp://github.com/technomancy/swank-clojure. It magically found a 1.2.1 > - Also copied the clojure and clojure-contrib jars into lib/ > - lein swank > - use slime-connect and say yes on this: versions differ: nil (slime) vs. > 20100404 (swank) continue? > - works > > For completeness, I started from an emacs-starter-kit installation and then > installed swank-clojure and SLIME using ELPA. Removing swank-clojure with > elpa does not get rid of the warning. Is there another way to get rid of it? > (I also don't get how my SLIME version can be nil). > > Thanks > Robbie > > On Tue, May 18, 2010 at 5:06 AM, Hugo Duncan < > > > > hugodun...@users.sourceforge.net> wrote: > > On Mon, 17 May 2010 10:38:43 -0400, grav wrote: > > > clojure-mode 1.7.1 > >> slime 20100404 > >> slime-repl 20100404 > >> swank-clojure 1.1.0 > > > You'll need swank-clojure 1.2.1 to work with that version of slime. > > > -- > > Hugo Duncan > > > -- > > 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 > > Note that posts from new members are moderated - please be patient with > > your first post. > > To unsubscribe from this group, send email to > > clojure+unsubscr...@googlegroups.com > > For more options, visit this group at > >http://groups.google.com/group/clojure?hl=en > > -- > 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 > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/clojure?hl=en -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: API in Clojure for Java folklore
Hi, any responses? -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: My first clojure program - A swing app to display graphs
Hey Meikel, Thank you for your suggestions! I changed the dereferencing and looked at swing-utils in contrib. It doesn't seem like there's a lot I can use straight, but I did get an idea to write a function add-component-listener, that I can use. Who's in charge of swing-utils? I just thought they might like to add the add-component-listener to the package. Well here it is anyways: http://github.com/pparkkin/clojure.pparkkin/blob/master/pparkkin/graph_view.clj#L116 Paavo On May 10, 6:28 pm, Meikel Brandmeyer wrote: > Hi, > > you don't have to do (into {} @reference). Dereferencing > the reference will give you an immutable thing, which > cannot change underneath your hands. > > You might want to look at clojure.contrib.swing-utils > for little helpers like do-swingor add-action-listener > and such. > > Sincerely > Meikel > > -- > 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 > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/clojure?hl=en -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: reducing multiple sets
1:6 user=> (use '[clojure.set]) nil 1:7 user=> (reduce union #{} #{#{[3 2] [5 4] [3 3] } #{[4 3] [5 4] [3 3] } #{[3 2] [2 2] [3 3] } } ) #{[3 2] [4 3] [5 4] [2 2] [3 3]} 1:8 user=> Thx -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: finding combinations given a coll and selection of n
As Steve said, better look at the combinatorics-api. As for your original code, the idea you have gives all permutations not combinations! Few changes will make it functioning - (defn permutations [n coll] (if (= n 1) (map #(vector %) coll) (for [el coll nlis (permutations (- n 1) (k-filter el coll))] (conj nlis el 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Coercing a map to a record
On 22 May 2010 04:03, Ben Mabey wrote: > How about merging? > > user=> (merge (Bar. {}) m) > #:user.Bar{:x 1, :y 2} > > This approach at least doesn't require that you know in advance the keys of > Bar. No, you still do: user=> (defrecord Foo [x y z]) user.Foo user=> (merge (Foo. {}) m) No matching ctor found for class user.Foo But that's okay; I'm just going to have to use constructor function instead of a raw type. - James -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: defn allows overwriting Protocol function without notification
Sorry for the duplicate messages. -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
defn allows overwriting Protocol function without notification
user=> (defn foo [_] "foo") user=> (defprotocol IFoo (foo [_])) Warning: protocol #'user/IFoo is overwriting function foo IFoo user=> (extend-protocol IFoo nil (foo [_] "IFoo")) nil user=> (foo nil) "IFoo" user=> (foo 1) java.lang.IllegalArgumentException: No implementation of method: :foo of protocol: #'user/IFoo found for class: java.lang.Integer (NO_SOURCE_FILE:0) ; Side note: Is there any way to access the old global "foo" function at this point? user=> (defn foo [_] "foo") ; I'd prefer a warning here #'user/foo user=> (foo nil) "foo" user=> (foo 1) "foo" -- Aaron -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
defn allows overwriting Protocol function without notification
user=> (defn foo [_] "foo") user=> (defprotocol IFoo (foo [_])) Warning: protocol #'user/IFoo is overwriting function foo IFoo user=> (extend-protocol IFoo nil (foo [_] "IFoo")) nil user=> (foo nil) "IFoo" user=> (foo 1) java.lang.IllegalArgumentException: No implementation of method: :foo of protocol: #'user/IFoo found for class: java.lang.Integer (NO_SOURCE_FILE:0) ; Side note: Is there any way to access the old global "foo" function at this point? user=> (defn foo [_] "foo") ; I'd prefer a warning here #'user/foo user=> (foo nil) "foo" user=> (foo 1) "foo" -- Aaron -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Should repeatedly defining the same protocol in a file work?
(I tried to post this to clojure-dev, but don't have permission to post messages there) At a repl the following works: (defprotocol Base (foo [o])) (defprotocol Base) (defprotocol Base (foo [o])) However, a file containing only those three forms, causes the following when loaded: loader (instance of clojure/lang/DynamicClassLoader): attempted duplicate class definition for name: "clojure/test_clojure/protocols/Base" I'm attempting to create a test for issue #353 in Assembla (see http://gist.github.com/410416), so while it may not make sense in general for it to be allowed for protocols to be redefined, it would be convenient for creating a test. It is possible to workaround this by loading two different files with the different definitions for the protocol, but I wanted to check if it was intended. -- Aaron -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Default value for *read-eval*
agree 2010/5/22 Chris Riddoch : > I have a rather small patch I'd like to propose for Clojure: > > *read-eval* should default to false, rather than true. Security > implications? Aside from the 'read' function, are other operations on > strings safe from unintended evaluation? > > -- > Chris Riddoch > > -- > 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 > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: finding combinations given a coll and selection of n
On 22 May 2010, at 20:38, Kasim wrote: > Hi folks, > > I am just asking you guy's input to following: > > (defn- k-filter [el coll] > (filter #(not (= el %)) coll)) > > (defn combinations [n coll] > (if (= n 0) >nil >(for [el coll nlis (combinations (- n 1) (k-filter el coll))] > [el nlis]))) > > It is not working now. Here is an example I want this code to produce: > (combinations 2 '[A B C] -> ([AB],[AC],[BC]). Above code uses > recursion and I would like to see not recursive version. Any one care > to enlighten me? Thanks in advance. Check out the clojure.contrib.combinatorics/combinations function: http://richhickey.github.com/clojure-contrib/combinatorics-api.html#clojure.contrib.combinatorics/combinations -Steve -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
finding combinations given a coll and selection of n
Hi folks, I am just asking you guy's input to following: (defn- k-filter [el coll] (filter #(not (= el %)) coll)) (defn combinations [n coll] (if (= n 0) nil (for [el coll nlis (combinations (- n 1) (k-filter el coll))] [el nlis]))) It is not working now. Here is an example I want this code to produce: (combinations 2 '[A B C] -> ([AB],[AC],[BC]). Above code uses recursion and I would like to see not recursive version. Any one care to enlighten me? Thanks in advance. -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: reducing multiple sets
On May 22, 2010, at 10:00 AM, mikel wrote: > Trying to get from here: > #{#{[3 2] [5 4] [3 3] } #{[4 3] [5 4] [3 3] } #{[3 2] [2 2] [3 3] } } > to here: > #{[3 2] [5 4] [4 3] [2 2] [3 3] } > that is, combining the set of sets into one set. (apply clojure.set/union #{#{[3 2] [5 4] [3 3]} #{[4 3] [5 4] [3 3]} #{[3 2] [2 2] [3 3]}}) -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: reducing multiple sets
'into' is one easy way: (reduce into #{#{[3 2] [5 4] [3 3] } #{[4 3] [5 4] [3 3] } #{[3 2] [2 2] [3 3] } }) => #{[3 2] [4 3] [5 4] [2 2] [3 3]} Stu Hi, from a newbie!! Any help appreciated Trying to get from here: #{#{[3 2] [5 4] [3 3] } #{[4 3] [5 4] [3 3] } #{[3 2] [2 2] [3 3] } } to here: #{[3 2] [5 4] [4 3] [2 2] [3 3] } that is, combining the set of sets into one set. -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
reducing multiple sets
Hi, from a newbie!! Any help appreciated Trying to get from here: #{#{[3 2] [5 4] [3 3] } #{[4 3] [5 4] [3 3] } #{[3 2] [2 2] [3 3] } } to here: #{[3 2] [5 4] [4 3] [2 2] [3 3] } that is, combining the set of sets into one set. -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Default value for *read-eval*
I have a rather small patch I'd like to propose for Clojure: *read-eval* should default to false, rather than true. Security implications? Aside from the 'read' function, are other operations on strings safe from unintended evaluation? -- Chris Riddoch -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Coercing a map to a record
James Reeves wrote: Hi folks, I've been experimenting with the new type system in Clojure 1.2, but I've hit something of a problem. If I define a record: user=> (defrecord Foo []) user.Foo Then I can coerce a map into a type Foo like so: user=> (def m {:x 1, :y 2}) #'/user/m user=> (Foo. {} m) #:user.Foo{:x 1, :y 2} But what if I define an argument in the record constructor? user=> (defrecord Bar [x]) user.Bar I can't use (Bar. {} m); I'd have to use (Bar. (m :x) {} (dissoc m :x)), but this depends on me knowing in advance that x is an argument in Bar's constructor. So is there a programmatic way of telling what keys a record derives from its constructor? Or if there is any other way of coercing a map into an arbitrary record? - James How about merging? user=> (merge (Bar. {}) m) #:user.Bar{:x 1, :y 2} This approach at least doesn't require that you know in advance the keys of Bar. -Ben -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Coercing a map to a record
Good point. I keep falling into the trap of treating types like classes. Types don't have inline constructors, because normal functions perform that task well enough. If I want to coerce a map into a type, I really need just a constructor function, rather than the type itself. In this case, something like: (defn make-bar [m] (Bar. (m :x) {} (dissoc m :x))) - James On 22 May 2010 07:06, Meikel Brandmeyer wrote: > Hi, > > user=> (defrecord Bar [x]) > user.Bar > user=> (into (Bar. nil) {:x 1 :y 2}) > #:user.Bar{:x 1, :y 2} > > One still has to know, that Bar takes an argument, but one could provide > and API function which takes care of that. > > user=> (defrecord Bar [x]) > user.Bar > user=> (defn empty-bar [] (Bar. nil)) > #'user/empty-bar > user=> (into (empty-bar) {:x 1 :y 2}) > #:user.Bar{:x 1, :y 2} > > Sincerely > Meikel > > -- > 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 > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en