a question from Maple users
Antti Karttunen
antti.karttunen at gmail.com
Mon May 15 13:04:56 CEST 2006
Emeric Deutsch wrote:
> Dear Maple user seqfans,
>
> I'd like to be able to get for any n all the n-dimensional
> 0-1 vectors (2^n, of course). For a particular n, for example n=3, I
> can write the command
>
> [seq(seq(seq([u,v,w],u=0..1),v=0..1),w=0..1)];
>
> leading to [[0, 0, 0], [1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 0, 1],
> [1, 0, 1], [0, 1, 1], [1, 1, 1]]
>
> How can I avoid writing seq n times?
>
> I'd appreciate your help or the address of a Maple support group.
>
> Thanks,
> Emeric
>
Also related:
with(combinat, composition); # composition(n, k) gives ordered
partitions of integer n into k parts.
E.g. composition(4,2) returns [1,3],[2,2],[3,1] if I recall right,
or something similar. (But no [0,4] and [4,0] present... I have no Maple
installed now.)
I.e. those partitions correspond to the run lengths
of the corresponding binary vectors, where k different runs are present.
Yours,
Antti
More information about the SeqFan
mailing list