On Sun, Jun 04, 2006 at 04:40:53PM -0700, Frederick Akalin
wrote:
> I've run into this before. Basically, behind the
scenes, picture is an
> array of pointers. When you first call make_matrix,
you're passing in a
> default value, but that means that every pointer in
picture points to
> the *same* record with r=g=b=0, rather than each
pointer pointing to a
> *different* record with r=g=b=0.
>
> In the old code, you change each pointer in picture to
point to a
> newly-created record, but in the new code you're
updating the fields of
> the same record.
OK, thanks.
This is a thing in OCaml, I really hate. :(
The only thing I really hate in OCaml....
...and I again and again forget this thing... :(
...maybe I use Arrays too seldom to remember it...
>
> You probably want:
>
> Array.init (width * height) (fun i ->
{red=0;green=0;blue=0})
OK, thanks...
... and in that case I also can use the correct values while
doing it,
so I can throw out the later loop completely.
Thanks,
Oliver
------------------------ Yahoo! Groups Sponsor
--------------------~-->
Everything you need is one click away. Make Yahoo! your
home page now.
http://us.click.yahoo.com/AHchtC/4FxNAA/yQLSAA/saFolB/TM
------------------------------------------------------------
--------~->
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|