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

Re: [Jprogramming] working with content of boxes

2020-03-20 Thread Raul Miller
That approach looks like it matches that description of what you want. Thanks, -- Raul On Fri, Mar 20, 2020 at 11:10 AM Rudolf Sykora wrote: > > Dear Raul, > > > thanks for your prompt answer, I hope I understand the logic at least somehow. > The first part is understood, you break the list of

Re: [Jprogramming] working with content of boxes

2020-03-20 Thread Rudolf Sykora
Dear Raul, thanks for your prompt answer, I hope I understand the logic at least somehow. The first part is understood, you break the list of boxes and rebuild it back. The second question, by my fault, was misinterpreted. I actually want to do the operation on each third box (where, by chance,

Re: [Jprogramming] working with content of boxes

2020-03-20 Thread Raul Miller
ee=:(129;144;51582.8125;7);<128;143;51545.3125;22 If you define a verb which combines the first two boxes of list of numbers, for example: ((2 ;@{. ]);2 }.]) 1{:: ee +---+---+--+ |128 143|51545.3|22| +---+---+--+ You can apply that at level 1 of your noun using L:1 ((2 ;@{.

[Jprogramming] working with content of boxes

2020-03-20 Thread Rudolf Sykora
Dear list, say I have a variable ee +--+---+ |+---+---+--+-+|+---+---+--+--+| ||129|144|51582.8125|7|||128|143|51545.3125|22|| |+---+---+--+-+|+---+---+--+--+| +--+---+ how can I 1)