Re: How to construct Set

2010-08-10 Thread Mark Engelberg
BTW, when you're done, it would be great if you could post a report about your experience using JGraphT from Clojure. I've been thinking a lot lately about what an ideal graph library would look like in pure Clojure, and it would be interesting to hear how easy/hard it already is to use an existin

Re: How to construct Set

2010-08-10 Thread Nikita Beloglazov
> > If the JGraphT constructor takes say 2 args arg1 and arg2, you'll just > write > (let [graph (JGraphT. arg1 arg2)] ) and every side will be happy: > clojure, and java. > And when you need to add vertex or edge you create it and add. If you need to get edge (e.g. getEdge(...) method) you ju

Re: How to construct Set

2010-08-10 Thread Meikel Brandmeyer
Hi, Am 10.08.2010 um 23:22 schrieb Tim Daly: > This code uses the JGraphT graphing package which > wants to create a graph where the types of the > vertices and edges are generics, as in: > > JGraphT graph = > > and I'm at a loss for how to instantiate a graph in clojure. Just leave away

Re: How to construct Set

2010-08-10 Thread Laurent PETIT
2010/8/10 Tim Daly > This code uses the JGraphT graphing package which > wants to create a graph where the types of the > vertices and edges are generics, as in: > > JGraphT graph = > > and I'm at a loss for how to instantiate a graph in clojure. Tim, Generics in java are there only for ma

Re: How to construct Set

2010-08-10 Thread Alan
Depends on what you mean by that. If you mean, create a hashset for use in clojure that will only accept MyType objects, I'll defer to someone here who knows more clojure than I do, though it looks like metadata preconditions are the way to go. If you mean, create a hashset you can pass to Java ob

Re: How to construct Set

2010-08-10 Thread Tim Daly
This code uses the JGraphT graphing package which wants to create a graph where the types of the vertices and edges are generics, as in: JGraphT graph = and I'm at a loss for how to instantiate a graph in clojure. Armando Blancas wrote: If you must use Java's HashSet, you can use it untyp

Re: How to construct Set

2010-08-10 Thread Tim Daly
All of the code I'm trying to convert uses generics everywhere. I don't know how to construct a generic in clojure. Is there a syntax for it? For instance, I have a graph of nodes of type Chart. They are stored in the graph where the nodes are kept as: Set nodes = Can I construct a type hint ^S

Re: How to construct Set

2010-08-10 Thread Armando Blancas
If you must use Java's HashSet, you can use it untyped: user=> (deftype MyType []) user.MyType user=> (def my-set (HashSet.)) #'user/my-set user=> (.add my-set (MyType.)) true user=> (.add my-set (java.util.Date.)) true If you need to enforce the use of a type, use a checked set: user=> (def che

Re: How to construct Set

2010-08-10 Thread Nikita Beloglazov
Hi, Tim Can you describe you task? Sets (and other collections) in clojure don't use generics, as I know. You can add element to set and check if set contains element. Why do you need MyType? To allow add only MyType elements in set? On Tue, Aug 10, 2010 at 11:40 PM, Tim Daly wrote: > I have jav

Re: How to construct Set

2010-08-10 Thread Tim Daly
I have java code that reads: Set s = new HashSet(); I don't know how to write the parameter in clojure where MyType is a Java class. Laurent PETIT wrote: 2010/8/10 Tim Daly > How do I construct Set s = new HashSet(); in clojure? Can you be more

Re: How to construct Set

2010-08-10 Thread Laurent PETIT
2010/8/10 Tim Daly > How do I construct > Set s = new HashSet(); > in clojure? > Can you be more precise about the context of what you're trying to achieve ? 'cause the naive answer to your question is (def s #{}) or (let [s #{}] ...) but I think you have a usecase in mind I'm not clearling

How to construct Set

2010-08-10 Thread Tim Daly
How do I construct Set s = new HashSet(); in clojure? -- 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 po