Thanks Julian, this is Good Advice™

My cloumsy answer was meant to say
“that’s not the J way”
without actually spelling that out.
But maybe it didn’t come across.

Sometimes the best answer to “how?” is just “don’t!”


Am 27.01.22 um 15:44 schrieb Julian Fondren:
J doesn't have lexical scope so you're cutting against the grain of the 
language to want internal definitions like this. Those internal verbs are also 
defined every single time the function is called. The entire APL family of 
languages have their own ways of achieving readability and maintainability and 
performance and much of it's pretty at odds with common practice in other 
languages.

You can organize code with locales: 
https://code.jsoftware.com/wiki/Vocabulary/Locales
Instead of using internal definitions just to hide them, you can define them in 
the same or another locale. This also defines them once instead of every time 
the outer function is called, allows you to inspect them interactively, etc.

You can smuggle data into an internal definition by using conjunctions, like the & 
in f =. x & {{ x + y }}

------- Original Message -------

On Thursday, January 27th, 2022 at 7:55 AM, Pawel Jakubas 
<jakubas.pa...@gmail.com> wrote:

I am wondering how to embed definition of `f` inside `repeat`. so I would
call `x repeat d` and inside this function `x f (d;d)` would be called. On
both levels, repeat and f, we have names x and y.And I wonder what are the
techniques to (a) reuse them at both `repeat` and `f` level, (b) separate
them, for example x on `f` definition level is not the same as in `repeat`
level.

Thanks,
Pawel
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

--
----------------------
mail written using NEO
neo-layout.org
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to