Re: Defining own data types on top of Persistent ones

2008-11-02 Thread André Thieme
On 1 Nov., 14:12, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Oct 31, 1:20 pm, André Thieme <[EMAIL PROTECTED]> wrote: > > Here is what I tried: > > > user> (defn make-lyst [& items] > >         (proxy [clojure.lang.IPersistentList] [] > >                (cons [obj] (cons obj this)) > >          

Re: Defining own data types on top of Persistent ones

2008-11-01 Thread Rich Hickey
On Oct 31, 1:20 pm, André Thieme <[EMAIL PROTECTED]> wrote: > In #Clojure Rich mentioned today that we can define our own data > structures on top of the existing ones. > Maybe someone wants/needs his own version of vectors that rearrange > automatically in some specific order or whatever. > > I

Re: Defining own data types on top of Persistent ones

2008-10-31 Thread Meikel Brandmeyer
Hi André, Am 31.10.2008 um 22:48 schrieb André Thieme: Can anybody give a very simple/minimal implementation of lists/ vectors/ maps in Clojure? A 5-20 lines (proxy ...) example that would allow me to say (def a (make-lyst 1 2 3)) and run several list functions on it? There is my lazy-map pac

Re: Defining own data types on top of Persistent ones

2008-10-31 Thread André Thieme
Stuart Sierra schrieb: > On Oct 31, 1:20pm, André Thieme <[EMAIL PROTECTED]> wrote: > > But unfortunately (make-lyst 1 2 3) ==> > > java.lang.ClassCastException: clojure.lang.Proxy__5307 cannot be cast > > to clojure.lang.ISeq > > > > Any ideas how this should be done so that it will work? > > I t

Re: Defining own data types on top of Persistent ones

2008-10-31 Thread Stuart Sierra
On Oct 31, 1:20 pm, André Thieme <[EMAIL PROTECTED]> wrote: > But unfortunately (make-lyst 1 2 3) ==> > java.lang.ClassCastException: clojure.lang.Proxy__5307 cannot be cast > to clojure.lang.ISeq > > Any ideas how this should be done so that it will work? I think the problem here is that IPersis

Defining own data types on top of Persistent ones

2008-10-31 Thread André Thieme
In #Clojure Rich mentioned today that we can define our own data structures on top of the existing ones. Maybe someone wants/needs his own version of vectors that rearrange automatically in some specific order or whatever. If I now want to add something that works nearly like lists, but a little