[Jprogramming] index error on load (but works in console)

bill lam bbill.lam at gmail.com
Mon Apr 9 14:33:23 HKT 2007


On second thought, since tally_rightpairs had already thrown an error, the break 
point is redundant. Just invoke the debugger and load the script will work.

bill lam wrote:
> If I were you, I would use debug facility to test for y. or tallies in 
> the verb, insert a break point into tally_rightpairs
> 
> tally_rightpairs =: 3 : 0
> [:0
> +/"1 (2 3 {"1 ((i.#y.) { y.)){ tallies
> )
> 
> invoke debug by ctrl-k, and then load the script, when it stops at the 
> break point, type y. or $y. or tallies in the ijx.
> 
> 
> Tracy Harms wrote:
>> I've been working on the puzzle from Dr. Dobbs that
>> Randy MacDonald announced here:
>> http://www.jsoftware.com/pipermail/chat/2007-April/000467.html
>>
>> I'm still not ready for full-fledged spoilers, but I
>> am asking for help getting past one particular error
>> condition.  The problem is that an index error is
>> reported when I try to load the script, but it seems
>> fine when I run it in the J console.
>>
>> My approach to solving the puzzle is:
>>
>> reportstates same_chars same_tallies 4 comb 50
>>
>> I've only developed this as deep as verb same_tallies,
>> which is:
>>
>> same_tallies =: ((tally_leftpairs = tally_rightpairs)
>> y.) # y.
>>
>> Here are the component verbs:
>>
>> tally_leftpairs  =: 3 : '+/"1 (0 1 {"1 ((i.#y.) { y.))
>> { tallies'
>> tally_rightpairs =: 3 : '+/"1 (2 3 {"1 ((i.#y.) { y.))
>> { tallies'
>>
>> Now I'll show testing from a J session, ending with an
>> error on attempt to load the same verb that functioned
>> perfectly when entered in the console:
>>
>>    twocomb =: 0 1 11 14 ,: 4 5 6 20
>>    twocomb
>> 0 1 11 14
>> 4 5  6 20
>>    twocomb { states
>> +----------+--------+-----------+-------------+
>> |Alabama   |Alaska  |Idaho      |Iowa         |
>> +----------+--------+-----------+-------------+
>> |California|Colorado|Connecticut|Massachusetts|
>> +----------+--------+-----------+-------------+
>>    twocomb { tallies
>>  7 6  5  4
>> 10 8 11 13
>>    (0 1 {"1 ((i.#twocomb) { twocomb)) { tallies
>>  7 6
>> 10 8
>>    (2 3 {"1 ((i.#twocomb) { twocomb)) { tallies
>>  5  4
>> 11 13
>>    +/"1 (0 1 {"1 ((i.#twocomb) { twocomb)) { tallies
>> 13 18
>>    +/"1 (2 3 {"1 ((i.#twocomb) { twocomb)) { tallies
>> 9 24
>>    load 'c:\j504\user\miscellany\statespzl2.ijs'
>> |index error: tally_rightpairs
>> |   +/"1(2 3    {"1((i.#y.){y.)){tallies
>>
>> No error was signaled for the line before it, which
>> differed only in the values of the pairing noun:
>>
>> tally_leftpairs  =: 3 : '+/"1 (0 1 {"1 ((i.#y.) { y.))
>> { tallies'
>> tally_rightpairs =: 3 : '+/"1 (2 3 {"1 ((i.#y.) { y.))
>> { tallies'
>>
>> I'm at a loss as to what needs to be fixed, here.
>>
>> -- 
>> Tracy B. Harms
>>
>>      It is the central thesis of this book that the descriptive
>>      and analytic power of an adequate programming language amply
>>      repays the considerable effort required for its mastery.
>>                 Kenneth E. Iverson
>>                 A Programming Language, 1962
>>
>>
>>  
>> ____________________________________________________________________________________ 
>>
>> It's here! Your new message!  Get new email alerts with the free 
>> Yahoo! Toolbar.
>> http://tools.search.yahoo.com/toolbar/features/mail/
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> 
> 


-- 
regards,
bill


More information about the Programming mailing list