function

Dynamically invoking any function by passing function name as string

Hello, How do I automate the process of getting an instance created and its function executed dynamically? Thanks Edit: Need an option to pass parameters too. Thanks ...

Passing functions with arguments to another function in Python?

Is it possible to pass functions with arguments to another function in Python? Say for something like: def Perform ( function ) : function but the functions to be passed will be like: Action1() Action2(p) Action3(p,r) ...

How do I pass a hash to a function in Perl?

I am having a lot of trouble. I have a function that takes a variable and an associative array, but I can't seem to get them to pass right. I think this has something to do with function declarations, however I can't figure out how they work in Perl. Does anyone know a good reference for this and how to accomplish what I need? I should a...

Rot13 for numbers.

EDIT: Now a Major Motion Blog Post at http://messymatters.com/sealedbids The idea of rot13 is to obscure text, for example to prevent spoilers. It's not meant to be cryptographically secure but to simply make sure that only people who are sure they want to read it will read it. I'd like to do something similar for numbers, for an appl...

SEO title making function ??

I have created a function which will convert any string into tab delimited. What's new in ASP.NET 4.0 Then it will convert above title to following: what-s-new-in-asp-net-4-0 I am using this to make my URL's SEO'd. But I am not sure that it will work fine in all cases or not. Till now I have tested this function on around 1000 rec...

Call a function with argument list in python

I'm trying to call a function inside another function in python, but can't find the right syntax. What I want to do is something like this: def wrapper(func, args): func(args) def func1(x): print(x) def func2(x, y, z): return x+y+z wrapper(func1, [x]) wrapper(func2, [x, y, z]) In this case first call will work, and seco...

Using a function in a query that returns a string or a null

I want to join 2 tables 'addresses' and 'user_info' on user_id and app_id (which is a number, or it is null), like these 2 examples: select * from user_info left outer join addresses on addresses.user_id = user_info.user_id and addresses.app_id is null select * from user_info left outer join addresses on addresses.user_id = user_in...

Why does my .push_back() give me an error? (C++)

I initialized a vector of pointers called "antiviral_data", and am able to use antiviral_data.push_back without problems. But when I try to do the same thing with "viral_data" I get an error, because the compiler thinks I am redeclaring "viral_data": vector<virus*> viral_data; vector<virus*>::iterator vI; viral_data.push_back(new X1(9, ...

How to create/run a .exe from a program? (C++)

Is it possible (and if so, how) to write a program in C++ that takes parameters, then run that program from another C++ program. Ie: I can create a function that adds two numbers: int add(int a,int b){return a+b;} Is it possible to do the same thing, except instead of a function, a separate C++ .exe? EDIT: Since a lot of people don...

Objective-C: Smalltalk-style Messages vs. C-style Functions

When should I use messages versus C-style functions? ...

Declaring functions in JSP?

I come from PHP world, where declaring a function in the middle of a php page is pretty simple. I tried to do the same in JSP: public String getQuarter(int i){ String quarter; switch(i){ case 1: quarter = "Winter"; break; case 2: quarter = "Spring"; break; case 3: quarter = "Summer I"; break; case 4: quarter = "Summer II"; br...

Declare External Functions In A Cocoa / Obj-C Project.

Ok, here goes. I've completed a Cocoa foundation-tool that calculates mean absolute deviation of random integers (Just as a learning project). I've moved the calculation into a function called "findMeanAbsoluteDeviation()" It accepts a NSMutableArray of NSNumber objects to preform calculations. Anyways. So this works all fine and dandy...

PHP get all arguments as array?

Hey, I was working with a PHP function that takes multiple arguments and formats them. Currently, I'm working with something like this: function foo($a1 = null, $a2 = null, $a3 = null, $a4 = null){ if ($a1 !== null) doSomethingWith($a1, 1); if ($a2 !== null) doSomethingWith($a2, 2); if ($a3 !== null) doSomethingWith($a3, 3)...

Take input text, print to page and open new window onclick

What I need help with: My page shall take user input text, then show what was entered on the page (no alert) and open a new window on click if a match is found that would be stored in an array or var. Here is the line I am having trouble with below: onclick="insert(this.form.name.value),show();"/> Here is the code thus far: ...

Cached or precomputed Immutable Functions in C# / C++

By "immutable function" or "immutable method", I mean a function whose result will never vary if you give it the same arguments. I would be interested to know if anyone know of a more generic or less verbose solution when you want to cache the precomputed value(s) of an immutable function. Let me explain what I mean with a simple examp...

how to trigger a jquery function just with the url?

Hello everyone.. this is my first question.. so, here we go. i have a site, 100% xhtml/css with some ajax functions thanks to jquery. te problem is.. for all the "sub pages".. the url remains the same (index.php).. my question is.. does jquery allow some url parameters to trigger an specific function? example: www.mypage.com -> hom...

Two functions, or one function with different params?

This is a very generic 'best practice' question, but here's an example. Let's say I have a movie cataloging app. I want to give my users the chance to specify, say, IMDb or Metacritic for their synopsis/ rating info. Do I do this: if (preferredSupplier == "imdb"){ getIMDbRating(movieName); }else{ getMetacriticRating(movieN...

Drupal hook_search function location

I can't for the life of me figure out where the hook_search function in drupal is located. Is it something I need to add to a file to access? ...

Cheap php templating with vprintf?

Ok, so printf/sprint/vprintf all accept a certain type specifier syntax %[num][type]. (http://us2.php.net/sprintf see examples 3 and 4) Where num is the index to the type. Example: vprintf('Number %1$d string %2$s. String %2$s, number %1$d',array(1,"no")); Yes, it is limited... And you would need to maintain the indexes. But it's nativ...

AS3: declaring an "undefined" parameter for int, uint or Number

I'd like to implement the following logic: function setMyValue (myVar:int = undefined):void { if (myVar == undefined) { /* Generate a value for myVar */ } else { /* Use the supplied value for myVar */ } } So if the value is supplied, use it. If not, generate it. Seems simple enough. Problem is that A...