question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Eval math operations

See original GitHub issue

We need to add a tool to eval pure math and bool operations.

For example, we can check that 1 + 2 is 3 and "a" * 2 is "aa" We need it because sometimes we restrict to use several datatypes in some places: like float in dict keys. But, people can actually write float numbers as math expressions: 0.1 + 5 * 10 ^ 2. We have to parse this information and return result nodes.

Algorithm:

  • if all elements are constants - return the evaluated result
  • if anything fails - return the wrapping node itself

Refs #861

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
sobolevncommented, Dec 6, 2020

Sounds like a good idea. Let’s try it!

1reaction
Jrryycommented, Oct 26, 2020

It is a complicated subject. People usually do not code such operations, but in certain situations it makes the code clearer. For example, if you want a variable to hold an amount of days in seconds, you could write days = x*24*60*60. There are constant operations, but you can clearly see what is stored in this variable.

I suppose I could explore the usage of some of the modules in the project for the purpose of auto improving the code, and use noqas in the cases in which the user would not want the code to be modified.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expression Evaluation with Basic Operations - CK12-Foundation
To evaluate a variable expression means to find the value of the expression for given values of the variables. To evaluate, substitute the...
Read more >
php - calculate math expression from a string using eval
It must contain at least two operands and an operator. Operands' name could be in upper or lower case. By now, math functions...
Read more >
Arithmetic Expression Evaluation - GeeksforGeeks
Arithmetic Expression Evaluation · Convert the expression in Reverse Polish notation( post-fix notation). · Push the operands into the stack in ...
Read more >
Python eval(): Evaluate Expressions Dynamically - Real Python
Python's eval() allows you to evaluate arbitrary Python expressions from a string-based or compiled-code-based input. This function can be handy when you're ...
Read more >
eval() - JavaScript - MDN Web Docs - Mozilla
The eval() function evaluates JavaScript code represented as a string and returns its completion value. The source is parsed as a script.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found