eval

in c#: expression evaluation function like flash script

好久不见. 提交于 2019-11-29 14:51:11
Duplicate of: How can I evaluate a C# expression dynamically? See also: C# eval equivalent? How to evaluate expression. Maybe like: int a=1; int b=3; int c=Eval("a+b"); or int c=int.parse("1+3*(2+3)"); This seems stupid to me. is it possible in c#? You can take code, and using the CSharpCodeProvider write an Eval function that actually compiles your code into an in-memory assembly and then executes that code. See this CodeProject article for sample source. thinkbeforecoding Not directly. C# contains no runtime compiler. There is an open source project attached to Mono that will do this. I

Using eval() to set global variables

 ̄綄美尐妖づ 提交于 2019-11-29 14:17:15
My code to set a global variable using eval is not working. It's as if the assignment is not called at all, but no script errors occur. <script type="text/javascript"> $(function() { setTimeout(function() { eval('var x = 1;'); alert(x); }, 0); }); </script> <div onclick="alert(x);">Click to see 'x'</div> When the page loads, the alert shows what I expect; it confirms that x = 1. But after that, I click on the div and get a javascript error that x is undefined. How do I make eval add this variable properly? Background: The code above is a minimally reproducing example from a project I'm working

Alternatives to eval() for multiple nested objects

放肆的年华 提交于 2019-11-29 14:14:09
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 advices on how to access the "pageTitle" property inside

Python实现简单的四则运算

萝らか妹 提交于 2019-11-29 13:48:54
GitHub 项目地址 https://github.com/745421831/-/tree/master PSP PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟) Planning 计划 10 20 · Estimate · 估计这个任务需要多少时间 10 10 Development 开发 360 600 · Analysis · 需求分析 (包括学习新技术) 30 40 · Design Spec · 生成设计文档 30 40 · Design Review · 设计复审 (和同事审核设计文档) 10 15 · Coding Standard · 代码规范 (为目前的开发制定合适的规范) 5 5 · Design · 具体设计 40 80 · Coding · 具体编码 300 500 · Code Review · 代码复审 60 120 · Test · 测试(自我测试,修改代码,提交修改) 180 120 Reporting 报告 120 60 · Test Report · 测试报告+博客 120 120 · Size Measurement · 计算工作量 10 10 · Postmortem & Process Improvement Plan · 事后总结, 并提出过程改进计划 40 30 合计

Cannot programmatically trigger jQuery click event

▼魔方 西西 提交于 2019-11-29 13:40:57
If I understand correctly, to programmatically trigger a jQuery click event attached to an object with a css class of my-button , you should be able to just do this: $('.my-button').click(); For some reason, this code is failing to trigger the click event attached to the element. The $('.my-button') part of the code is working and returning one element. We know the event handler is attached to that element because clicking on the element does trigger its event handler's code. The handler is attached with the following simple code: $('<a class="my-button"/>') .click(function() { /* code here */

Perl: Why doesn't eval '/(…)/' set $1?

南楼画角 提交于 2019-11-29 13:14:09
If a regular expression match occurs inside an eval, changes to the capture-related variables ($1, etc.) are not visible in the outside environment. Is this a bug? perlop and perlre don't seem to mention any such restriction. For example: use strict; use warnings; $_ = "hello"; eval '/(.*)/'; print "GOT: $1\n"; gives: Use of uninitialized value $1 in concatenation (.) or string at -e line 1. GOT: A more succinct demo is: perl -we '$_="foo"; eval q(/(.*)/;) ; print "GOT:$1\n";' Documentation proof that local ized variables are the issue here is in perlvar of 5.14.0 : These variables are read

eval in Objective-C [duplicate]

末鹿安然 提交于 2019-11-29 12:35:45
Possible Duplicate: Is there something like Matlab's eval statement in Objective-C 2.0? Is there an eval function (as in lisp, javascript, python, ruby...) in Objective-C? What I mean by eval is a function that can take in arbitrary Objective-C code (possibly having class definitions, side effects, instrospection, etc) as a string (not a block or an NSInvocation or IMP or something like that), and evaluate each expression, respecting the current runtime environment state, side effects, class definitions, etc. If not, is it possible to implement within the confines of the existing runtime?

Is pound-quote (hash-quote, #') in Clojure running the resolve and symbol functions?

筅森魡賤 提交于 2019-11-29 12:09:43
问题 Perhaps you can help me find this in the docs. I'm using pound-quote to be able to pass around unevaluated function names prior to execution. For example: (#'cons 1 ()) ;(1) (defn funcrunner [func a b] (func a b)) (funcrunner cons 'a ()) ;(a) (funcrunner 'cons 'a ()) '() (funcrunner #'cons 'a ()) ;(a) #'cons ;#'clojure.core/cons (resolve (symbol 'cons)) ;#'clojure.core/cons My guess is that this is a reader macro. My question is (a) What is the pound quote (#') shorthand for? (b) Can you

Dynamic code evaluation in scala

[亡魂溺海] 提交于 2019-11-29 11:17:12
What is the best way to inject a snippet of code to scala? something like eval in javascript and GroovyScriptEngine. I want to keep my rules/computations/formulas outside the actual data processing class. I have close to 100+ formulas to be executed. The data flow is same for all only the formulas change. What is the best way to do it in scala? and the number of formulas will grow over time. You could use either scala-lang API for that or twitter-eval . Here is the snippet of a simple use case of scala-lang import scala.tools.nsc.Settings import scala.tools.nsc.interpreter.IMain object

powershell: how to evaluate a string read from a file

时光怂恿深爱的人放手 提交于 2019-11-29 11:12:22
问题 file a.txt is: delete from test_$suffix $a=get-content a.txt $suffix="tableA" how to manipulate the variable to set it as delete from test_tableA 回答1: $a=get-content a.txt $suffix="tableA" $ExecutionContext.InvokeCommand.ExpandString($a) 回答2: Invoke-Expression is the equivalent. $strExpression = "5 + 5 -eq 10" Invoke-Expression $strExpression True See http://technet.microsoft.com/en-us/library/ee176880.aspx for more information. 回答3: Here's one way. Variables in a double-quoted here-string