by cjebbs · 8y ago · 0 comments
It's the approach used in APL and J, and I've certainly found it far preferable to the current math notation standard.
if you're composing some function g : X --> Y with a function f : Y --> Z then
let x be some element of X.
then f g (x) = f(g(x)) = f(y), say, where y = g(x).
1+2x3+4x5 evaluates to 1+2x23 which in turn evaluates to 1+46 which is 47. In the normal way it would be 1+6+20 or 27.
(edit: messed up on the order of operations and added example from the book).
It's probably either because parsing operators with precedence wasn't really a solved problem in 1964 when Iverson first started working on APL, or because Iverson disagrees with the normal precedence rules. If you look at Notation of a tool of thought (also linked on HN in the recent past ), then there is this passage (when comparing APL with normal math notation):
> In the interpretation of composite expressions APL agrees in the use of parentheses, but differs in eschewing hierarchy so as to treat all functions (user-defined as well as primitive) alike, and in adopting a single rule for the application of both monadic and dyadic functions: the right argument of a function is the value of the entire expression to its right. An important consequence of this rule is that any portion of an expression which is free of parentheses may be read analytically from left to right (since the leading function at any stage is the "outer" or overall function to be applied to the result on its right), and constructively from right to left (since the rule is easily seen to be equivalent to the rule that execution is carried out from right to left)