Abdur-rahmaanJ / greenberry

A one-line statement language with grammar and infinite look-ahead
https://abdur-rahmaanj.github.io/greenberry/
Apache License 2.0
50 stars 39 forks source link

substitute py's eval for a complete postfix evaluater #13

Closed Abdur-rahmaanJ closed 5 years ago

KushalVijay commented 5 years ago

I have gone through the documentation and Since i am a beginner, i did not understood in which file i have to make changes i.e. write code for " postfix evaluation". Please help

Abdur-rahmaanJ commented 5 years ago

well if i give you

2+3-5*7

can you write a python program to evaluate it? if you can, i'll guide you where to insert it!

KushalVijay commented 5 years ago

Yes! I can do this . I will first convert the infix expression to postfix ,then evaluate the postfix expression to calculate the answer. This can be done with the help of Stacks. Please provide me the workplace i.e. where to code it out. One more question,Is it mandatory to implement it in python ,can i do in C++ ? If it is mandatory , I have no issues,ignore the above lines then.

Regards Kushal Vijay

Abdur-rahmaanJ commented 5 years ago

in python. when you code it, i'll tell you where to put 👌

KushalVijay commented 5 years ago

Yes,I have written the code and its running properly . Now please guide me where to put it,then i will send you a pull request.

KushalVijay commented 5 years ago

But postfix to infix evaluation is only valid for expression having digits between 0 to 9. For higher numbers the original expression should have separator like space between all elements (operators and operands) of given expression.

Abdur-rahmaanJ commented 5 years ago

nooo solve this as that's what is meant by evaluating 1+2-5*8/4

KushalVijay commented 5 years ago

Yes Sir, my code can solve this expression easily .Let me pull a request ,then you can review it if there is any issue then let me know . Is it ok?

Abdur-rahmaanJ commented 5 years ago

ok fine, you can put a utils file and then put it in a function

KushalVijay commented 5 years ago

Sorry ,for the late response.Please review the pull request . For the example above you have given me ,there is an ambiguity ,for correct answer, the expression should be like 1+2-(5*8)/4=-7 Thankyou

Abdur-rahmaanJ commented 5 years ago

gave just a basic, mine is btw =- or =+ etc not part of eval

Abdur-rahmaanJ commented 5 years ago

near closing issue