Hi Hoa,
Seems like you are new to the Wolfram Language / Mathematica. The code you shared just defines a function named ShowCA
. You have to evaluate an expression involving the function and its arguments. Simple example
Define a function named myFunction
that takes a single argument and evaluates to it's square.
myFunction[arg_] := arg^2
Evaluate
myFunction[4]
(* 16 *)
I don't have the book you are referring to but I am guessing it is trying to do something like this
ClearAll@animateCA;
animateCA[rule_Integer, steps_Integer,
colorRules : List[__Rule] : {0 -> LightBlue, 1 -> Red}] :=
Animate[
ArrayPlot[
ArrayPad[CellularAutomaton[rule, {{1}, 0}, {n, All}],
{{0, steps - n}, {steps - n, steps - n}}],
ColorRules -> colorRules],
{n, 0, steps, 1}]
Then you can evaluate
animateCA[30, 75]
Different rule and colors
animateCA[73, 75, {0 -> LightGreen, 1 -> Magenta}]
Note: I adapted the code from this answer on MSE.