function

Return a reference to an Excel Worksheet from a PowerShell Function

倾然丶 夕夏残阳落幕 提交于 2021-02-05 09:01:18
问题 For the sake of code readability, I'd like to move my Excel stuff to a function and leave the worksheet object available to write cell values as my program processes stuff. How do I call a function that creates an Excel spreadsheet and return a worksheet reference so I can continue to access the open/active Excel app object I've created? Function Create-Excel-Spreadsheet() { # open excel $excel = New-Object -ComObject excel.application $excel.visible = $True # add a worksheet $workbook =

Shuffle array in Unity

假装没事ソ 提交于 2021-02-05 08:50:08
问题 I want to shuffle the numbers in my array variable once, so I called my Shuffle method from Start() . I then attempt access the shuffled array from update, but I am unable to do so. How can I access it? Is there any other way to shuffle my array once, then use it forever? private System.Random _random = new System.Random(); float sec; float timecount; float starttime; void Start () { starttime = Time.time; int[] array = { 1, 2, 3, 4, 5, 6, 7, 8}; Shuffle(array); foreach (int value in array) {

How to get the string name of the argument's type hint?

故事扮演 提交于 2021-02-05 08:36:05
问题 Let us say we have this function: function greetMe (string $name) { echo '<br/>'.$name; echo '<br/>'.gettype($name); } As you can see, we can get the type of the parameter $name . Now I am interested to know if there is a possibility, within the body of this function, to know that I declared the type string and not some other type. Any hints? 回答1: In PHP 7 and later, you can use ReflectionParameter.getType. Example #1 ReflectionParameter::getType() example <?php function someFunction(int

Python function returns only the first value instead of a dataframe

浪子不回头ぞ 提交于 2021-02-05 08:35:59
问题 I have build a function where I append the returns of 5 portfolios to a dataframe which I want to return to a variable . When I run the commands within the function row by row(kind of debugging) I end upwith the variable 'folioReturn'(which is the one I want my script to return) having the right amount of values (e.x 5). But if I call the function, only the first value of the dataframe is returned. Does anyone know how I can get the whole dataframe ? def portfolioReturns (securities,

Access: ConcatRelated works on a table, but not on a query

安稳与你 提交于 2021-02-05 08:19:06
问题 I have been using Allen Browne's ConcatRelated function, and while it works fine when the data comes from a table, but it doesn't work when the data comes from a query. The green 'running query' bar appears for a few seconds, but then when it tries to display the data it shows only one field from the first row, runs very slowly and can take a few minutes to display the first screen of records. I've not managed to leave it long enough to complete the result set, have to shut down Access using

kdb/q: How to apply a string manipulation function to a vector of strings to output a vector of strings?

不打扰是莪最后的温柔 提交于 2021-02-05 08:18:51
问题 Thanks in advance for the help. I am new to kdb/q, coming from a Python and C++ background. Just a simple syntax question: I have a string with fields and their corresponding values pp_str: "field_1:abc field_2:xyz field_3:kdb" I wrote an atomic (scalar) function to extract the value of a given field. get_field_value: {[field; pp_str] pp_fields: " " vs pp_str; pid_field: pp_fields[where like[pp_fields; field,":*"]]; start_i: (pid_field[0] ss ":")[0] + 1; end_i: count pid_field[0]; indices:

kdb/q: How to apply a string manipulation function to a vector of strings to output a vector of strings?

天大地大妈咪最大 提交于 2021-02-05 08:18:10
问题 Thanks in advance for the help. I am new to kdb/q, coming from a Python and C++ background. Just a simple syntax question: I have a string with fields and their corresponding values pp_str: "field_1:abc field_2:xyz field_3:kdb" I wrote an atomic (scalar) function to extract the value of a given field. get_field_value: {[field; pp_str] pp_fields: " " vs pp_str; pid_field: pp_fields[where like[pp_fields; field,":*"]]; start_i: (pid_field[0] ss ":")[0] + 1; end_i: count pid_field[0]; indices:

Leaving recursive functions running forever?

橙三吉。 提交于 2021-02-05 08:10:53
问题 I came across a function where it had a setTimeout inside with a timeout growing exponentially (timeout *= 2) . let timeout = 10000 function foo() { // doSomething without breaking, returning setTimeout(foo, timeout) timeout *= 2; } foo() It seems that this should not be a problem and intuitively feels like setInterval is kinda doing the same already (having an infinite loop until it's cancelled if ever) , however, my question is in the approach itself. Is this something that could lead to

Leaving recursive functions running forever?

◇◆丶佛笑我妖孽 提交于 2021-02-05 08:10:28
问题 I came across a function where it had a setTimeout inside with a timeout growing exponentially (timeout *= 2) . let timeout = 10000 function foo() { // doSomething without breaking, returning setTimeout(foo, timeout) timeout *= 2; } foo() It seems that this should not be a problem and intuitively feels like setInterval is kinda doing the same already (having an infinite loop until it's cancelled if ever) , however, my question is in the approach itself. Is this something that could lead to

x64 assembly functions (call/return vs push/pop/jump)

瘦欲@ 提交于 2021-02-05 07:57:28
问题 Whats the difference between using the built-in call and return instructions vs manually pushing and popping the stack and using jumps for functions? 回答1: Functionally, if you do it correctly, nothing. However it takes more instructions and/or registers to emulate call / ret using push / pop . Of course if you really wanted to take it to the extreme, you could also emulate push / pop using lea and mov :) Also, current processors have specialized hardware to handle function calls for the