3 ms·
Yes, but a * b + c is not normally interpreted as a * (b + c), in this text it is. 1+2x3+4x5 evaluates to 1+2x23 which in turn evaluates to 1+46 which is 47. I
by irishsultan 9y ago
Yes, but a * b + c is not normally interpreted as a * (b + c), in this text it is.
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).
- NPMaxwell 9y agoThat looked really weird to me too. Iverson is finessing the whole issue of order of operations by assuming there is no order of operations. To see what the issue is, see http://www.slate.com/articles/health_and_science/science/2013/03/facebook_math_problem_why_pemdas_doesn_t_always_give_a_clear_answer.html http://www.slate.com/articles/health_and_science/science/201..., where the author says that the CORRECT order of operations is PEMDAS and then uses "PEDMAS" in the same article. https://en.wikipedia.org/wiki/Order_of_operations https://en.wikipedia.org/wiki/Order_of_operations lists a variety of mnemonics that are inconsistent with standard current software. I'm amused that if you put 1-3^2 into the Google calculator, it will helpfully rewrite your equation as "1-(3^2)". I gather that the PEDMAS order of operations was an invention related to the development of an early software language and would have been very recent in 1971 when Iverson was writing.
- irishsultan 9y agoIt's not that PEDMAS was a new thing in 1971, if you look at the article about the timeline of Parsing (https://news.ycombinator.com/item?id=16856694 https://news.ycombinator.com/item?id=16856694) then you'll see that the earliest programming languages didn't have operator precedence, and that this annoyed users of those languages. 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)