Nobody is asking for explanations here, but I probably should explain anyways.

The columns here correspond to '<', '!', '>', and everything else.

The fractional parts are instructions:
   .1 start word
   .3 end word
   .0 continue with whatever is happening

The integer parts identify the row which will be used to handle the
next character (and we start at row 0 for the first character, and we
are not in a word when we start).

Hopefully that makes sense. For further detail, I guess you'd just run
it by hand on some short examples. (That's almost how I write the
things.)

So, for example, in gc, if you are in a word you are also on row 1. If
you encounter a < you always go to row 2 (and end any word if there
was one).

Meanwhile, in cg, if you are in a word (if you are dealing with text
which will be part of the result), you are always on row 2 - leaving
the row ends that word. It's not quite symmetrical with gc because we
do not want the bounding < and > to be included in the "word"s in
either implementation. So that's why in cg sometimes < sends you to
row 1 (which is where the words start in cg).

Anyways, it's really worth running some examples through by hand if
you want to see how these things work.

I hope this helps,

-- 
Raul


On Sat, Dec 9, 2017 at 5:39 PM, Raul Miller <[email protected]> wrote:
> Yes:
>
> gc=:(1;(0 10#:10*".;._2]0 :0);'<!>'i.a.)&;:
>  2.0 1.1 1.1 1.1 NB. 0: end of garbage
>  2.3 1.0 1.0 1.0 NB. 1: not garbage
>  2.0 3.0 0.0 2.0 NB. 2: garbage
>  2.0 2.0 2.0 2.0 NB. 3: cancelled garbage
> )
>
> cg=:(1;(0 10#:10*".;._2]0 :0);'<!>'i.a.)&;:
>   1.0 0.0 0.0 0.0 NB. 0: not garbage
>   2.1 3.0 0.0 2.1 NB. 1: start of garbage
>   2.0 3.3 0.3 2.0 NB. 2: in garbage
>   1.0 1.0 1.0 1.0 NB. 3: cancelled garbage
> )
>
>
> score=:3 :0
>   stream=. gc y
>   +/('{'=stream)#+/\-/'{}'=/stream
> )
>
> Part 1 was
>    score input
>
> Part 2 was
>    #cg input
>
> Thanks,
>
> --
> Raul
>
>
> On Sat, Dec 9, 2017 at 4:35 PM, Jimmy Gauvin <[email protected]> wrote:
>> Hi all,
>>
>> has anybody used the Sequential Machine ;: to solve this problem?
>> It seems like a natural fit.
>>
>>
>>
>> On Sat, Dec 9, 2017 at 1:48 PM, David Lambert <[email protected]> wrote:
>>
>>> Small victory!  I guessed that part 2 would address the chaff.
>>>
>>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to