eval

Doing math in vb.net like Eval in javascript

匿名 (未验证) 提交于 2019-12-03 02:28:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there any way to parse a string in vb.net (like, built in methods), that can do math like Eval can? For example, 3+(7/3.5) as a string would return 2. I am not asking for you to code this for me, I just want to know if there is a built in way to do this, if there is not I will code it myself. I can wager that it would not be able to parse stuff like Sin(90) on its own, and I understand that would need to be replaced by Math.Sin(90). If there is a built in method, how do you use it? 回答1: There's a shortcut for limited (ie. simple) math

Javascript calling eval on an object literal (with functions)

匿名 (未验证) 提交于 2019-12-03 02:26:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Disclaimer: I fully understand the risks/downsides of using eval but this is one niche case where I couldn't find any other way. In Google Apps Scripting, there still is no built-in capability to import a script as a library so many sheets can use the same code; but, there is a facility built-in where I can import text from a plaintext file. Here's the eval-ing code: var id = [ The - docID - goes - here ]; var code = DocsList . getFileById ( id ). getContentAsString (); var lib = eval ( code ); Logger . log ( lib . fetchDate ());

Convert from an infix expression to postfix (C++) using Stacks

匿名 (未验证) 提交于 2019-12-03 02:24:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My lecturer gave me an assignment to create a program to convert and infix expression to postfix using Stacks. I've made the stack classes and some functions to read the infix expression. But this one function, called convertToPostfix(char * const inFix, char * const postFix) which is responsible to convert the inFix expression in the array inFix to the post fix expression in the array postFix using stacks, is not doing what it suppose to do. Can you guys help me out and tell me what I'm doing wrong? The following is code where the functions

Initializing perl variables using eval

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm guessing this should be something obvious to those knowing Perl, but I simply don't get it.. I also guess it has to do with problems described in - but I cannot apply any of that in my case. Anyways, here's the code: #!/usr/bin/env perl # call with: # ./test.pl use strict ; my $tvars = "my \$varA = 1; my \$varB = 2; my \$varC = 3; " ; my @lines = split / \n /, $tvars ; foreach my $line ( @lines ) { print "$line\n" ; eval $line ; warn $@ if $@ ; } #~ print "$varA\n"; # Global symbol "$varA" requires explicit package name at .

Alternatives to eval() for multiple nested objects

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to create a generic i18n solution for a HTML app I'm working in. I'm looking for alternatives to use eval() to call deeply nested Javascript objects: Suppose the following HTML example: <div id="page1"> <h1 data-i18n="html.pageOne.pageTitle"></h1> </div> and it's companion Javascript (using jQuery): var i18n; i18n = { html: { pageOne: { pageTitle: 'Lorem Ipsum!' } } }; $(document).ready(function () { $('[data-18n]').each(function () { var q; q = eval('i18n.' + $(this).attr('data-i18n')); if (q) { $(this).text(q); } }); }); Any

“eval” in Scala

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Can Scala be used to script a Java application? I need to load a piece of Scala code from Java, set up an execution scope for it (data exposed by the host application), evaluate it and retrieve a result object from it. The Scala documentation shows how easy it is to call compiled Scala code from Java (because it gets turned into to regular JVM bytecode). But how can I evaluate a Scala expression on the fly (from Java or if that is easier, from within Scala) ? For many other languages, there is the javax.scripting interface. Scala does not

Alan Kay&#039;s Eval/Apply Einstein Moment

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Alan Kay said that reading the code closely and finding the 1 and only bug in the code on page 13 of the Lisp 1.5 manual, helped him understand Computer Science by a factor of 100 better . The code in question is the 1st release of eval & apply that looks anything remotely like modern lisp (that I'm aware of). Since the correct answer is likely known but lost (my google-fu is decent and I've searched for 20 mins at least) I will award the 1st correct answer (I will be looking at edit times so don't try to cheat) a 250 point bounty As Soon As

Error in eval(expr, envir, enclos) : object not found

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am very new to coding in R, and cannot understand what is going wrong here. Any help will be much appreciated. data.train <- read.table("Assign2.WineComplete.csv",sep=",",header=T) # Building decision tree Train <- data.frame(residual.sugar=data.train$residual.sugar, total.sulfur.dioxide=data.train$total.sulfur.dioxide, alcohol=data.train$alcohol, quality=data.train$quality) Pre <- as.formula("pre ~ quality") fit <- rpart(Pre, method="class",data=Train) I am getting the following error : Error in eval(expr, envir, enclos) : object 'pre'

Is JSON.parse() really safer than eval() when web page and ajax call come from same server?

吃可爱长大的小学妹 提交于 2019-12-03 02:13:28
I get that JSON.parse() prevents an attacker from injecting javascript into the response since a JSON parser is just a text parser, not a script parser so please don't close this is a dup of all the other questions that talk about that. This is a different question. If an attacker can hijaack your Ajax call and put javascript into the Ajax call aren't they just as likely to be able to hijack your actual webpage and put arbitrary javascript into your page from which they could accomplish the exact same attack? Sure, you have nothing to lose by using JSON.parse() instead of eval() (unless you

type=dict in argparse.add_argument()

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to set up a dictionary as optional argument (using argparse); the following line is what I have so far: parser.add_argument('-i','--image', type=dict, help='Generate an image map from the input file (syntax: {\'name\': <name>, \'voids\': \'#08080808\', \'0\': \'#00ff00ff\', \'100%%\': \'#ff00ff00\'}).') But running the script: $ ./script.py -i {'name': 'img.png','voids': '#00ff00ff','0': '#ff00ff00','100%': '#f80654ff'} script.py: error: argument -i/--image: invalid dict value: '{name:' Even though, inside the interpreter, >>> a={