Currently, my code looks like this:
fun gradImage () =
let val iImg = Gdimage.image(640,480) (0,0,0);
val void = mapi gradient iImg;
in
Gdimage.toPng iImg "gradient.png"
end;
mapi is a function with type intint->intint*int->image->unit. Essentially it operates on the image supplied.
The function looks ugly with val void = …
How could I eliminate that?
You can have a list of expressions between
inandendin aletexpression. So you could rewrite your code toI assume
mapimodifiesiImgin place, as the code seems to be written that way. That doesn’t sound very functional; it would feel more natural to havemapireturn the modifiedimage, but from what I can see of the Gdimage interface, it looks like how it’s done there, and I understand it’s probably better from efficiency perspective.