Thank you - following this discussion has helped me a lot! Also I didn't
look into NuVoc til now but rather limited myself to the old vocabulary
simply because it is included in the installation.

Ehm, since I mentioned it, here's my AoC 9 part I. Of course this does not
use u} at all - that part got dropped during the review.


inp =: (' ',LF,CR,TAB) -.~ freads 'aoc9.txt'

NB. sequential machine to extract compression markers
f=:2
m=:a. e. '('
m=:m + 2 * a. e. '0123456789'
m=:m + 3 * a. e. 'x'
m=:m + 4 * a. e. ')'

s=: _2]\"1 }.".;._2 (0 : 0) 
' 0    (   dig   x    ) ']0
 0 0  1 1  0 0  0 0  0 0  NB. 0  waiting for (
 0 0  0 0  1 0  2 0  0 0  NB. 1  reading first number
 0 0  0 0  2 0  0 0  3 0  NB. 2  reading second number
 0 3  1 2  0 3  0 3  0 3  NB. 3  end
)

find_markers=:(2;s;m;0 _1 0 0)&;: 

NB. extract maker position, length and data
pick_marker=:(<:@<:@{:@[ {. >:@{.@[ }. ])"1
blank_x=:' '&(i.&'x'@] })
read_marker=:".@blank_x"1
extract=:find_markers ([ ,. read_marker@:pick_marker) ]

NB. some markers shadow others
pos_and_len=: ({. , +/@}.@}:)"1
shadow=:4 : 0   
 'fr pr lr'=.y
 'fl pl ll'=.x
 if. lr > pl - pr do.
  0 , pl , lr - pl - pr
  return.
 end.
 x
)
relevant_markers=: #~ {."1 @: (shadow/\.&.|.) @: (1 ,"1 pos_and_len)

NB. length increase associated with each marker
weight=:(1&{ -~ <:@{: * 2&{)"1

(# inp) + +/ weight relevant_markers extract inp

--
David


Brian Schott <[email protected]> writes:

> To clarify NuVoc's explanation, first I think I created the index list for
> the current example.
>
>    ,/>@{(i. 3);i. 2
> 0 0
> 0 1
> 1 0
> 1 1
> 2 0
> 2 1
>
> Then pretending that y is i. 3 2, I applied the expression given in NuVoc
> and it produces the expected "atom numbers".
>    ($i. 3 2)#.  ,/>@{(i. 3);i. 2
> 0 1 2 3 4 5
>
> I think this also confirms Cliff's observation.
>
> On Wed, Dec 28, 2016 at 10:24 AM, Henry Rich <[email protected]> wrote:
>
>> The Dictionary does discuss this, at http://www.jsoftware.com/help/
>> dictionary/d530v.htm but unfortunately it doesn't mention that the result
>> of u is the atom number.
>>
>> NuVoc in http://code.jsoftware.com/wiki/Vocabulary/curlyrtu#dyadic does
>> describe the case correctly, though without the usual examples because the
>> form is antiquated.
>>
>> Henry Rich
>>
>>
>>
>>
> ----------------------------------------------------------------------
> 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