For(x) declares the given symbol as locally bound variable in the
scope of the parent call. For example, f(a, For(x), b) declares
as a locally bound variable that may be used within the expressions
and . The interpretation of the variable is left to the
parent operator .
Called with a tuple of symbols, For(Tuple(x, y, z)), each symbol
becomes a locally bound variable.
Called with several arguments, for example For(x, a, b, c), the additional parameters
specify information about the range of . The interpretation of the parameters is up to the parent operator . Most operators recognize For() with two additional parameters as
specifying an iteration range: for example, Sum(Factorial(n), For(n, 2, 10)) gives . (When For(n, a, b) is used in this sense, the endpoints
and
must be integers or possibly
and/or
where an infinite sequence makes sense. The iteration sequence is empty if .)
There are various exceptions. For example, Integral understands two
parameters as representing the endpoints (not necessarily integers)
of a directed line segment to integrate over: Integral(Cos(x), For(x, Neg(Pi), Pi)) becomes . Derivative takes one or two parameters denoting the evaluation point and optionally the order of differentiation: Derivative(Sin(x), For(x, y)) becomes
and Derivative(Sin(x), For(x, y, 2)) becomes .
Definitions:
Fungrim symbol | Notation | Short description |
---|---|---|
Sum | Sum | |
Factorial | Factorial | |
Infinity | Positive infinity | |
Integral | Integral | |
Cos | Cosine | |
Pi | The constant pi (3.14...) | |
Derivative | Derivative | |
Sin | Sine |
Source code for this entry:
Entry(ID("43cc72"), SymbolDefinition(For, Ellipsis, "General-purpose generator"), Description(SourceForm(For(x)), "declares the given symbol as locally bound variable in the scope of the parent call. For example,", SourceForm(f(a, For(x), b)), "declares", x, "as a locally bound variable that may be used within the expressions ", a, "and", b, ". The interpretation of the variable is left to the parent operator", f, "."), Description("Called with a tuple of symbols,", SourceForm(For(Tuple(x, y, z))), ", each symbol becomes a locally bound variable."), Description(" Called with several arguments, for example ", SourceForm(For(x, a, b, c)), ", the additional parameters", a, b, c, "specify information about the range of", x, ".", "The interpretation of the parameters is up to the parent operator", f, ". Most operators recognize ", SourceForm(For()), "with two additional parameters as specifying an iteration range: for example, ", SourceForm(Sum(Factorial(n), For(n, 2, 10))), "gives", Sum(Factorial(n), For(n, 2, 10)), ".", "(When", SourceForm(For(n, a, b)), " is used in this sense, the endpoints", a, "and", b, "must be integers or possibly", Equal(a, Neg(Infinity)), "and/or", Equal(b, Infinity), "where an infinite sequence makes sense. ", "The iteration sequence is empty if", Less(b, a), ".)"), Description(" There are various exceptions. For example,", SourceForm(Integral), "understands two parameters as representing the endpoints (not necessarily integers) of a directed line segment to integrate over: ", SourceForm(Integral(Cos(x), For(x, Neg(Pi), Pi))), "becomes", Integral(Cos(x), For(x, Neg(Pi), Pi)), ". ", SourceForm(Derivative), "takes one or two parameters", "denoting the evaluation point and optionally the order of differentiation:", SourceForm(Derivative(Sin(x), For(x, y))), "becomes", Derivative(Sin(x), For(x, y)), "and", SourceForm(Derivative(Sin(x), For(x, y, 2))), "becomes", Derivative(Sin(x), For(x, y, 2)), "."))