Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2128

Strange behavior with comment

From Virgil Stokes <vs@it.uu.se>
Newsgroups comp.soft-sys.math.mathematica
Subject Strange behavior with comment
Date 2011-05-06 11:22 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iq0llp$2n0$1@smc.vnet.net> (permalink)

Show all headers | View raw


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?



Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Strange behavior with comment Virgil Stokes <vs@it.uu.se> - 2011-05-06 11:22 +0000

csiph-web