One approach:

nt=:(!~ i.@>:)@^~&2

Less efficient:

ntt=:(0&, + ,&0)^:(2&^`1:)

(In both cases, it's about taking advantage of definitions, rather than
merely rearranging operations.)

I hope this helps,

-- 
Raul

On Sat, Aug 12, 2023 at 7:02 PM 'Nollaig MacKenzie' via Chat <
[email protected]> wrote:

> numtt=: 3 : '((,~ 0:) + (, 0:)) ^: (2^y) 1’
>
> calculates, for the possible truth-tables of y variables a list of the
> those which have 0 1s, 1 1, 2 1s …..
>
> e.g.
>
>     numtt 2
> 1 4 6 4 1
>
> numtt just produces the appropriate row of Pascal’s Triangle.
> It’s a trivial little verb, but I’m bothered by the fact that
> I can’t see a way to make it tacit.
>
> ----------------------------------------------------------------------
> 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