Find Jobs
Hire Freelancers

PHP convert operators to function calls - Polish notation algorithm

$30-250 USD

已取消
已发布大约 8 年前

$30-250 USD

货到付款
I need you to develop a PHP function, which implements some variant of the Polish notation algorithm or Reverse Polish Notation algorithm, whichever is better suitable (see wikipedia for detais). The function will take the $formula variable as parameter, and it will parse it to the Polish notation, and then it will construct function calls instead of operators. For example, the input variable will be like this: $formula="12+4*x+(11/(3+5*y))*exp(10;2)-3" The following operations must be converted to function calls: a + b ... PLUS(a;b) a - b ... MINUS(a;b) a * b ... MULTIPLY(a;b) a / b ... DIVIDE(a;b) a > b ... GT(a;b) a < b ... LT(a;b) a >= b ... GE(a;b) a <= b ... LE(a;b) a = b ... EQ(a;b) a != b ... NE(a;b) a && b ... AND(a;b) a || b ... OR(a;b) fn(...) ... fn(...) - keep functions as functions, but remember to process the function arguments Note that * and / have higher priority than + and -, Note that comparison operators like < and > have low priority than + - * / Note that && has higher priority than ||, and both these have higher priority than everything else. Example results: Formula like "10+5" will be converted to "PLUS(10;5)". Formula like "10+9*xyz-5*exp(x+2;3)" will be converted to: MINUS(PLUS(10;MULTIPLY(9;xyz));MULTIPLY(5;EXP(PLUS(x;2);3))). Formula like "a>b+3" will be converted to "GT(a;PLUS(b;3))". Formula like "(10*(x+y))" will produce result MULTIPLY(10;PLUS(x;y)) - note the missing unnecessary parenthesis. Remember that "10+5" is the same as "10 + 5", and also "func(x)" is the same like "func ( x )" (notice added spaces in both examples) The result will never contain any of the original operands like +-*/etc, and will always be as a string with function calls. Remember that function name is always followed by open parentheses. If a number or character sequence is followed by something else, then it is considered to be operand, for example 10; 5; xyz; x12; abc; etc The PHP code must be short and clean. Add comments where necessary, not everywhere. Thank you for reading so far. Happy bidding! :)
项目 ID: 9624667

关于此项目

5提案
远程项目
活跃8 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
5威客以平均价$201 USD来参与此工作竞价
用户头像
Hello, I have been working in web development and web design since I began my career in IT following an IT degree and specializing in the web side. I enjoy working on websites and pages and the interaction with the clients to ensure that the website is as they specifically want it. I am a real problem solver and work in a methodical manner. I concentrate very hard in my work and like to ensure that I meet my deadlines and work to the clients timeframes. I would welcome the opportunity to discuss this with you further but if you have any questions before hand, please do not hesitate to contact me and I will be happy to answer anything you need to know related to my previous experience. Thank you ..!!
$222 USD 在3天之内
3.7 (7条评论)
2.4
2.4
用户头像
Can do it
$200 USD 在1天之内
0.0 (0条评论)
0.0
0.0
用户头像
I have code running with basic operations. I need time to modify and add logics operations. Contact me to explain me some things.
$250 USD 在2天之内
0.0 (0条评论)
0.0
0.0

关于客户

CZECH REPUBLIC的国旗
Sumperk, Czech Republic
5.0
70
付款方式已验证
会员自4月 5, 2009起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。