"Is it possible to define f tacitly?"

J tacit programming is Turing complete; thus, any verb can be defined
tacitly.  It can be difficult sometimes but this case is easy... If one is
prepared to venture to the dark side.


   an=. <@:((,'0') ,&< ])

   NB. Dark side of the force...

   Cloak=. ((5!:1)@:<'Cloak')Cloak=. (0:`)(,^:)
   ( train=. (Cloak <'`:')&6 )  NB. `:6 verbalized
,^:(0:``:)&6

   v=. train@:({.@:(0&({::)) ; an@:>@:{:) f.


   v (+:`*:;i.5)
0 2 4 6 8


On Thu, Jan 29, 2015 at 1:20 PM, Joe Bogner <[email protected]> wrote:

> Is it possible to define f tacitly?
>
> f=: 3 : '({.@:>@:{.y)`:0 (>@:}.y)'
> f (+:`*:;i.5)
>
> 0 2 4 6 8
>
> It's meant to take the first gerund from a box that contains a list of
> gerunds and data to operate on
>
> It's an odd circumstance that needed it. I could probably rework the
> logic but now I'm curious if it can be done
>
> Some things I tried:
>
> a=:(+:`*:;i.5)
>
> f1=:{.@:>@:{.
>    f1 a
> ┌──┐
> │+:│
> └──┘
>
> f2=:>@:}.
>   f2 a
> 0 1 2 3 4
>
>
> Tried various version of combining f1 and f2 to no avail
>
> This works:
>
>    g`:0 f2 a [ g=. f1 a
> 0 2 4 6 8
>
> I'm thinking there might be a way to do it without the assignment?
> ----------------------------------------------------------------------
> 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