Re: Error when tried to compile with C-c C-k in emacs.

2010-05-22 Thread Chris McClellen
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$com

Re: API in Clojure for Java folklore

2010-05-22 Thread ka
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,

Re: My first clojure program - A swing app to display graphs

2010-05-22 Thread enjoying the view
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 th

Re: reducing multiple sets

2010-05-22 Thread ka
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 g

Re: finding combinations given a coll and selection of n

2010-05-22 Thread ka
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

Re: Coercing a map to a record

2010-05-22 Thread James Reeves
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 match

Re: defn allows overwriting Protocol function without notification

2010-05-22 Thread Aaron Cohen
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 fr

defn allows overwriting Protocol function without notification

2010-05-22 Thread Aaron Cohen
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 metho

defn allows overwriting Protocol function without notification

2010-05-22 Thread Aaron Cohen
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 meth

Should repeatedly defining the same protocol in a file work?

2010-05-22 Thread Aaron Cohen
(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 (ins

Re: Default value for *read-eval*

2010-05-22 Thread Joop Kiefte
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 Riddo

Re: finding combinations given a coll and selection of n

2010-05-22 Thread Steve Purcell
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))] >

finding combinations given a coll and selection of n

2010-05-22 Thread Kasim
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

Re: reducing multiple sets

2010-05-22 Thread Michael Gardner
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]

Re: reducing multiple sets

2010-05-22 Thread Stuart Halloway
'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

reducing multiple sets

2010-05-22 Thread mikel
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

Default value for *read-eval*

2010-05-22 Thread 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

Re: Coercing a map to a record

2010-05-22 Thread Ben Mabey
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

Re: Coercing a map to a record

2010-05-22 Thread James Reeves
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, someth