There is a verb called rt ('Restrained Take') in mt addon (in struct.ijs
file). It supports negative and/or infinite indexing, and is very similar to
yours.
--
Regards,
Igor
On 01/02/2018 5:53 AM, Pascal Jasmin wrote:
> seems better than what I've been doing,
>
> take
> (*@[ * |@[ <. #@:]) {. ]
>
>
>
> $ 2 take i.0
> 0
>
> take =: ];.0 :: (i.@(0"_) )
>
> $ 2 take i.0
>
> 0
>
>
> it loses negative indexing though, so
>
> take =: (];.0)`(];.0)`(] {.~ _1: * |@[ <. #@:])@.(*@[)^:(0 < #@])
>
> _7 take i.6
> 0 1 2 3 4 5
> _3 take i.6
> 3 4 5
>
> _3 take i.0
>
>
> 3 take i.2 2
> 0 1
> 2 3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm