Re: How to add a new type of collection?

2012-01-28 Thread Joachim De Beule
Well, I also do not want to re-invent the wheel. Some of these libraries are really optimized for both memory and speed (yes, I will need both) and already provide a great deal of useful functionality that I would otherwise have to implement myself. I just want to make sure I am doing it right

Re: How to add a new type of collection?

2012-01-27 Thread Walter van der Laan
Are you somehow required to use the Java library? Otherwise you could also use a Clojure map as a sparse matrix. This will be much easier to implement. Walter -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: How to add a new type of collection?

2012-01-27 Thread Ben Mabey
On 1/27/12 9:11 AM, Walter van der Laan wrote: Are you somehow required to use the Java library? Otherwise you could also use a Clojure map as a sparse matrix. This will be much easier to implement. Using a clojure map to store a sparse matrix is not a good solution if you plan on doing any

Re: How to add a new type of collection?

2012-01-25 Thread joachim
Great, thanks people. So to be surfe I understand, let me summarize as follows: There are two ways to go: (1) import the existing sparse matrix class in my clojure project and wrap a new type around it that implements all required java interfaces (using them as protocols) (2) code a new java

How to add a new type of collection?

2012-01-24 Thread joachim
Dear, I am using a java class that implements sparse matrices (see http://javasourcecode.org/html/open-source/mahout/mahout-0.5/org/apache/mahout/math/SparseMatrix.html). I was wondering how to add them to clojure as a new type of collection, so that I can use nth and count etc. on them? Thanks,

Re: How to add a new type of collection?

2012-01-24 Thread Stuart Sierra
The fundamental interfaces are all written in Java. ISeq, IPersistentCollection, and so on. You can implement then in deftype. Look at (ancestors (class [])) as a place to start. -S -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: How to add a new type of collection?

2012-01-24 Thread Ben Mabey
On 1/24/12 7:20 AM, Stuart Sierra wrote: The fundamental interfaces are all written in Java. ISeq, IPersistentCollection, and so on. You can implement then in deftype. Look at (ancestors (class [])) as a place to start. -S I believe the OP wanted to know if they could extend a java data

Re: How to add a new type of collection?

2012-01-24 Thread Stuart Sierra
Oh, I see. Yes, you can't do that in Clojure right now, because the core functions are not based on Protocols. ClojureScript is built on Protocols from the ground up. It would be nice to have this in Clojure too, but would require some pretty serious redesign. -S -- You received this message

Re: How to add a new type of collection?

2012-01-24 Thread endbegin
I know this isn't exactly what the OP is looking for, but the Incanter project has done something for dense matrices that might work. The Matrix type has been imported (which is a java class), and a whole bunch of functions have been implemented on that class. See here