m*x + b // an expression f(x) = m*x + b // a function m = 3 b = 5 f(4) = m*4 + b ===> 3*4 + 5 = 17 public static double m = 3.0; public static double b = 5.0; public static double f(double x) { return m*x + b; // m and b are non-local references } f(x,m,b) = m*x + b // a different function (but same expression) f(4,5,6) = 5*4 + 6 public static double f(double x, double m, double b) { return m*x + b; // no non-local variables } b = 4 f(m, x) = m*x + b // a third function (still the same expression) public static double b = 4.0 public static double f(double x, double m) { return m*x + b; // b is a non-local reference } x*y + z // An expression. How many functions can we define using this expression? y=4, z=6 f1(x) = x*y + z // y,z are free variables z=6 f2(x,y) = x*y + z // z is a free variable f3(x,y,z) = x*y + z // no free variables y=2 f4(x,z) = x*y + z // y is free y=2 f5(z,x) = x*y + z // y is free // f4 and f5 are not the same function even though they // use the same expression with the same free variable f4(2,3) ===> 2*2 + 3 = 7 f5(2,3) ===> 3*2 + 2 = 8 anonymous versions of f1, f2, f3, f4, f5 y=4, z=6 (x) => x*y + z // y,z are free variables z=6 (x,y) => x*y + z // z is a free variable (x,y,z) => x*y + z // no free variables y=2 (x,z) => x*y + z // y is free (z,x) => x*y + z // y is free ((x,z) => x*y + z) (2,3) ===> 2*2 + 3 = 7 ((z,x) => x*y + z) (2,3) ===> 3*2 + 2 = 8