eval Questions

4

Solved

Actually I have some formula like "x + y", which is a String. I managed to replace the x/y variable with specific values like "1.2", which is still String type. Now I have expression like "1 + 2". ...
Defiant asked 7/4, 2011 at 14:42

10

Solved

I want to calculate math expression from a string. I have read that the solution to this is to use eval(). But when I try to run the following code: <?php $ma ="2+10"; $p = eval($ma); print $p...
Axum asked 18/9, 2013 at 19:33

12

Solved

In the book that I am reading on Python, it keeps using the code eval(input('blah')) I read the documentation, and I understand it, but I still do not see how it changes the input() function. W...
Pentathlon asked 21/2, 2012 at 19:19

4

I am storing function body in string with function name. function fnRandom(lim){ var data=[]; for(var i=0;i<lim;i++) { data=data.concat(Math.floor((Math.random() * 100) + 1)); } return dat...
Chaille asked 6/3, 2018 at 7:0

4

Solved

I can't import a module using the eval() function. So, I have a function where if I do import vfs_tests as v it works. However, the same import using eval() like eval('import vfs_tests as v') thro...
Agreement asked 16/6, 2013 at 19:13

9

Solved

I was just wondering if PHP has a function that can take a string like 2-1 and produce the arithmetic result of it? Or will I have to do this manually with explode() to get the values left and rig...
Rubierubiginous asked 20/2, 2011 at 13:31

14

Solved

I have a string like the following: String str = "4*5"; Now I have to get the result of 20 by using the string. I know in some other languages the eval() function will do this. How can I do thi...
Thorlay asked 9/4, 2010 at 4:7

8

I'm typing an equation into a TextBox that will generate the graph of the given parabola. Is it possible to use an eval function? I'm using C# 2010 and it doesn't have Microsoft.JScript
Putup asked 19/5, 2011 at 0:50

8

Solved

I'm curious to know if R can use its eval() function to perform calculations provided by e.g. a string. This is a common case: eval("5+5") However, instead of 10 I get: [1] "5+5" Any solutio...
Personally asked 16/11, 2009 at 17:39

27

Solved

I'm writing some JavaScript code to parse user-entered functions (for spreadsheet-like functionality). Having parsed the formula I could convert it into JavaScript and run eval() on it to yield the...
Musky asked 13/10, 2008 at 14:28

2

Solved

I like eval in Ruby because it works pretty straightforward: eval("puts 7 * 8") # => 56 What is an eval's equivalent in Crystal ? I know that we can do something similar with macro: macro ev...
Luminescence asked 24/6, 2015 at 20:17

1

I was going through this What is the use of eval `opam config env` or eval $(opam env) and their difference? and notice something funny. I understand command subtitution is used to nest commands in...
Dannettedanni asked 8/6, 2022 at 15:50

1

Solved

I would like to have various dynamic "shortcuts" (rule names) in my Snakemake workflow without needing marker files. The method I have in mind is similar to eval in GNU Make, but it doesn...
Waechter asked 6/6, 2022 at 18:28

2

Solved

I was coding something, and there was an error in one part. But I can't find why the error occurs. Code (Sample; similar to the error part): class Test: def __init__(self,a=0): self.x = a self....
Bland asked 17/6, 2017 at 11:21

11

Solved

After reading the Bash man pages and with respect to this post, I am still having trouble understanding what exactly the eval command does and which would be its typical uses. For example, if we do...
Juvenile asked 16/6, 2012 at 16:13

5

Solved

I am attempting to eval the following tab-indented string: '''for index in range(10): os.system("echo " + str(index) + "") ''' I get, "There was an error: invalid syntax , line 1" What is it c...
Belenbelesprit asked 2/10, 2012 at 20:44

3

Solved

Time and time again, I see Bash answers on Stack Overflow using eval and the answers get bashed, pun intended, for the use of such an "evil" construct. Why is eval so evil? If eval can't be used s...
Extravaganza asked 8/7, 2013 at 14:29

4

Everybody says eval is evil, and you should use $() as a replacement. But I've run into a situation where the unquoting isn't handled the same inside $(). Background is that I've been burned too o...
Solitude asked 8/10, 2012 at 20:35

6

We want to give our users the ability to execute self created JavaScript code within our application. For this we need to use eval to evaluate the code. To reduce all security concerns to a minimum...
Sigmund asked 21/10, 2014 at 8:35

11

Solved

I have a little bit of code that looks just like this: function StrippedExample(i1, i2, i3, i4, i5, i6, i7, i8) { this.i = []; for (var i=1,j=0 ;i<9;i++) { var k = eval("i"+i); if (k > 0...
Cassis asked 8/1, 2010 at 18:50

5

Solved

I need to execute series of commands inside an interactive program/utility with parameterized values. Is there a way to loop inside heredoc ? Like below .. Not sure if eval can be of any help here....
Stability asked 5/8, 2016 at 4:5

12

Solved

Is there a way to calculate a formula stored in a string in JavaScript without using eval()? Normally I would do something like var apa = "12/5*9+9.4*2"; console.log(eval(apa)); So, does ...
Telson asked 25/6, 2011 at 17:2

3

Solved

Why does the eval statement return Illegal variable name $ eval "$(ssh-agent -s)" Illegal variable name.
Croydon asked 24/10, 2014 at 2:43

4

Solved

I have this simple VBA code below, and I don't know why is not working. Sub Run() test = "MsgBox" & """" & "Job Done!" & """" Application.Run test End Sub What I want to do is to ...
Epitome asked 4/4, 2017 at 19:48

0

I am running an R script on databricks notebook for multiple datasets (around 500). I ordered datasets by file size to avoid errors and run the max amount of files within the shortest time because ...
Calciferous asked 21/1, 2022 at 16:7

© 2022 - 2024 — McMap. All rights reserved.