Abdulaziz Ghuloum wrote:
A few questions:
1. You're not handing left/right associativity, right?
Eduardo Cavazos wrote:
Eh... can you give an example? Or, does this help to clarify? :
> (infix '(a + b - c))
(- (+ a b) c)
Abdulaziz Ghuloum wrote:
What I mean is:
(infix '(a + b + c + d))
=> (+ (+ (+ a b) c) d)
because + is left associative, while
(infix '(a ^ b ^ c ^ d))
=> (^ a (^ b (^ c d)))
because ^ is right-associative.
Your code handles all operators as if they were all left associative.
The URL you gave explains how to handle right associative operators.
Ahem.... I am so busted! :-) I would have known what you meant had I
read the page more carefully... I took a look at the decision table on
that page and implemented the first version off of that alone. I see the
extra details now... :-)
OK, here's a version with support for right-associative '^':
http://proteus.freeshell.org/_shunting-yard-e.scm
Ed