This strikes me as a confusing name:

increment=: [: $: >:

because $: implies recursion. Also, the bounds of recursion get slippery
when you start rearranging the code (and using f.).

But let's take a step back and think about what you are asking for here:

You have defined:
   increment =: [: $: >:
   result =: ]
   choose =: 3 < |

and you want an adverb A such that
   increment`[email protected] A
is
   (increment f.)`(result f.)@.(choose f.) A

But let's take a look at what A is working on:
   9!:3]2

   increment`[email protected]
┌──────────────────┬──┬──────┐
│┌─────────┬──────┐│@.│choose│
││increment│result││  │      │
│└─────────┴──────┘│  │      │
└──────────────────┴──┴──────┘

That's kind of vague, actually, let's look at what's really going on here:
   9!:3]1

   increment`[email protected]
┌────────────────────────────────────┐
│┌──┬───────────────────────────────┐│
││@.│┌──────────────────────┬──────┐││
││  ││┌─┬──────────────────┐│choose│││
││  │││0│┌─────────┬──────┐││      │││
││  │││ ││increment│result│││      │││
││  │││ │└─────────┴──────┘││      │││
││  ││└─┴──────────────────┘│      │││
││  │└──────────────────────┴──────┘││
│└──┴───────────────────────────────┘│
└────────────────────────────────────┘

That's a dizzying amount of detail, but this is what the data structure
looks like, that you'd need to work with if you wanted to write A. Except
that's not actually the data structure. Instead, it's the verb itself. To
get the data structure, you'd need to use 5!:1:

   increment`[email protected] 1 :'5!:1<''u'''
┌────────────────────────────────────┐
│┌──┬───────────────────────────────┐│
││@.│┌──────────────────────┬──────┐││
││  ││┌─┬──────────────────┐│choose│││
││  │││0│┌─────────┬──────┐││      │││
││  │││ ││increment│result│││      │││
││  │││ │└─────────┴──────┘││      │││
││  ││└─┴──────────────────┘│      │││
││  │└──────────────────────┴──────┘││
│└──┴───────────────────────────────┘│
└────────────────────────────────────┘

Now we have an actual data structure, and you can experiment with it. For
example:
   L. increment`[email protected] 1 :'5!:1<''u'''
5

Or, looking to see if we need A to do anything differently from f. we might
do this:
   '@.' -:S:0 increment`[email protected] 1 :'5!:1<''u'''
1 0 0 0 0

Now... how do we get f. to work on the verb as a whole, and yet still
substitute a part of the result?

One approach might be:
1) find the cases of @.
2) work from the inside out
2.a) for each @. find the inner part that's the gerund
2.b) for each represented verb,
2.b.1) convert from noun to verb,
2.b.2) use f. on that verb and then
2.b.3) convert back to noun, forming a new gerund
2.c) plug the whole thing into (a copy of) the original structure
3) finally, convert the whole atomic representation back to a verb and use
f. on that.

That's a bit complex to describe, and it would be similarly complex to
implement. But I'm sure you could do it.

Another approach, only slighly different, would be to find a series of
otherwise unused names, extract the gerunds for the @. instance and assign
each to one of those unused names (fixing its components in the process).
It's still the same algorthm, but maybe the use of those names would make
it easier to debug and reason about.

Thanks,

-- 
Raul

On Tue, Jul 29, 2014 at 10:05 PM, David Lambert <[email protected]>
wrote:
> Suppose I have a recursive verb
>
>    ([: $: >:)`]@.(3 < |)
>
> And I want to name the components
>
>    increment =: [: $: >:
>    result =: ]
>    choose =: 3 < |
>
>    increment`[email protected] f.
> 3 : '[: $: >: y' :(4 : 'x [: $: >: y')`]@.(3 < |)
>
> J carefully isolated recursion to the named verb
> Thus I really want to, in symbolic language, Map f.
>
>    (increment f.)`(result f.)@.(choose f.)
> ([: $: >:)`]@.(3 < |)
>
> Or in this case, simply
>
>    (increment f.)`[email protected] f.
> ([: $: >:)`]@.(3 < |)
>
> Is there a way to map f. ?  I tried literals with Define (5!:0) but of
> course I'd need to construct a complicated boxed structure.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to