recursion - F# Recursively creating a int list list -


Then I have a bitmap that is an int list list, representing 3 pixels per indicator RGB. One line of the image is a list, and I'm trying to edit this int listing list recycle and spit the second int list list back. The problem is that when I reach the end of a line, I want to make it a second list. Now the code creates a list per pixel per line, 3 values ​​per list and the image is going down a straight line, so it is making a new list of each recursive call I want to continue on the same list, while it The end of the width has not been reached Here's the code to make a bit more sense as I have a hard time explaining this.

  REC grayscale picture (width: integer, width: integer, image: int list list) = image with match | [] - & gt; [] | _ - & gt; Let's get R = image.Have go.Come on. Image.Read.Sit.Cheat.Come on.Come on.Sit.Bell.You average = (int) ((R + G + B) / 3) Give wide bravery and GT; 3 then [average; Average; Average] :: grayscale image (width, width-1, image. Tail, tail) other ??? Firstly, if a new list is created after that, then I want to keep it on the list of averages. (This image is in scaling of BTD) and then I know that it should do it. If that happens then something happens, but probably not at all. I am very confused about doing this.  
  REC BuildRowGrayscale (Column: Int, A: IT) = There is some progress with match calls:  

Edit: with. 0 - & gt; [] | _ - & gt; A :: a :: a :: BuildRowGrayscale (cols-1) Match image with a Rick Rick GrasecaleImage (width: int, height: int, depth: int, image: int list list) = | [] - & gt; [] | _ - & gt; Let's R = Image. G = image. Take care.Bell.Come on.Better image.Get up.Sit. Sit down. Average = (intestine) ((r + g + b) / 3) (buildreve grayscale width avg) :: grayscale image (width, height, depth, image. Tail)

but it BuildRowGrayscale (Columns-1) refuses to build on (BuildRowGrayscale width average) and "This value is not a function and it can not be applied"

After your comment, I think you are trying to do this:

  REC grayscale image image A. = REC BuildRowGrayscale = FUNCTION | [] - & gt; [] | R :: G :: B :: rest - & gt; Give Avg = (r + g + b) / 3 (avg :: avg :: avg :: BuildRowGrayscale rest). _ - & gt; Failed image with "illegal image" match [] - & gt; [] | Line :: rest - & gt; BuildRowGrayscale line :: grayscale image balance  

or list.replicate and List.map using:

  grayscale image = REC BuildRowGrayscale = function | Please [] - & gt; [] | R :: G :: B :: rest - & gt; List Repetition 3 ((R + G + B) / 3) @ BuilderGraz balance. _ - & gt; Failed image "List.map BuildRowGrayscale  

Sorry, but the fact that you were specifying width, I think you were also changing the original structure, but if the structure does not change You do not have to specify the width, it is rooted in the original structure.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -