Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Postfix 2 Prefix

Status
Not open for further replies.

VektorX

Programmer
Feb 6, 2004
1
CA
Hey guys and gals,
Got a problem with my conversion tool. I am converting a postfix expression to a prefix expression via


p2p([12,13,+,4,1,-,/], etc ...)

which uses a stack.

I've gotten to the point where I almost get a correct answer ie:

X = [[/,[+,12,13],[-,4,1]]]
Yes
?-

Ok, so this whole list "[/,[+,12,13],[-,4,1]]" is the top element of the stack, which is returned if successfull

My question is, how can I just have it so it's

X = [/,+,12,13,-,4,1]
Yes

Notice how all lists were sorta "merged" and pushed onto the stack in reverse order? Is there an easy way to do that? Thanx :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top