Re: [Jprogramming] function within function; scope

2020-03-24 Thread rsykora
Dear Raul and Henry thank you for your comprehensive list of ideas and explanation. It helped. Ruda March 20, 2020 11:22 PM, "Raul Miller" wrote: > There are several ways to accomplish what I think you're asking for: > > Algebraic simplification: > g=:3 :0 > -y > ) > > Pass the intermediat

Re: [Jprogramming] function within function; scope

2020-03-20 Thread Raul Miller
Hmm... I'd phrase that differently: J's blocks are a strict (or maybe 'flat') abstraction that do not inherit from other blocks. Local names (as opposed to locale names) are specific to the block they were created in, That said, the underlying concept is, I think, the same. Thanks, -- Raul O

Re: [Jprogramming] function within function; scope

2020-03-20 Thread Raul Miller
There are several ways to accomplish what I think you're asking for: Algebraic simplification: g=:3 :0 -y ) Pass the intermediate result as a parameter: g=:3 :0 b=. 2*y f=. 4 :'y-x' b f y ) Or g=:3 :0 b=. 2*y f=. b 1 :'y-m' f y ) Serialize the desired value and incorporate it i

Re: [Jprogramming] function within function; scope

2020-03-20 Thread Henry Rich
J has no concept of block scope.  locales provide namespaces, so public assignments are not truly global but only visible within the locale; but for something small like what you are talking about you just can't do it. Henry Rich PS You CAN actually get to g's b from the function f, using a fe

[Jprogramming] function within function; scope

2020-03-20 Thread Rudolf Sykora
Dear list, although I seem to be able to define a function within another function, it seems that the inner function does not see private variables from the outer one. What is then the correct way to write something like g =: 3 : 0 b =. 2*y f =. 3 : 'y-b' f y ) g 2 and get -2 as a result? Her