Back: Programming
Previous: Syntax of = := ==
Next: Contexts: local vs. global variables
k[x_] := ( a=2x+1 ; b=x^2 ; c=3x ; a b c )
W = k[2];
{ a, b, c, W }
{5, b, 3, 120}
small[x_] := If[ Abs[N[x]] < 1, True, False, dunno ]
Map[ small, {0, 0.5, 1, 5, XXX, Pi/4} ]
{True, True, False, False, dunno, True}
small[x_] := If[ Abs[N[x]] < 1,
Print[x, " is small."] ; a=0; True,
Print[x, " isn't small."] ; a=99; False,
Print[x, " is ???."] ; a=-17; dunno]
Map[ small, {0, 0.5, 1, XXX, Pi-3} ]
0 is small.
0.5 is small.
1 isn't small.
XXX is ???.
-3 + Pi is small.
{True, True, False, dunno, True}