function-calls

Passing missing argument from function to function in R

此生再无相见时 提交于 2019-12-18 13:08:53
问题 I’ve learned that it’s common practice to use optional arguments in function and check them with missing() (e.g. as discussed in SO 22024082) In this example round0 is the optional argument (I know, round0 could be defined as logical). foo = function(a, round0) { a = a * pi if(!missing(round0)) round(a) else a } But what if I call this function from another function, how can I pass “missing”? bar = function(b) { if(b > 10) round1=T foo(b, round1) } If b < 10 then round1 in bar() is not

What is a callback function and how do I use it with OOP

半世苍凉 提交于 2019-12-18 12:24:07
问题 I want to use the php simple HTML DOM parser to grab the image, title, date, and description from each article on a page full of articles. When looking at the API I notice it has a set_callback which Sets a callback function. However im not sure what this does or how I would use it? In one of the examples its used to call a function which strips out some stuff, im wondering if you have to use this to call all functions? I guess im wondering why I use this, and what does it do as I have never

Calling a user defined function in jQuery

谁都会走 提交于 2019-12-18 10:08:41
问题 I am trying to call a user defined function in jQuery: $(document).ready(function() { $('#btnSun').click(function() { myFunction(); }); $.fn.myFunction = function() { alert('hi'); } }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id="btnSun">Say hello!</button> I tried the following as well: $(document).ready(function() { $('#btnSun').click(function() { myFunction(); }); }); function myFunction() { alert('hi'); } <script src="https://ajax

When passing an array to a function in C++, why won't sizeof() work the same as in the main function?

落花浮王杯 提交于 2019-12-18 07:23:00
问题 So my C++ instructor told us in class that there was no function to determine an array size in C++ and I was not satisfied with that. I found a question here on stackoverflow that gave this bit of code (sizeof(array)/sizeof(*array)) and while I don't exactly understand it, I understand it takes the total amount of memory allocated to the array and divides it by what I assume is the default memory allocation of its data type...(???) I decided I wanted to practice writing functions (I'm in CS

How to view JavaScript function calls as they occur

[亡魂溺海] 提交于 2019-12-18 03:12:17
问题 Is it possible to view JavaScript function calls in the browser's JavaScript console? I know you can view XHR, but can you view function calls? For example, I hover my mouse over some element on a page and a div pops up. I know there was a JavaScript function that was called to show the popup so it would be nice to be able to view this call in the console so I can see what function was called. Am I missing something or is this not possible? 回答1: So basically you want to view JS calls in real

What is the scope of a defaulted parameter in Python?

久未见 提交于 2019-12-17 23:23:37
问题 When you define a function in Python with an array parameter, what is the scope of that parameter? This example is taken from the Python tutorial: def f(a, L=[]): L.append(a) return L print f(1) print f(2) print f(3) Prints: [1] [1, 2] [1, 2, 3] I'm not quite sure if I understand what's happening here. Does this mean that the scope of the array is outside of the function? Why does the array remember its values from call to call? Coming from other languages, I would expect this behavior only

'Spread' parameters in Scala?

左心房为你撑大大i 提交于 2019-12-17 20:23:28
问题 Is there any way to call a Scala function that takes individual parameters, given an array (similar to JavaScript Spreads in ECMAScript 6)? ys = [10.0, 2.72, -3.14] f(x, ...ys); The cleanest syntax would be: f(1, ys) but that does not appear to be possible. Even f(1, ys:_*) does not work (and neither does f(ys:_*) , as the compiler reports too few parameters - only the first one is filled). Example: def f (a:Int, b:Float, c:Float, d:Float): String val x = 1 val ys = List(10.0, 2.72, -3.14) //

Call a function by an external application without opening a new instance of Matlab

天涯浪子 提交于 2019-12-17 06:16:25
问题 Is there a way to call Matlab functions from outside, in particular by the Windows cmd (but also the Linux terminal, LUA-scripts, etc...), WITHOUT opening a new instance of Matlab each time? for example in cmd : matlab -sd myCurrentDirectory -r "function(parameters)" -nodesktop -nosplash -nojvm opens a new instance of Matlab relatively fast and executes my function. Opening and closing of this reduced matlab prompt takes about 2 seconds (without computations) - hence for 4000 executions more

How to call C# DLL function from VBScript

不想你离开。 提交于 2019-12-17 04:32:13
问题 I have my script on server, so I do not have UI interaction available and have to use DLL instead of console application. How to call a function in C# DLL from VBScript? How do I make my DLL to be COMVisible ? Do I have to register it? 回答1: You need to mark your assembly as COM visible by setting the COMVisibleAttribute to true (either at assembly level or at class level if you want to expose only a single type). Next you register it with: regasm /codebase MyAssembly.dll and finally call it

How to call C# DLL function from VBScript

夙愿已清 提交于 2019-12-17 04:31:16
问题 I have my script on server, so I do not have UI interaction available and have to use DLL instead of console application. How to call a function in C# DLL from VBScript? How do I make my DLL to be COMVisible ? Do I have to register it? 回答1: You need to mark your assembly as COM visible by setting the COMVisibleAttribute to true (either at assembly level or at class level if you want to expose only a single type). Next you register it with: regasm /codebase MyAssembly.dll and finally call it