On Sun, May 4, 2014 at 3:58 AM, Linda Alvord <[email protected]> wrote:
> My first problem is finding out how Raul's
>
> ":@/:~/./|:0 10 #: ruth
> 4 4 9
> 4 5
> 1 1 6 6 6 7 9
> 2 5
> 0
>
> I can see how the rows are in a different order, but I can't figure out how
> it works.  I'd like to write an explicit verb that has his result.


stem=: 3 : '":@/:~/./|:0 10 #: y'

We can make it more explicit though. I sometimes need to start by
understanding the words involved:

;: '":@/:~/./|:0 10 #: ruth'

Alternatively, we can use a boxed representation after making it explicit:

stem =: 13 : '":@/:~/./|:0 10 #: y'
   5!:2 <'stem'
┌──┬──────────────────────┬───────────────────┐
│[:│┌──────────────────┬─┐│┌──┬──┬───────────┐│
│  ││┌─────────────┬──┐│/│││[:│|:│┌────┬──┬─┐││
│  │││┌─────────┬─┐│/.││ │││  │  ││0 10│#:│]│││
│  ││││┌──┬─┬──┐│~││  ││ │││  │  │└────┴──┴─┘││
│  │││││":│@│/:││ ││  ││ ││└──┴──┴───────────┘│
│  ││││└──┴─┴──┘│ ││  ││ ││                   │
│  │││└─────────┴─┘│  ││ ││                   │
│  ││└─────────────┴──┘│ ││                   │
│  │└──────────────────┴─┘│                   │
└──┴──────────────────────┴───────────────────┘

From here, we can start to see the structure. Fully parenthesized:

(([: ((":@/:)~(/.)/) ([: |: (0 10 #: ]))) ruth) -: (stem ruth)
1

steme =: 3 : 0
g=: [: |: (0 10 #: ])
f=: (":@/:)~(/.)/
([: f g) y
)

smoutput (steme ruth) -: (stem ruth)
1

steme2 =: 3 : 0
g=: |: @: (0 10 #: ]) NB. simplify capped fork
f=: (":@/:)~(/.)/
f@:g y NB. simplify capped fork
)

smoutput (steme2 ruth) -: (stem ruth)
1


steme3 =: 3 : 0
g=: 3 : '|: 0 10 #: y'
f=: 3 : '(":@/:)~(/.) / y'
f g y
)

smoutput (steme3 ruth) -: (stem ruth)
1

Is that the level of explicit you were looking for?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to