[Jprogramming] recursive agenda with named components

David Lambert b49p23tivg at stny.rr.com
Wed Jul 30 19:31:22 UTC 2014


Like others, I'm learning to use j effectively on tiny smart phone 
display.  I had considered preprocessing source with m4 to produce long 
j sentences. Considering m4 helped me finally understand eval.  Eval 
directly converts literals into j code.  Now I have another option to 
compose j.
Thank you all.

    Eval =: 1 : 'a: 1 : m'
    increase =: '([: $: >:)'
    result =: '(])'
    choose =: '(3 < |)'
    (increase,'`',result,'@.',choose)Eval
([: $: >:)`]@.(3 < |)

    (increase,'`',result,'@.',choose)Eval 1
4

    NB. I have not found m4 for android.

> Date: Tue, 29 Jul 2014 22:43:21 -0700
> From: "'Pascal Jasmin' via Programming"<programming at jsoftware.com>
> To:"programming at jsoftware.com"  <programming at jsoftware.com>
> Subject: Re: [Jprogramming] recursive agenda with named components
> Message-ID:
> 	<1406699001.37116.YahooMailNeo at web122605.mail.ne1.yahoo.com>
> Content-Type: text/plain; charset=iso-8859-1
>
> ? ?eval =:?1 : ' a: 1 :  m'?
> ? ?A =: 1 : (,'u')
> ? ?eval2ger =:?3 : 'a=. A for_i.  y do. a=.  (>i) eval a `  end. '''' a'
>
> a partial way of doing it,
>
> ? (eval2ger@:((<' f.') ,~ each ]) 'increment';'result')@.choose f.
> ([: $: >:)`]@.(3 < |)
>
> eval2ger takes a boxed list of string expressions, and turns them into a gerund expression. ?The other part "automates" adding f. inside the expression.
>
> ________________________________
> From: David Lambert<b49p23tivg at stny.rr.com>
> To: programming<programming at jsoftware.com>  
> Sent: Tuesday, July 29, 2014 10:05:54 PM
> Subject: [Jprogramming] recursive agenda with named components
>
>
> Suppose I have a recursive verb
>
> ? ? ([: $: >:)`]@.(3 < |)
>
> And I want to name the components
>
> ? ? increment =: [: $: >:
> ? ? result =: ]
> ? ? choose =: 3 < |
>
> ? ? increment`result at .choose  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.)`result at .choose  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.



More information about the Programming mailing list