Based on this comment ( https://news.ycombinator.com/item?id=46352389 ), I think I understood the missing first paragraph: If you have the expression 1+2*3 you have three elements with two operands. You need to choose a rule to pick one of them first. In mathematics, the rule is "*/ then +-" and then from left to right. This means that usually first you do 2*3, then 1+. But what if you do want to make 1+2 first? Ther…
If we actually (as the title seems to imply) invert the parentheses, then for your example we get 1+2)*(3 . Now all you need are the opening and closing parentheses at the start and end, and we're back to normal.
Inverse Parentheses
41–50 of 67 posts
Re: Inverse Parentheses
#42Am I stupid if I don't get it? What is the intended end state? What does "ungroup operands" mean?
For instance, using "] e [" as the notation for reverse parentheses around expression e, the second line showing reverse parenthese simplification, third line showing the grouping after parsing, and the fourth line using postfix notation:
A + B * (C + D) * (E + F)
=> A + B * (C + D) * (E + F)
=> (A + (B * (C + D) * (E + F)))
=> A B C D + E F + * * +
A + ] B * (C + D) [ * (E + F)
=> A + B * C + D * (E + F)
=> ((A + (B * C)) + (D * (E + F)))
=> A B C * + D E F * + +
So what ungrouping would mean is to undo the grouping done by regular parentheses.
However, this is not what is proposed later in the article.
Possibilities include reversing the priority inside the reverse parentheses, or lowering the priority wrt the rest of the expression.
Re: Inverse Parentheses
#43Earlier quoted context omitted.
If we actually (as the title seems to imply) invert the parentheses, then for your example we get 1+2)*(3 . Now all you need are the opening and closing parentheses at the start and end, and we're back to normal.
Yeah, that seems a much more robust formulation of the whole thing. Flip all parens and enclose the whole string in more parens.
(1+2)*(3)
which is (as GP notes), equivalent to "normal", ie what we do today: (1+2)*3
Right?Re: Inverse Parentheses
#44I was hoping the parentheses themselves would be flipped. Like this: > 1 + )2 * 3( (1 + 2) * 3
Same. That said if you try to use that with ordinary parentheses usage it would get ambiguous as soon as you nest them
Re: Inverse Parentheses
#45Based on this comment ( https://news.ycombinator.com/item?id=46352389 ), I think I understood the missing first paragraph: If you have the expression 1+2*3 you have three elements with two operands. You need to choose a rule to pick one of them first. In mathematics, the rule is "*/ then +-" and then from left to right. This means that usually first you do 2*3, then 1+. But what if you do want to make 1+2 first? Ther…
I don't think that's even well-defined if you have arbitrary infix operators with arbitrary precedence and arbitrary associativity (think Haskell). If $, & and @ are operators in that order of precedence, all right-associatve. Using your notation, what is: a & > @ d If $ is reduced below & but above @ then it's the same as: ((a & b) $ c) @ d If it's reduced below both & and @ then it becomes: (a & b) $ (c @ d) I thin…
a & )b $ c) @ d would mean ((a & b) $ c) @ d.
a & (b $ c( @ d would mean a & (b $ (c @ d)).
Combining both, a & )b $ c( @ d would mean (a & b) $ (c @ d).
;)
Re: Inverse Parentheses
#46Based on this comment ( https://news.ycombinator.com/item?id=46352389 ), I think I understood the missing first paragraph: If you have the expression 1+2*3 you have three elements with two operands. You need to choose a rule to pick one of them first. In mathematics, the rule is "*/ then +-" and then from left to right. This means that usually first you do 2*3, then 1+. But what if you do want to make 1+2 first? Ther…
Gerald Jay "Jerry" Sussman from Scheme and SICP fame (and others) would tell you there's also the prefix notation (but ofc only infix makes TFA valid: prefix or postfix makes it mostly moot). "3 x 4 x 7 x 19" only looks natural to us because we've been taught that notation as toddlers (well, ok, as young kids).
But "x 3 4 7 19" is just as valid (Minksy and having to understand someting in five different ways or you don't understand it etc.).
P.S: also your comment stinks of AI to me.
Re: Inverse Parentheses
#47Re: Inverse Parentheses
#48Based on this comment ( https://news.ycombinator.com/item?id=46352389 ), I think I understood the missing first paragraph: If you have the expression 1+2*3 you have three elements with two operands. You need to choose a rule to pick one of them first. In mathematics, the rule is "*/ then +-" and then from left to right. This means that usually first you do 2*3, then 1+. But what if you do want to make 1+2 first? Ther…
If we actually (as the title seems to imply) invert the parentheses, then for your example we get 1+2)*(3 . Now all you need are the opening and closing parentheses at the start and end, and we're back to normal.
A real Wesley Crusher moment.
Re: Inverse Parentheses
#49Am I stupid if I don't get it? What is the intended end state? What does "ungroup operands" mean?
https://lobste.rs/s/qoqfwz/inverse_parentheses#c_n5z77w
which should provide the answer.