Find Jobs
Hire Freelancers

a parser and evaluator for boolean formulae.

$15-20 USD

Completed
Posted about 22 years ago

$15-20 USD

Paid on delivery
Write a parser and evaluator for boolean formulae. You are given the following datatype: datatype formula_type=ATOM of string | NOT | AND | OR; Your program will take 2 inputs, namely the formula and the Boolean variables' assignments as two lists. The formula will be stored as a list of formula_type, and Boolean variable assignments will be stored as a list of string and bool pairs. For example: val formula1=[(ATOM "p"), OR, (ATOM "q"), AND, NOT, (ATOM "p")]; represents the Boolean formula: p OR q AND NOT p val assign1=[("p", false), ("q", true)]; represents that p is FALSE and q is TRUE. Since there is no parenthesis only operator precedences will be used to determine the order of the evaluation. NOT has the highest precedence, followed by AND, then OR, which has the lowest precedence. Therefore, for the above example is equivalent to the fully parenthesized expression (p OR (q AND (NOT p))). (This expression evaluates to TRUE.) Associativity of the binary operators is left to right. Your main function should be named as eval and should take two lists as its inputs, a formula and an assignment and return true or false. The function call eval(formula1,assign1); should return true. If there is either a syntax error in your formula or an assignment for a variable in the formula passed to eval doesn't appear in the assignment list or vice versa, your program is not required to work properly. (Essentially, we will ONLY test your program with valid inputs. Only worry about your program running properly in these cases. It is okay if your program crashes given invalid input.) ## Deliverables Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. Complete copyrights to all work purchased. ## Platform in ML language also provide an instruction for how to run the program and execute it
Project ID: 2844222

About the project

1 proposal
Remote project
Active 22 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
See private message.
$17 USD in 14 days
5.0 (2 reviews)
1.0
1.0

About the client

Flag of UNITED STATES
United States
4.5
10
Member since Feb 20, 2002

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.