You can express this tacitly like this:
   f2=: 1:`[`]}
   3 5 7 f2 10#0
0 0 0 1 0 1 0 1 0 0

From the dictionary page for m}
http://www.jsoftware.com/help/dictionary/d530n.htm

If m is a gerund, one of its elements determines the index argument to
the adverb } , and the others modify the arguments x and y :
x (v0`v1`v2)} y         ↔       (x v0 y) (x v1 y)} (x v2 y)
(v0`v1`v2)} y   ↔       (v1 y)} (v2 y)
(v1`v2)} y      ↔       (v1 y)} (v2 y)

On Sun, Apr 10, 2011 at 2:47 AM, Steven Taylor <[email protected]> wrote:
> f=:13 : '1 (x)}y$0'
>    3 5 7 f 10$0
> 0 0 0 1 0 1 0 1 0 0
> (correct)
>
> but
>   f2=:1([)}0$~]
>   3 5 7 f2 10
> 0 1 0 0 0 0 0 0 0 0
> I can see that there are some challenges from the boxed notation returned
> for f2... but wondered if there was a way to achieve this tacitly.  I'm
> guessing, but f looks like it is less efficient because it resolves to 4:1
> (x)}y$0.  i.e. interpret a string on-the-fly.
>
> thanks,
> -Steven
> ----------------------------------------------------------------------
> 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