[Jprogramming] Choosing k items out of n
R.E. Boss
r.e.boss at planet.nl
Sun Aug 3 04:11:06 HKT 2008
A minor improvement:
chs=: 4 : ';(,/@:(([,. ]+ <:)"0 _) )&.>/ |. 0((,.&.>@{)`[`])} <@i."0
(>:y-x)+i.x'
to force a 2-cell for x=1 :
1 chs 3
0
1
2
2 chs 3
0 1
0 2
1 0
1 2
2 0
2 1
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: programming-bounces at jsoftware.com [mailto:programming-
> bounces at jsoftware.com] Namens Raul Miller
> Verzonden: zaterdag 2 augustus 2008 17:06
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] Choosing k items out of n
>
> On Sat, Aug 2, 2008 at 1:49 AM, R.E. Boss <r.e.boss at planet.nl> wrote:
> > chs=: 4 : ';(,/@:(([,. ]+ <:)"0 _) )&.>/ |.<@i."0 (>:y-x)+i.x'
>
> That's beautiful.
>
> I hope you do not mind if I re-express this slightly:
> cs=: ;@(,/@:(([ ,. <:+])"0 _)&.>/)@(i.&.>@{. 1+i. at -)
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list