Mostly I try to avoid utility code, but this one looks really nice.

Thanks,

-- 
Raul


On Thu, Jul 23, 2015 at 4:18 PM, 'Pascal Jasmin' via Programming
<[email protected]> wrote:
> Y =: @:]
>
> can be useful typing/reading productivity boost for tacit code
>
> Y =: (&{::)(@:])
>
> is a different useful version where 0 Y is equivalent to (0 {:: }).  It picks 
> out the first element of Y and unboxes it.  1 Y is equivalent to (1 {:: ])
>
> BEHOLD!
>
> Y =: 1 : 'if. 3 = 4!:0 < ''u'' do. u@:] else. m {:: ] end.'
> X =: 1 : 'if. 3 = 4!:0 < ''u'' do. u@:[ else. m {:: [ end.'
>
>   +/ Y
> +/@:]
>
>  (0 Y - 1 Y + 2 Y) 6 2 3
> 1
>
>  (0 Y - 1 Y + 2 Y)
> (0 {:: ]) - (1 {:: ]) + 2 {:: ]
>
>
>  3 (+:X * 0 Y - 1 Y + 2 Y)  6 2 3
> 6
>
>
> If the u parameter to Y is a verb, use the first definition (@:]).  Otherwise 
> use the 2nd (get index)
> ----------------------------------------------------------------------
> 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