[racket] Mutation of structure elements
My matrix package actually only provides semi-persistent (a technical term
in the data structures world, I guess) matrices. A fully functional one
would probably just use a double layered hasheq.
Basically, you can always read any older version of the matrix, but you
only modify the latest modification. Also, reads to an old version are O(n)
where n is the distance (in writes) to the latest but reads to the current
version are O(1)
Jay
On Wed, Oct 31, 2012 at 6:38 PM, Danny Yoo <dyoo at hashcollision.org> wrote:
> On Wed, Oct 31, 2012 at 5:12 PM, Gregory Woodhouse
> <gregwoodhouse at icloud.com> wrote:
> > I've been thinking about whether how to implement matrices in Racket.
> One obvious option is just to use a vector
>
>
> Oh! That's related to something I was coding up called "multidim" to
> do multi-dimensional matrices. Here is the source:
>
> https://github.com/dyoo/multidim
>
> I was going to ask the list for a code review to figure out what a
> nice API would be. No documentation yet, but does have test cases.
>
>
>
> > ;;a matrix with data stored in the vector data
> > (struct matrix (rows cols [data #:mutable]))
>
>
> If we're going to use a single mutable vector for data, then we don't
> need to mark the field itself as #:mutable. We'd need it if we were
> to use set-matrix-data!, but I don't think you're doing that, right?
>
>
>
> > Is there a preferred way of doing this sort of thing?
>
> I'm not sure. I think it really depends on the application. If we
> need persistent structures, then probably something like Jay's matrix
> package might be helpful:
>
>
> http://planet.racket-lang.org/display.ss?package=matrix.plt&owner=jaymccarthy
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121031/1b32863c/attachment.html>