2

If I write this piece of code in a textfield if(value < 4), my program will generate the following table

value    Output
 3        True
 5        False

The table will dynamically change in size depending on the conditions. The values 3 and 5 were randomly generated.

I'm stuck when it comes to more than one condition.

For example, when it comes to this if (value > 4 && value <= 10). Note: I have functions for each of these conditions: =, <, >, <=, >=, !=

How do I get it to give me a true value that is in the range and a false value?

Daniel Beck
  • 20,653
  • 5
  • 38
  • 53
B.shini
  • 21
  • 1
  • 4
    Show us the code of your functions please. – diiN__________ Feb 03 '16 at 07:18
  • 2
    Sounds like a homework assignment ;) – Gabe Feb 03 '16 at 07:25
  • So you're looking for the input ranges that result in either `true` or `false`? Which would be `true: range(-inf, 3), false: range(4, inf)` for the first example and `true: range(5, 10), false: range(-inf, 4), range(11, inf)` for the second? – Pieter Witvoet Feb 03 '16 at 14:16
  • You said that 3 and 5 were randomly generated, and were examples of values that both satisfied and did not satisfy a predicate with one condition.. OK, so why did you then not generate 3 and 5 randomly for your predicate that had two conditions? 3 and 5 also have the property that one does not satisfy the predicate and the other does. I can't figure out what you're actually asking here. – Eric Lippert Feb 03 '16 at 14:49

1 Answers1

0

Since I do not know how you've implemented it so far I would recommend you to have a look at this How to execute code that is in a string?

Then you would not have to worry about order of execution &&, parentheses etc. Just have the string compile and the runtime will solve your problem just like you would have written it in an console app

But if it is a homework assignment I guess you would have trouble explaining this solution!

Community
  • 1
  • 1
SJFJ
  • 657
  • 6
  • 18