English employs various symbols to punctuate a sentence,
to indicate the order in which its phrases are to be interpreted.
The teacher said he was stupid.
The teacher, said he, was stupid.
Math also employs various devices (primarily parentheses) to specify
order of interpretation or, as it is usually called, order of execution.
It also employs a set of rules for an unparenthesized phrase,
including a hierarchy amongst functions. For example, power
is executed before times, which is executed before addition.
J uses parentheses for punctuation, together with the
following rules for unparenthesized phrases:
The right argument of a verb is the value of
the entire phrase to its right.
Adverbs are applied first. Thus, the phrase a */ b
is equivalent to a (*/) b, not to a(*/b).
a=:5 b=:3 (a*a)+(b*b) 34 a*a+b*b 70 a*(a+(b*b)) 70 (a+b)*(a-b) 16 a (+*-) b 16
The last sentence above includes the isolated phrase +*-
which has thus far not been assigned a meaning. It is called a
fork, and is equivalent to the sentence that
A fork also has a monadic meaning, as illustrated for the
c=:2 3 4 5 6 (+/ % #) c The verb # yields the number of items in its argument 4 (+/c)%(#c) 4
|4.1||In math, the expression 3x4+4x3+5x2 is called a polynomial.
x=: 2 (3*x^4)+(4*x^3)+(5*x^2)
to evaluate the polynomial for the case where x is 2.
|4.2||Note that the hierarchy among functions used in math
is such that no parentheses are necessary in writing a polynomial.
Write an equivalent sentence using no parentheses.
Answer: +/3 4 5 * x ^ 4 3 2
or (first assigning names to the coefficients 3 4 5
and the exponents 4 3 2), as: +/c*x^e