Questions tagged [dynamic-function]

75 questions
3
votes
3 answers

Javascript: Passing local variables into a dynamically created function that is a parameter inside another function

I am using a function with the following parameterization (which cannot be changed): my_function(data, callback_function(results, status) {}); I need to pass additional information to callback_function that cannot be added to 'data' (which…
kanoko
  • 85
  • 1
  • 2
  • 8
3
votes
2 answers

How do you dynamically call a method of an object?

in Perl I know you can use eval and *{$func_name} to call functions dynamically but how do you do this with methods of an object? for example EZBakeOven sub make_Cake { ... } sub make_Donut { ... } sub make_CupCake { ... } sub make_Soup {…
qodeninja
  • 10,946
  • 30
  • 98
  • 152
3
votes
0 answers

Inconsistency with bracket notation in object property accessors for dynamically named constructor-function. Is there an explanation?

I want to dynamically create objects of dynamically named class (sorry JS, I got used to call them classes) via dynamically named anonymous function. In this answer I found out that... As of ES2015, the function created by an anonymous function…
3
votes
1 answer

In Javascript, how to apply a dynamically created function name

My goal is to efficiently apply a dynamically chosen set of transforms to each element of a matrix. I store the selected functions in an array, then apply each of them in a single pass thru the matrix. My question is, how can I dynamically create…
3
votes
2 answers

Lua : Dynamically calling a function with arguments

Using Lua, I'm trying to dynamically call a function with parameters. I want to send a string to be parsed in a way that: 1st argument is a class instance "Handle" 2nd is the function to be called All that is left are arguments "modules" is a a…
Tipx
  • 7,367
  • 4
  • 37
  • 59
3
votes
1 answer

How to allow end user write his own functions?

I'm modeling some financial products and each product has his own pricing formula. In the application I would like to allow the end-user create his own product with the formula. And this formula can be used by my application to price the…
Thomas Carlton
  • 5,344
  • 10
  • 63
  • 126
3
votes
1 answer

call variable jQuery function

I've been shown how to call variable javascript functions by using window[](). Is it possible to call variable jQuery functions? If so, how? Usually, I only need a ternary to flip a visible switch, and it would be very convenient to smush many…
user1382306
2
votes
4 answers

PowerShell, auto load functions from internet on demand

It was pointed out to me (in PowerShell, replicate bash parallel ping) that I can load a function from the internet as follows: iex (irm https://raw.githubusercontent.com/proxb/AsyncFunctions/master/Test-ConnectionAsync.ps1) The url referenced…
YorSubs
  • 3,194
  • 7
  • 37
  • 60
2
votes
2 answers

How to Concat Strings using macro or any other ways

I have similar macros defined with just difference in them is number. e.g #define Function_01_Call(param) (FunctionName((int)01, param)) #define Function_02_Call(param) (FunctionName((int)02, param)) #define Function_03_Call(param) …
A.BHi
  • 33
  • 4
2
votes
2 answers

Storing php function variables in memcached

I was wondering if it is possible to store function variables in memcached. I wrote basic templating system which compiles xml templates into functions. The templates can get very big and I think I could get a performance boost if I could cache it.…
Ilia Choly
  • 18,070
  • 14
  • 92
  • 160
2
votes
1 answer

Problem with a dynamic function in SQL Server

I have a table dbo.t_products and I want to know the last record updated. For that I have an attribute last_changed which stores for each record the timestamp of the last update. Finally I want to save that result in a variable called @y. DECLARE…
Marco
  • 21
  • 1
2
votes
1 answer

Dynamically call a function in Windows Form

I'm building an app to test some equipment and the app will have 43 test steps (Step01.cs to Step43.cs). (tests are massive and need to be split in separate files) In each .cs file there is a public static void Test(){} function. At any given point…
xlucian
  • 339
  • 2
  • 4
  • 19
2
votes
4 answers

How do I create a function at runtime in Objective-C

So it's late here, and my google skills seem to be failing me. I've found some great responses on SO before (time and time again), I thought you guys could help. I have a neural network I'm trying to run in native objective-c. It works, but it's…
Paul
  • 169
  • 2
  • 10
2
votes
2 answers

TypeScript call function in dynamic (anonymous) function

I am trying to create a dynamic function in TypeScript which calls an already existing function like: let dynamicFunction = new Function("existingFunction(\"asdf\");"); function existingFunction(name: string) { console.log(name); } While…
Sarah
  • 31
  • 1
  • 1
  • 5
2
votes
1 answer

Dynamic expression for generic orderby clause

I need a little help for creating a generic method for fetching data from dbcontext and pass the 'orderby' clause as parameter. So far a managed to do this: public virtual Task> GetListAsync(Expression> orderby, bool asc =…