Raul,
Your code is especially clear in many ways, but I am having trouble
understanding how the dyad `square` works. Below is an excerpt from my
explorations to understand the phrase X-"1 0 . That phrase looks like X is
a noun and -"1 0 is a verb constructed from the adverb " . If I am correct
in saying these two pieces are a NV (noun verb) combination, then I don't
know how that is parsed in J, although VN is so common. (And btw, I cannot
begin to process the rest of that long sentence in the dyad `square` until
I understand this first part. Forgive me if I have not included your most
recent revisions into this post.)
Here is part of the problem: I get different results (1) when I execute the
phrase X-"1 0 in isolation and when (2) I execute the same phrase inside
the debug routine.
In the first case (1) I get the following which I believe are verb results.
-"1 O
-"1 O
CYAN-"1 O
0 1 1 -"1 O
But when I execute the same code inside a debug (2) I get the following
which I believe are noun results.
load'debug'
dbss 'square : 1'
'BACK' square GREEN;CYAN;BLACK
|stop: square
| colors=.<.255*O+"1,/0.25*((i.5)*/Y-"1 O)+"1/(i.5)*/X-"1 O
|square[:1]
X-"1 O
0 0 1
X
0 1 1
CYAN
0 1 1
-"1 O
0 _1 0
On Sat, Jun 13, 2015 at 1:00 AM, Raul Miller <[email protected]> wrote:
> I got a lot of squares running your script, and the one that I really
> liked was the one that was labeled 'TOP'. So I'll base my
> implementation on that one.
>
> For something as complicated as this, I think I'd like to sketch out
> first how it's supposed to look.
>
> So here's my first sketch:
> (<'BASE')(<3 1)}(<'FRONT')(<2 1)}(;:'LEFT TOP RIGHT')1}(<'BACK')(<0 1)}4
> 3$a:
>
> (beware line wrap - that's supposed to be a single line).
>
> But I also need to think about colors. After a little fiddling, I
> decided to go with this:
>
> TOP=:<,.'TOP';<2 2$;:'BLACK BLUE RED MAGENTA'
> BACK=:<,.'BACK';<2 2$;:'GREEN CYAN BLACK BLUE'
> FRONT=:<,.'FRONT';<2 2$;:'RED MAGENTA YELLOW WHITE'
> BASE=:<,.'BASE';<2 2$;:'YELLOW WHITE GREEN CYAN'
> LEFT=:<,.'LEFT';<2 2$;:'BLACK RED GREEN YELLOW'
> RIGHT=:<,.'RIGHT';<2 2$;:'MAGENTA BLUE WHITE CYAN'
> BASE(<3 1)}FRONT(<2 1)}(LEFT,TOP,RIGHT)1}BACK(<0 1)}4 3$a:
>
> with that out of the way, all I need is a routine to render squares,
> the rest of the code almost writes itself:
>
> 'BLACK BLUE GREEN CYAN RED MAGENTA YELLOW WHITE'=:#:i.8
>
> square=:4 :0
> 'O X Y'=. y
> colors=. <.255*O+"1,/0.25*((i.5)*/Y-"1 O)+"1/(i.5)*/X-"1 O
> colors viewmat (i.5 5);x
> )
>
> 'BACK' square GREEN;CYAN;BLACK
> 'LEFT' square BLACK;RED;GREEN
> 'TOP' square BLACK;BLUE;RED
> 'RIGHT' square MAGENTA;BLUE;WHITE
> 'FRONT' square RED;MAGENTA;YELLOW
> 'BASE' square YELLOW;WHITE;GREEN
>
> Good enough?
>
> Thanks,
>
> --
> Raul
>
>
> --
(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm