myCHcc[K_Integer] := Module[{CH}, CH = Drop[Tuples[{0, 1}, K], 1]]
myCHcc[4.4]
myCHccOLD[K_Integer] := Table[IntegerDigits[n, 2, K], {n, 1, 2^K - 1}];
myCHccOLD[4.4]
Hi all,
??am reading the core language
http://www.wolfram.com/learningcenter/tutorialcollection/
where there is an example on page 80.
In the above code,
myCHccOLD[4.4]
is alright. but
myCHccOLD[4.4]
runs into error. I expect the same out like
myCHccOLD[4.4]
What's the difference? I understand tha the two functions creat the same desired outputs. I am asking the differences between the pattern matching on the inputs.
And further,
myCHcc[K_ /; K > 2 ] := Module[{CH}, CH = Drop[Tuples[{0, 1}, K], 1]]
myCHccOLD[K_ /; K > 2 ] :=
Table[IntegerDigits[n, 2, K], {n, 1, 2^K - 1}];
And using
myCHcc[K_ /; K > 2 ] := Module[{CH}, CH = Drop[Tuples[{0, 1}, K], 1]]
myCHccOLD[K_ /; K > 2 ] :=
Table[IntegerDigits[n, 2, K], {n, 1, 2^K - 1}];
myCHcc[1]
myCHccOLD[1]
does not give me
myCHcc[1]
myCHccOLD[1]
as the patern does not match the rule of K>2
How do I make sure that the input is an Interger also great 2 at the same time?
myCHcc[K_Integer /; K > 2 ] :=
Module[{CH}, CH = Drop[Tuples[{0, 1}, K], 1]]
Does not do that?