On Fri, 28 Aug 2009, Sherlock Ric wrote: > I'm not convinced that this solution meets the spec given for the RosettaCode > problem "Basic bitmap storage" > http://rosettacode.org/wiki/Basic_bitmap_storage > > allocimg=: 0 $~ 3 ,~ ] > fillimg=: ]`(a:"_)`[} > setpix=: (1&{::@])`([: <@;/ <:@(0&{::@]))`[} > getpix=: <@;/@:<:@] { [ > > myimg=: allocimg 10 7 NB. 10 by 7 pixel image > myimg=: myimg fillimg 0 255 0 NB. fill with green > myimg getpix 4 5 NB. get color of pixel from 4th row and > 5th col > 0 255 0 > myimg=: myimg setpix 4 5; 255 0 255 NB. set pixel to magenta > myimg getpix 4 5 NB. verify > 255 0 255 >
I guess if myimg is on the rhs of verb, then it will not require additional ~ in verb train such as .... setpix~ 0 255 0 fillimg~ allocimg 10 7 -- regards, ==================================================== GPG key 1024D/4434BAB3 2008-08-24 gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
