Strange behavior with comment
- To: mathgroup at smc.vnet.net
- Subject: [mg118655] Strange behavior with comment
- From: Virgil Stokes <vs at it.uu.se>
- Date: Fri, 6 May 2011 07:22:34 -0400 (EDT)
The following gives an error,
m = 4;
k = 3;
IntegerPartitions[ m, {k}]; (* Get all integer partitions that are exactly of
length k *)
Permutations /@ %; (* Get all permutations of the integer partitions *)
Flatten[%, 1] (* Flatten the list *)
Apply[Multinomial, %, {1}] (* Apply Multinomial to each element of the list % *)
ns = Plus @@ %
Flatten::normal: Nonatomic expression expected at position 1 in Flatten[3,1]. >>
Flatten[3, 1]
However, if I remove the comment from the entry in the line before Flatten, then
it gives the correct results,
m = 4;
k = 3;
IntegerPartitions[m, {k}]; (* Get all integer partitions that are exactly of
length k *)
Permutations /@ %;
Flatten[%, 1] (* Flatten the list *)
Apply[Multinomial, %, {1}] (* Apply Multinomial to each element of the list % *)
ns = Plus @@ %
{{2, 1, 1}, {1, 2, 1}, {1, 1, 2}}
{12, 12, 12}
36
Why does this happen?