eval

匿名函数,子函数,私有函数,重载函数,eval和feval函数

徘徊边缘 提交于 2019-11-30 09:54:08
匿名函数,子函数,私有函数等函数类型 匿名函数: 匿名函数没有函数名,也不是.m文件,只包含一个表达式和输入输出参数。 Fxy=@(x,y)x.^y+3*x*y x,y为输入输入参数,Fxy为函数名 子函数: 在 Matlab中, 多个函数写入一个.m文件中。其中出现的第一个函数称为主函数,其他函数称为子函数,保存时文件名与主函数名相同,外部程序只能调用主函数。 特点: 子函数只能被同一文件下的其他函数调用 通过名称调用函数时优先调用子函数,再调用内置函数。 同一文件的主函数,子函数工作区独立,各个函数之间的信息传递通过输入输出参数实现。 Help,lookfor无法显示子函数的相关信息 function F=ex4_19(n) A=1; w=2; phi=pi/2; signal=createsig(A,w,phi); F=signal.^n; %%%%%%%%subfunction%%%%%%%%%% function signal=createsig(A,w,phi) x=0:pi/100:pi*2; signal=A*sin(w*x+phi); 私有函数和私有目录: 私有函数指位于私有目录private下的函数文件。 特点: 私有函数构造与普通函数相同。 私有函数只能被private目录下的M文件直接调用。 使用指令调用私有函数,优先级仅次于Matlab内置函数和子函数

Securely running user's code

巧了我就是萌 提交于 2019-11-30 09:47:52
问题 I am looking to create an AI environment where users can submit their own code for the AI and let them compete. The language could be anything, but something easy to learn like JavaScript or Python is preferred. Basically I see three options with a couple of variants: Make my own language, e.g. a JavaScript clone with only very basic features like variables, loops, conditionals, arrays, etc. This is a lot of work if I want to properly implement common language features. 1.1 Take an existing

vbscript Eval a string to a Variable in a loop?

那年仲夏 提交于 2019-11-30 09:41:36
问题 I am trying to use vbscript's Eval (or maybe I need Execute) to create some variables from the key names from an ini file. The ini file can have unlimited unknown key=val pairs. I need to create a variable based on the key name no matter what. Ini File contents: myPath=c:\test myExe=myapp.exe .... xxx=123 yyy=abc My code that reads the ini and returns the key and values to an object The code I am trying to get working is here: For each pair in objINI Eval("pair.key=pair.val") Next msgbox

AngularJS uses eval in chrome extension

你说的曾经没有我的故事 提交于 2019-11-30 09:39:05
问题 The lates AngularJS (1.3 beta 19) uses eval . This is prohibited in chrome extionsion. How to fix the issue without allowing evals ? Error message: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:". Stack trace: angular.js:1011 csp angular.js:1011 (anonymous function) angular.js:23556 UPDATE: See documentation of ng-csp https://docs.angularjs.org

Performance of `eval` compared to `str2func` to evalulate a function from a string

末鹿安然 提交于 2019-11-30 09:05:38
问题 eval and str2func are both able to evaluate a function represented by a string, f.e. f='a^x+exp(b)+sin(c*x)+d' : Using eval : y = eval(f) or (suggested by rahnema1) fHandle = eval(['@(x, a, b, c, d) ' f]); y = fHandle(x, a, b, c, d); Using str2func : fHandle = str2func(['@(x, a, b, c, d) ' f]); y = fHandle(x, a, b, c, d); Which of both methods has the best performance? Remarks Note that this benchmark is inspired on this question. Note that I'm aware that using eval and str2func is often bad

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

你离开我真会死。 提交于 2019-11-30 08:38:59
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 explain what it is doing? (c) Can you locate it in the docs? (d) Is it actually shorthand for for resolve

Define const variable using eval()

南笙酒味 提交于 2019-11-30 08:28:24
问题 When I try to define a variable using var, everything is working. But defining it as const is not working as expected and the variable is undefined. window.eval("var v = 5;"); document.body.innerHTML += window.v === undefined; window.eval("const l = 5;"); document.body.innerHTML += window.l === undefined; I have tested it on Chrome and Node.js. Am I missing something? Thank you in advance! 回答1: That is because const turns on the strict mode by default. See what happens when you turn on the

基于B/S的asp校园二手商品交易网

荒凉一梦 提交于 2019-11-30 07:44:40
随着Internet技术的发展,人们的日常生活已经离不开网络。网络已逐渐深入人心,更是成为继报刊、电视、广播等传统媒体之后而兴起的一新传媒介质。随着互联网的发展,电子商务也得到了飞速发展, 于是网上购物平台变得流行起来。近些年,在国家倡导节约型校园的精神推动下,很多大学校园兴起了二手商品交易的热潮。将二手商品充分合理的利用是很有必要的,因此本人认为很有必要建立学校的二手交易网站。 学校二手交易网站是将计算机技术应用于信息传播与处理的一个方面,使用该系统能及时发布交易信息,并且还能完成在线的交易。本文论述的系统是采用C#和SQL结合,基于B/S 模式的Web应用软件,实现对学生二手交易货品有关信息的统一化管理。 本文首先对建设学校二手交易网站的背景和意义进行分析,同时提出网站设计思路;然后介绍了建立学校二手交易网站所需要的 工具技术 ,并对所用到的技术(C#、SQL)和工具(VS2010 、SQL 2005)详细分析;接下来阐述了该系统所需的各模块的设计,给出网站总体功能设计和数据库设计;最后,从研究方案入手,利用相关语言进行模块化设计。 <body> <form id="form1" runat="server"> <div> <table id="search" align="center" border="1" bordercolor="#cccccc" cellpadding

python如何保证输入键入数字

痴心易碎 提交于 2019-11-30 07:37:33
要求:用python写一个要求用户输入数字,如果不是数字就一直循环要求输入,直到输入数字为止的代码 错误打开方式: while True : ten = input ( 'Enter a number:' ) if type ( eval ( ten ) ) == type ( int ) :    break 用这个输入字母可以可是输入字母就直接报错中断了 主要出在eval上。 第一个方案: ''' 遇到问题没人解答?小编创建了一个Python学习交流QQ群:857662006 寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书! ''' while True : ten = input ( "x:" ) try : x = eval ( ten ) if type ( x ) == int : break except : pass 然后输入asf,没有提示。输入344就退出了 x : asf x : 344 第二个方案 while True : ten = None try : ten = int ( input ( "x:" ) ) except : pass if type ( ten ) == int : break 这个在python3.0上调试通过 第三个方案:python2.x的方案 ''' 遇到问题没人解答

Why must “exec” (and not “eval”) be used for Python import statements?

可紊 提交于 2019-11-30 06:51:57
I'm trying to run a snippet of Python from within Java, using Jython. If I use an exec statement to import, everything works. PythonInterpreter pi = new PythonInterpreter(); pi.exec("import re"); PythonObject o = pi.eval("re.match('abc', 'abc123')"); // returns a MatchObject o = pi.eval("re.match('abc', 'def123')"); // returns Py.None If, however, I try to combine the two lines, all hell breaks loose. This: PythonInterpreter pi = new PythonInterpreter(); pi.eval("import re"); // exception! PythonObject o = pi.eval("re.match('abc', 'abc123')"); // never gets here o = pi.eval("re.match('abc',