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.<div><br></div><div>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)</div>
<div><br></div><div>Jay</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 31, 2012 at 6:38 PM, Danny Yoo <span dir="ltr">&lt;<a href="mailto:dyoo@hashcollision.org" target="_blank">dyoo@hashcollision.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Wed, Oct 31, 2012 at 5:12 PM, Gregory Woodhouse<br>
&lt;<a href="mailto:gregwoodhouse@icloud.com">gregwoodhouse@icloud.com</a>&gt; wrote:<br>
&gt; I&#39;ve been thinking about whether how to implement matrices in Racket. One obvious option is just to use a vector<br>
<br>
<br>
</div>Oh!  That&#39;s related to something I was coding up called &quot;multidim&quot; to<br>
do multi-dimensional matrices.  Here is the source:<br>
<br>
    <a href="https://github.com/dyoo/multidim" target="_blank">https://github.com/dyoo/multidim</a><br>
<br>
I was going to ask the list for a code review to figure out what a<br>
nice API would be.  No documentation yet, but does have test cases.<br>
<div class="im"><br>
<br>
<br>
&gt; ;;a matrix with data stored in the vector data<br>
&gt; (struct matrix (rows cols [data #:mutable]))<br>
<br>
<br>
</div>If we&#39;re going to use a single mutable vector for data, then we don&#39;t<br>
need to mark the field itself as #:mutable.  We&#39;d need it if we were<br>
to use set-matrix-data!, but I don&#39;t think you&#39;re doing that, right?<br>
<div class="im"><br>
<br>
<br>
&gt; Is there a preferred way of doing this sort of thing?<br>
<br>
</div>I&#39;m not sure.  I think it really depends on the application.  If we<br>
need persistent structures, then probably something like Jay&#39;s matrix<br>
package might be helpful:<br>
<br>
    <a href="http://planet.racket-lang.org/display.ss?package=matrix.plt&amp;owner=jaymccarthy" target="_blank">http://planet.racket-lang.org/display.ss?package=matrix.plt&amp;owner=jaymccarthy</a><br>
<div class="HOEnZb"><div class="h5">____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Jay McCarthy &lt;<a href="mailto:jay@cs.byu.edu" target="_blank">jay@cs.byu.edu</a>&gt;<br>Assistant Professor / Brigham Young University<br><a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>&quot;The glory of God is Intelligence&quot; - D&amp;C 93<br>
</div>