Right. No nested scope. Henry Rich
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of June Kim > Sent: Monday, September 25, 2006 2:33 PM > To: Programming forum > Subject: Re: [Jprogramming] Local vs. Global (was Re: Base Conversion) > > I think I understood it. J doesn't support "nested scoping"[1] and fa > is a new and independent scope by itself, separated from MN's local > scope. Hence, inside fa we can't access d, which resides in MN's local > scope. > > Am I right? > > [1] http://en.wikipedia.org/wiki/Scope_(programming) > > 2006/9/26, June Kim <[EMAIL PROTECTED]>: > > Oh.. I've been thinking so far that the running > context(scope) of "toN > > fromM y" has to be the local of MN. > > > > When(& from where) is fa(explicit definition) evaluated? I > thought it > > should've got evaluated before leaving the last line in MN. > > > > I am now doubting my understanding of J's execution model. (any > > directions welcomed) > > > > 2006/9/26, Henry Rich <[EMAIL PROTECTED]>: > > > fa is an explicit definition, and d is not defined inside it. > > > d is local to MN. > > > > > > I really wish that there were some way for modifiers to refer > > > by name to private variables in the calling definition. > > > But there's not (before J5 you could get around the problem). > > > > > > For this case, make fa a conjunction and pass d in as an operand. > > > > > > Henry Rich > > > > > > > -----Original Message----- > > > > From: [EMAIL PROTECTED] > > > > [mailto:[EMAIL PROTECTED] On Behalf Of June Kim > > > > Sent: Monday, September 25, 2006 12:51 PM > > > > To: Programming forum > > > > Subject: [Jprogramming] Local vs. Global (was Re: Base > Conversion) > > > > > > > > MN=: dyad define > > > > 'M N'=.x > > > > d=.'0123456789ABCDEF' > > > > fa=. 1 : 'm&#.@(d&i.)' > > > > fromM=.M fa > > > > toN=.N fa^:_1 > > > > toN fromM y > > > > ) > > > > > > > > 16 2 MN 'FF' > > > > |domain error: fromM > > > > | toN fromM y > > > > > > > > It works when "d" in MN is defined as global with =:. > Why does it have > > > > to be defined globally? > > > > > > > > 2006/9/26, June Kim <[EMAIL PROTECTED]>: > > > > > Hello > > > > > > > > > > Base M and N are given, which are any integer number > > > > between 2 and 16 > > > > > inclusive. Do the base conversion on a given > number(in string form) > > > > > from base M to base N. > > > > > > > > > > My quick trial follows: > > > > > > > > > > d=:'0123456789ABCDEF' > > > > > fromM=: [ #. d i. ] > > > > > toN=:d {~ 13 : 'x&#. ^:_1 y' > > > > > MN=: ([: {: [) toN ] fromM~ [: {. [ > > > > > > > > > > 16 2 MN 'FE' > > > > > 11111110 > > > > > 8 16 MN '732' > > > > > 1DA > > > > > > > > > > > > > > > Could you propose a pure tacit version, or more elegant, > > > > shorter one? > > > > > I bet there are better ones than mine, as always. > > > > > > > > > > June > > > > > > > > > > ---------------------------------------------------------------------- > > > > For information about J forums see > > > > http://www.jsoftware.com/forums.htm > > > > > > > ---------------------------------------------------------------------- > > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > > > > ---------------------------------------------------------------------- > For information about J forums see > http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
