Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request]: Recursion scope adverb #203

Open
cchando opened this issue Jul 24, 2024 · 0 comments
Open

[Feature request]: Recursion scope adverb #203

cchando opened this issue Jul 24, 2024 · 0 comments

Comments

@cchando
Copy link

cchando commented Jul 24, 2024

This would be backward compatible since no existing user code can contain R. (or whatever new adverb spelling/inflection is chosen), as it would've been a spelling error.

The following provides a motivation:

   ap  =: {{y`:6>x}}`{{y`:6&>/x}}@.(2=#@[)
   r   =: ($: 2&}.)`(ap 1&{)@.(ap {.)`ap@.(1=#@])
   Cond=: {{< :(,&<) r m"_}}

Here the recursive subexpression r is defined on its own line just because we don't want the < :(,&<) part of Cond to be part of the recursion; but r is not a very natural expression to separate from Cond and assign to a name.

Ideally this would be written inline using a recursion scoping adverb R.:

   ap  =: {{y`:6>x}}`{{y`:6&>/x}}@.(2=#@[)
   Cond=: {{< :(,&<) ($: 2&}.)`(ap 1&{)@.(ap {.)`ap@.(1=#@])R. m"_}}

where the scope of $: is limited to [the verb operand to the nearest adverb R.] which contains $:. The existing definition of $: holds if its no R. is present within the largest verb containing $: within the given sentence. R. can appear in multiple places within a verb, as in

   (… $: … ($: …)R. …)R.

As motivation, one of the benefits of J's terseness, and of tacit programming's absence of names, is the dispensation of the need to break up code into arbitrary (non-[conceptual/semantic]) pieces which will be used once only, and of the resulting need to create arbitrary names for these pieces. Anonymous recursion seems to be the only place where one is forced into doing so.

Z. would be my fallback naming suggestion since this adverb is like Z: in that each modifies the behavior of a particular primitive ($: and F(.:)(.:) respectively).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant