<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt;color:#00007f;"><div>Dear Clean team,<br><br>I'm trying a two-dimensional array update in-place... and got lost.<br><br>I have this utility function I did a while ago for update in place for one-dimensional arrays...<br><br>// updates first parameter (array) in place with values from a function that takes as parameters the value at <br>// index p and p itself<br>updateInPlace :: *(a e) (e Int -&gt; e) Int -&gt; *(a e) | Array a e<br>updateInPlace arr1 f maxPos = updateLoop_ arr1 f 0 maxPos<br>where<br>&nbsp;&nbsp;&nbsp; updateLoop_ :: *(a e) (e Int -&gt; e) Int Int -&gt; *(a e) | Array a e<br>&nbsp;&nbsp;&nbsp; updateLoop_ arr1 f pos maxPos<br>&nbsp;&nbsp;&nbsp; | pos == maxPos&nbsp; = arr1<br>&nbsp;&nbsp;&nbsp; # (v, arr1) = arr1![pos]<br>&nbsp;&nbsp;&nbsp; = {(updateLoop_ arr1 f (pos+1) maxPos) &amp; [pos]
 = f v pos}<br><br>If not the best implementation, at least worked for me.<br><br><br>I'm now trying to port the following element-wise matrix multiplication (for the sake of a simple example)<br><br>times :: {{#Int}} {{#Int}} -&gt; {{#Int}}<br>times m1 m2 = {{m1.[i,j] * m2.[i,j] \\ j &lt;- [0..MAX_INDEX]} \\ i &lt;- [0..MAX_INDEX]}<br><br>into an efficient update in place in the first parameter... but this throws a compilation error<br><br>times :: *{{#Int}} {{#Int}} -&gt; *{{#Int}}<br>times m1 m2 = updateInPlace m1 rowUpdate SIZE<br>where<br>&nbsp;&nbsp;&nbsp; rowUpdate :: *{#Int} Int -&gt; *{#Int}<br>&nbsp;&nbsp;&nbsp; rowUpdate row i = updateInPlace row (\v j = v * m2.[i,j]) SIZE<br><br>And the error refers to rowUpdate, I believe, but refers to it curried, [i.e. like A -&gt; (B -&gt; C) instead of A B -&gt; C]... and says that (B -&gt; C) must be unique, I'm lost.<br><br>Am I missing something?<br><br>Kind regards<br>Carlos<br>p.s. attached
 test2.icl with extracted code above<br></div>
</div><br>



      &nbsp;</body></html>