Fun

Input: Fun(x, x**2)
xx2x \mapsto {x}^{2}

Defines a univariate function mapping the symbol given as the first argument to the expression in the second argument. The symbol xx representing the dummy variable becomes locally bound within the function expression. This function is improper; that is, it does not belong to a particular function space.

Input: Fun(x, x**2)(42)
(xx2)(42)\left(x \mapsto {x}^{2}\right)(42)

Calling a named function.

Input: Where(f(42), Def(f, Fun(x, x**2)))
f(42)   where f(x)=x2f(42)\; \text{ where } f(x) = {x}^{2}

Calling a function assigned to a variable.

Input: Fun(Tuple(x, y), 2*x+3*y)
(x,y)2x+3y\left(x, y\right) \mapsto 2 x + 3 y

Defines a bivariate function. The symbols x and y become locally bound.

Input: Fun(Tuple(x), x**2)
(x)x2\left(x\right) \mapsto {x}^{2}

Equivalent to defining a univariate function.

Input: Fun(Tuple(x_(i), For(i, 1, n)), Sum(i * x_(i), For(i, 1, n)))
(x1,x2,,xn)i=1nixi\left(x_{1}, x_{2}, \ldots, x_{n}\right) \mapsto \sum_{i=1}^{n} i x_{i}

Defines a multivariate function with arity nn. In this special case, the variable binding x_ in the scope of the Tuple call propagates through to the Fun operator.

Input: Where(g(c_(2), c_(3)), Def(c_, Fun(n, n**2+n+1)), Def(g, Fun(Tuple(x, y), (x+y)*(x-y))))
g ⁣(c2,c3)   where cn=n2+n+1,  g ⁣(x,y)=(x+y)(xy)g\!\left(c_{2}, c_{3}\right)\; \text{ where } c_{n} = {n}^{2} + n + 1,\;g\!\left(x, y\right) = \left(x + y\right) \left(x - y\right)

Defining and calling named improper functions in the context of a Where-expression.

Last updated: 2020-03-06 00:22:16