in case there’s not already an elegant solution to this,
maybe dyadic {: and }: could be made to do that?

   3 6 {: i. 8
3 4 5
   3 6 {: 'hi there'
the

and the usual behaviour with boxed control data

otoh, it’s restricting x to have a last axis of length 2
and what if it’s 3x2x2, say, and y has more than one
axis – apply two selections or one? –
so it had better been a conjunction lower C upper DATA

plus, one may easily achieve its effect by other means
such as chained {. and }. so maybe that would be
a waste of primitives

I guess I should stop there
still, I wonder how a selection of a subarray by offsets
(left/lower and right/upper) is done without using both {. and }.

I feel like it must be obvious but I’m blind to it


Am 20.05.21 um 15:22 schrieb Hauke Rehr:
> so this is what I came up with
> but it’s still missing the last bucket (9 5)
> and it doesn’t read as well as xash’s version
> I strongly expect one could do better than to
> {.+i.@-.@-/
> but I just don’t know how
> (let alone how to {~ < < of that better)
> 
> ff =: (<@{~ 2 <&<&({. + i.@-.@(-/))"1@:]\ 1 I.@, 0 = 2+/\ 2&((<->)/\))
> 
> 
> Am 20.05.21 um 14:20 schrieb Hauke Rehr:
>> correction: of course, it’s 2&((<->)/\)
>>
>> Am 20.05.21 um 14:15 schrieb Hauke Rehr:
>>> you can also use (2 (< - >)/\) instead of (}: (<+_1*>) }.)
>>> I think that way it’s going more in the “appreciated” direction :)
>>>
>>> Am 20.05.21 um 13:49 schrieb xash:
>>>> f=:((#~ 1&|.) ,&.> <;.1~) 0 1, 0= 2+/\ }: (<+_1*>) }.
>>>>
>>>> The first part assigns _1 to elements that are greater than the next one,
>>>> and 1 to elements that are less than the next one. Where _1 1 or 1 _1
>>>> occur, a new group starts. Thus 0= 2+/\.
>>>>
>>>> This gets us the starting indices for <;.1. Because the borders should be
>>>> included, we prepend each element that is before a group start `(#~ 1&|.)`
>>>> to that group `,&.>` (thus the unusual `0 1,` for the group starts).
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>>
>>
> 

-- 
----------------------
mail written using NEO
neo-layout.org

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to