24 questions
1
vote
1
answer
58
views
Call function by reference in PowerShell [duplicate]
Suppose I have a function like this. How can I get a reference to that function and then call it?
function Hello($name) {
Write-Output "Hello, $name"
}
3
votes
1
answer
270
views
Differences between std::function_ref and delegates
What are the differences between the new std::function_ref, that was added to C++26, and a "delegate"? Are they the same?
By "delegate" I mean:
A type that has sizeof(...) == 16.
...
4
votes
1
answer
65
views
Nested functions don't recognize input
Here's a minimal example of my problem:
innerFunc([2, 4, 5]) % works fine
outerFunc(innerFunc, [2, 4, 5]) % doesn't work
function out = innerFunc(my_vec)
my_vec % not recogniced when called from ...
3
votes
1
answer
97
views
C++Niche Syntax: Function Reference Type Declaration: const reference?
This is a niche question, but I'm struggling to find a sufficient answer.
Struct members can be const, but can a function pointer/reference member be declared const? Based off my reading of C++17 ...
-1
votes
2
answers
74
views
setTimeout on a jQuery nested (?) function
I'm not sure, if I'm using the correct term, but I want to achieve a delay on the "mouseleave". The code looks like this:
jQuery( function()
{
var targets = jQuery( '[rel~=...
2
votes
1
answer
46
views
Making a reference to set type functions in Java
I'm making a generic abstract class that will work with float and integer values and will use different algorithms to generate a new value. It relies heavily on picking a random value within range, so ...
7
votes
1
answer
107
views
How can I reference an existing method in Raku?
As explained in the docs, you can reference an existing function by prepending the & sigil:
&say # reference to the `say` function
&infix:<+> # reference to the infix `+` ...
3
votes
0
answers
118
views
What is the difference between rvalue and lvalue references to functions? [duplicate]
From c++11 onwards, there are lvalue and rvalue references. I am aware of the differences between them. However, akin to function pointers such as int(*fptr)(), c++ also has lvalue and rvalue ...
0
votes
1
answer
194
views
C++ Reference to member function work around (computation speed)
It is well known that you cannot create a reference to a member function in C++ [source].
For those that don't know. The issue come when you want to do something similar to
class A
{
public:
void ...
0
votes
1
answer
161
views
Prompting for user input as part of a reference to an out-of-script function in R
I have an issue similar to the one described in this post however mine involves a function being called in script 1 from a second script that stores the function. Essentially script1.R has reference ...
2
votes
2
answers
396
views
Passing References to Member Functions
I've been working with a doubly-threaded BST in C++, and I thought it would be cool to separate my visitor functions from my various traversals. However I can't figure out how to properly pass ...
0
votes
2
answers
778
views
Pass a Suspended-function reference as another function parameter
I have created a function that should get a suspended function as its parameter, run it, and perform some operations with the results.
When I try to call this function and pass a function reference ...
-1
votes
2
answers
209
views
Is it possible to reserve function reference into unordered_map or vector?
i am making some callback system and i wonder if i can reserve function reference to unordered_map so that i can invoke it later.
float func_imp(float x)
{
return x;
}
int main()
{
using Tumap ...
1
vote
1
answer
399
views
Taking Python class method as a polymorphic function
Edit: this question is based on two mistakes: not originally yincluding self in methods and assuming unbounded methods would not exhibit polymorphism, but they do. I voted to close it.
I can take a ...
0
votes
2
answers
193
views
How paste works within a function
I have data frame like below
Col1 Col2
White Orange
White Blue
Red White
On executing the below code,the items from both columns adds together. Please explain how the function works ...
2
votes
1
answer
420
views
std::bind on operator[] of std::array
I am trying to bind a member function at or operator[] of std::array, but the compiler (gcc 7.3) says that it can't determine the typename _Func. So I had created my own struct array to see where the ...
0
votes
1
answer
294
views
Best practice in instantiating a function type in Kotlin
I was wondering, whether it is better (in a way of having clean code according to a best practice) to pass function as reference using a new code block (lambda expression) or using a callable ...
9
votes
1
answer
471
views
Can I get a function reference to a function with default parameters in Kotlin, as the parameterless function?
Is it possible to get a function reference to a function which has default parameters, specified as the parameterless call?
InputStream.buffered() is an extension method which transforms an ...
1
vote
1
answer
882
views
Cross referencing between different *.py files possible?
My program tui.py consists of about 70 functions, which are sorted groupwise into four different documents:
tui.py
tbt.py
ens.py
hmm.py.
Most functions call at least one other function, some also call ...
2
votes
2
answers
262
views
How new operator works with delegates in C#
In this code snippet how does new MyDel(this.WelcomeUser) work? What happens in memory, I know that delegate is reference type, so is there an object created in heap and which type of object is it - ...
1
vote
1
answer
329
views
Difference between calling a function in a lambda and function references
In the following code (in kotlin)
fun greet(){
print("Hello! ")
}
fun salute(){
print("Have a nice day ")
}
fun main(args: Array<String>){
//val todoList: List<()->Unit> =...
0
votes
5
answers
264
views
Why do callbacks have to be a function?
I keep on seeing:
() => execute code
instead of just
execute code
in callbacks. I am not passing in any parameters, so why does () => execute code work but execute code doesn't? Aren't they the ...
1
vote
1
answer
2k
views
in kotlin how to put function reference in an array
Having class member function like:
private fun getData1(uuid:String): IData? {
...
}
private fun getData2(uuid:String): IData? {
...
}
private fun getData3(uuid:String): IData? {
...
}
...
154
votes
1
answer
23k
views
Are there constructor references in Kotlin?
In Java we have the Class::new syntax for constructor references. I know, there are callable references for methods, but how about constructors? A typical use case for me would be factories.