Can someone explain what is going on with the following ...
func[y_] := func[y] = (Print["Hello world !!!"];)
func[1]
Hello world !!!
func[2]
Hello world !!!
func[1] (*nothing printed*)
func[2] (*nothing printed*)
As I understand it () are used so the function remembers its values, but as you see when I repeat func[1], nothing.
If I take out the y in f[y], it prints. If I define the function as f[y_] := (...) (without f[y] = ), it prints.
I'm sure there is a simple explanation, any help is appreciated.
(expr;)will return Null regardless of whatexprevaluates to. – amr Jan 31 '13 at 02:49