evaluate

How to properly evaluate sage code from within a Python script

不羁岁月 提交于 2019-12-24 19:49:53
问题 I've been trying to evaluate a simple "integrate(x,x)" statement from within Python, by following the Sage instructions for importing Sage into Python. Here's my entire script: #!/usr/bin/env sage -python from sage.all import * def main(): integrate(x,x) pass main() When I try to run it from the command line, I get this error thrown: NameError: global name 'x' is not defined I've tried adding var(x) into the script, global x , tried replacing integrate(x,x) with sage.integrate(x,x) , but I

MSBuild: Evaluating reserved properties with ReadLinesFromFile

雨燕双飞 提交于 2019-12-24 19:19:56
问题 I'm using MSBuild to customize the build process of Visual Studio, WiX, SandCastle, ... projects. To keep it as generic as possible I'd like to use text files defining some 'project specific' settings, like where the files should be loaded from, which custom executables to run and so on. A text file could look like this: $(MSBuildProjectDirectory)....\Projects\Project1\bin\Release obj\$(Configuration)\Project1.Files.wxi -in *.dll -id TEST Each line represents one command or file. Inside my

Prolog Prefix Expression

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 05:53:13
问题 I'm able to get the sum from the prefix expression but whenever I add a list within a list the program doesn't run. expr(Z) --> num(Z). expr(Z) --> [+], num(X), expr(Y), {Z is X+Y}. expr(Z) --> [-], num(X), expr(Y), {Z is X-Y}. num(D) --> [D], {number(D)}. calculate(L, M) :- expr(M, L, []). This works: calculate([+, 2, -, 9, 8], X] but calculate([+, 2, [-, 9, 8]], X] gives false. What do I need in order for it to work list inside of list? 回答1: very simple: ... expr(Z) --> [L], {calculate(L, Z

Evaluating command with Awk

偶尔善良 提交于 2019-12-24 04:35:16
问题 The problem is that: I have different txt files in which is registered a timestamp and an ip address for every malware packet that arrives to a server. What I want to do is create another txt file that shows, for every ip, the first time a malware packet arrives. In general I want to do something like this : for every line in file.txt if (ip is not present in list.txt) copy timestamp and ip in list.txt I'm using awk for doing it. The main problem is the "if ip is not present in list.txt". I'm

Evaluate javascript to plain text using C#, .NET 3.5

蓝咒 提交于 2019-12-23 01:54:51
问题 How can I evaluate's document.write javascript to plaintext in C#? I'm trying to evaluate this: <script type="text/javascript"> a=2;b=3; document.write(a+"_"+y); </script> to this: 2_3 回答1: From your comment, "it's a client side function on a downloaded HTML page", it sounds like you are doing some sort of screen scraping / crawling, where the HTML/JavaScript are not making a client request to your app? If I understand correctly that this is what you are seeking, then you need an interpreter

How to using XPath in WebBrowser Control?

这一生的挚爱 提交于 2019-12-22 01:27:45
问题 In C# WinForms sample application, I have used WebBrowser control. I want to use JavaScript XPath to select single node. To do this, I use XPathJS But with the following code, the returned value of vResult is always NULL. bool completed = false; WebBrowser wb = new WebBrowser(); wb.ScriptErrorsSuppressed = true; wb.DocumentCompleted += delegate { completed = true; }; wb.Navigate("http://stackoverflow.com/"); while (!completed) { Application.DoEvents(); Thread.Sleep(100); } if (wb.Document !=

XSL. Evaluate expression

社会主义新天地 提交于 2019-12-20 07:09:52
问题 Sorry for my English. XSL 1.0. How can I to calculate expression from element or attribute value? For example XML: <position> <localizedName>ref-help</localizedName> <reference>concat('../help/', $lang, '/index.html')</reference> </position> I try use expression from 'reference' attribute: <xsl:for-each select="/content/positions/position"> <li> <!--Save expression to variable...--> <xsl:variable name="path" select="reference"/> <!--Evaluate variable and set it value to 'href'--> <a target=

What values are evaluated to true and false without strict comparasion? [closed]

那年仲夏 提交于 2019-12-20 04:50:22
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I want to have a list of all values that will be evaluated to true or false with poor equality check like != , == or even if() I had one list that I collected throught years, but it died alog with my PC 回答1: http

Does .Value = .Value act similar to Evaluate() function in VBA?

﹥>﹥吖頭↗ 提交于 2019-12-19 03:18:22
问题 Consider the following snippet. It writes the same formula to two cells A1 and A2 Sub Main() With Range("A1") .Formula = "=1+1" End With With Range("A2") .Formula = "=1+1" .Value = .Value End With End Sub The second with block uses .Value = .Value which calculates/executes the formula therefore the formula disappears from the formula bar. Refer to hiding formulas from formula bar for a supportive reference. Now, add another with block With Range("A3") .Formula = "=1+1" End With Range("A4") =

How to coerce AWK to evaluate string as math expression?

这一生的挚爱 提交于 2019-12-18 04:27:08
问题 Is there a way to evaluate a string as a math expression in awk? balter@spectre3:~$ echo "sin(0.3) 0.3" | awk '{print $1,sin($2)}' sin(0.3) 0.29552 I would like to know a way to also have the first input evaluated to 0.29552. 回答1: Here's a simple one liner! math(){ awk "BEGIN{printf $1}"; } Examples of use: math 1+1 Yields "2" math 'sqrt(25)' Yeilds "5" x=100; y=5; math "sqrt($x) + $y" Yeilds "15" 回答2: awk lacks an eval(...) function. This means that you cannot do string to code translation