You're correct in terms of matching the pseudo-code but the original, less
accurate version gives better results. As shown below, the correct version
gives a very skinny, hard to visualize, result whereas the original,
mistaken, version gives a squarer result.
This makes me even more wary of pseudo-code.
NB. With spec matching pseudo-code:
DR=: 0 0, 0 1, 0 _1, 1 0, _1 0, 0 1, 0 0, 0 0, 0 0, 0 0,: 0 0
primenebulaP 1e6
247 x 99935
NB. Original, not matching pseudo-code:
DR=: 0 0, 0 1, 0 _1, 1 0, _1 0, 0 0, 0 0, 0 0, 0 0, 0 0,: 0 0
primenebulaP 1e6
247 x 224
NB. Where
primenebulaP=: 3 : 0
d=. ({.,#)/.~+/\ {&DR 11|p: i.y NB. scan left +/ on movement steps
NB. normalize coordinates to upper right quadrant and calculate size
'gx gy '=. >: >./ XY=.(2{."1 d) -"1 {.~&2 <./ d
smoutput (": gx),' x ', ": gy NB. show picture size
viewmat (2{"1 d) (<"1 XY) } 0$~ gx, gy
)
On Thu, Jan 7, 2010 at 4:31 PM, Viktor Cerovski
<[email protected]>wrote:
> ...
> For x=5, it should go up, ie:
>
> dr=: 0 0, 0 1, 0 _1, 1 0, _1 0, 0 1, 0 0, 0 0, 0 0, 0 0,: 0 0
> ...
>
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm