Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What do you mean by lazy?</p> <p>An array is not a lazy data type, which means that if you want to use arrays, you need to load all pixels during the initialization. If we were using single-dimensional array, an alternative would be to use <code>seq&lt;_&gt;</code> which is lazy (but you can access elements only sequentially). There is nothing like <code>seq&lt;_&gt;</code> for multi-dimensional arrays, so you'll need to use something else.</p> <p>Probably the closest option would be to use three-dimensional array of lazy values (<code>Lazy&lt;int&gt;[,,]</code>). This is an array of delayed thunks that access pixels and are evaluated only when you actually read the value at the location. You could initialize it like this:</p> <pre><code>for i=0 to Width for j=0 to Height let point = lazy image.GetPixel(i,j) pixels.[0,i,j] &lt;- lazy point.Value.R pixels.[1,i,j] &lt;- lazy point.Value.G pixels.[2,i,j] &lt;- lazy point.Value.B </code></pre> <p>The snippet creates a lazy value that reads the pixel (<code>point</code>) and then three lazy values to get the individual color components. When accessing color component, the <code>point</code> value is evaluated (by accessing <code>Value</code>).</p> <p>The only difference in the rest of your code is that you'll need to call <code>Value</code> (e.g. <code>pixels.[0,10,10].Value</code> to get the actual color component of the pixel.</p> <p>You could define more complex data structures (such as your own type that supports indexing and is lazy), but I think that array of lazy values should be a good starting point.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload