Nice work,  especially persuading 13 : to return a tacit version.  
I had reached the same solution as Pascal Jasmin’s,  so not worth a comment in 
itself.

However, it is just about worth pointing out that the filtering approach gets 
expensive for larger values of y;  eg 3 Smps 20 would entail filtering 2^20 
rows to obtain 1140. In that case,  I reckon it’s better to use the 1s indices 
provided by, eg, 3 comb 20 .  
comb is in addons/stats/base/combinatorial .

In case it matters!

Mike

Sent from my iPad

> On 31 Jul 2021, at 20:48, Raul Miller <rauldmil...@gmail.com> wrote:
> 
> That's a bit tricky in this case, but it can be done:
> 
> First off, the problem:
> 
>      13 : '(#~x=+/"1)f y' NB. select row
> 4 : '(#~x=+/"1)f y'
> 
> But we can work around this by giving 13 : a variant expression:
> 
>     13 : 't#~x=+/"1 t=.f y'
> [ (] #~ [ = [: +/"1 ]) [: f ]
> 
> And, in this example, we can turn this into a hook through inspection:
>   Smps=: (] #~ [ = [: +/"1 ]) f
> 
> This could be simplified further, of course:
>   2 ((] #~ (= +/"1)) f) 6
> and
>   2 (((= +/"1) # ]) f) 6
> 
> do the same computation.
> 
> I hope this helps,
> 
> -- 
> Raul
> 
>> On Sat, Jul 31, 2021 at 12:43 PM Srdjan Stipic <srdjan.sti...@gmail.com> 
>> wrote:
>> 
>> You can use “13 : ‘…’” construct to get tacit verb.
>> 
>> On Sat 31. Jul 2021 at 18:00, 'Pascal Jasmin' via Programming <
>> programm...@jsoftware.com> wrote:
>> 
>>> 2 ([ (] #~ [ = +/"1@:]) f@]) 6
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> On Saturday, July 31, 2021, 11:52:10 a.m. EDT, 'Bo Jacoby' via Programming
>>> <programm...@jsoftware.com> wrote:
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Consider this code
>>> 
>>>   f=.#&2#:[:i.2&^ NB. 0-1 rows
>>> 
>>> 
>>> 
>>> 
>>>   Smps=. 4 : '(#~x=+/"1)f y' NB. select rows
>>> 
>>>   2 Smps 6 NB. for example
>>> 0 0 0 0 1 1
>>> 
>>> 0 0 0 1 0 1
>>> 
>>> 0 0 0 1 1 0
>>> 
>>> 0 0 1 0 0 1
>>> 
>>> 0 0 1 0 1 0
>>> 
>>> 0 0 1 1 0 0
>>> 
>>> 0 1 0 0 0 1
>>> 
>>> 0 1 0 0 1 0
>>> 
>>> 0 1 0 1 0 0
>>> 
>>> 0 1 1 0 0 0
>>> 
>>> 1 0 0 0 0 1
>>> 
>>> 1 0 0 0 1 0
>>> 
>>> 1 0 0 1 0 0
>>> 
>>> 1 0 1 0 0 0
>>> 
>>> 1 1 0 0 0 0
>>> 
>>> 
>>> 
>>> I want to rewrite it tacit
>>>   Smps=.((=+/)"1 f)#f@]
>>> This works but is without the hook, so "f" is repeated.
>>> How to write the hook tacitly?
>>> I believe that this is easy, but I am stuck.
>>> Thank you!
>>> Bo.
>>> 
>>> 
>>> 
>>> 
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>> 
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> 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