> From: bill lam
> 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

Thanks, yes I had it around that way originally but swapped to avoid having to 
enclose the left argument for setpix in brackets. 
I think you're right though - it is the more natural way.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to