p j wrote:
> There's probably another name for this, but inspired
> from python terminolgy, a generator form of a function
> is one that is recursively called, but doesn't
> internally determine when to stop recursing. In
> Python and other languages, generators produce a lazy
> stream of values, where a "coroutine" will tell it
> when to stop. In J, a generator form is just a verb
> that returns the input for its next iteration.
>
This seems a useful idea. I think you can simplify your verbs, though.
> Look at the SIDE verb (which could be useful as an
> Evoke Gerund built in option). SIDE takes a gerund
> left argument and boxed right arguments and returns a
> boxed list of the same shape as y, the result of x0
> y0 ; x1 y1 ; ... xn yn (where x0, x1,... xn are verbs)
>
> SIDE =: 4 : 0
> a=. 0$0
> for_i. i.(#x.) do.
> a=. a , ((i_index{x.)`: 6) &.> i_index{y.
> end.
> )
>
How about
side=:4 : '<x `:6 >y'"0
>:`<: side 1;2
+-+-+
|2|1|
+-+-+
For your AND verb, you probably want to use prefixes and the power operator.
Best wishes,
John
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm