function

Haskell: How do I define the types my function can take as parameters? AND how do I access unnamed variables in a data structure?

1) Here is my code, the find function needs to take a (Node a) and a type (a) as parameters but my function definition doesn't seem to work, what am I doing wrong? Little info on the net that I can find, so thanks for any help! 2) When my find function is implemented I'll need to access a specific variable in a Node, how do I do this?!?...

Multiple function calls, only the last succeeds. Why?

I store an array of values in my cookie as a string (with ',' as separator). I update them using explode(), implode() and setcookie() methods in a custom function set_Cookie() and it works great. function set_Cookie($name, $position, $value) { $cookie = ($_COOKIE[$name]); $cookie_exp = explode(",", $cookie); $cookie_exp[$pos...

[C++] Map functions of a class

Hi! Before I was trying to map my classes and namespaces, by using static calls I succeded and now I need to map the functions of my classes because they will be used dinamically. Firstly I was thinking to hardcode in the constructor so I can assign a std:map with the string of the name of function pointing to the function itself. f...

Oracle SQL Count Function Display Only One Value

I am learning SQL for a personal projects and seems that I don't quite get the COUNT function. I have a "sample" table with this sample data: NAME COLOR Tom red Tom blue Jerry yellow Keri yellow Paul red Bob yellow Bob red Mary green What I am attempted to do is print out only those NAME values that have only one COLOR va...

Changing return type when overidding a function in the subclass in PHP?

Is this bad? Or this is very common in PHP framework? For example, in the parent class, there is a save() function which returns the number of rows affected in the database. Then in the child class, I override this function to do some pre-validation, and also would like to simply return a success/failed boolean value. ...

"Parameter" vs "Argument"

Possible Duplicate: Arguments or parameters? I got "Parameter" and "Argument" kind of mixed up and did not really pay attention to when to use one and when to use the other. Can you please tell me? Thanks. ...

Why does my yacc program not recognize function declarations?

I think my program should be able to recognize the following as a function declaration int fn(int i) { int n; return; } but it doesn't. Here's the relevant part of my yacc file program : declaration_list ; declaration_list : declaration_list declaration | declaration ; declaration : var_declaration | fun_declaration ...

Difference between [square brackets] and *asterisk

If you write a C++ function like void readEmStar( int *arrayOfInt ) { } vs a C++ function like: void readEmSquare( int arrayOfInt[] ) { } What is the difference between using [square brackets] vs *asterisk, and does anyone have a style guide as to which is preferrable, assuming they are equivalent to the compiler? For completene...

How to include files with die(); function?

Hi. file1.php and file2.php with die(); function. include.php: <? include 'file1.php'; include 'file2.php' ?> file1.php <? echo 'included'; die(); ?> file2.php <? echo 'not included'; die(); ?> How can I included both files with die(); function? P.S My English poor, sorry for that. ...

Closure/scope JavaScript/jQuery

Hello all, I'm trying to group some exisiting top-level functions inside a closure (to avoid polluting the global namespace) but I'm not quite getting it to work. First, all the JS works outside my anonymous function, but once I put it in the anonymous function I get an error of "crossfade is not defined". Does anyone see anything comp...

[C++] Map functions of a class while declaring the functions

Hi, My previous question about this subject was answered and I got some tests working nice. http://stackoverflow.com/questions/1786809/c-map-functions-of-a-class My question is now, if there is a way to while declaring the function, be able to register it in a map, like I realized in this question about namespaces and classes: http://s...

PHP: Array to variable function parameter values

I have a variable length array that I need to transpose into a list of parameters for a function. I hope there is a neat way of doing this - but I cannot see how. The code that I am writing will be calling a method in a class - but I will not know the name of the method, nor how many parameters it has. I tried this - but it doesn't w...

Asynchronous waiting while C# function is executing

I have a blocking function that executes an asynchronous MySQL query and returns the result when it is obtained. The reason is is asynchronous is this program is not allowed to lock up during a query. The function is called when the user presses a button, so the function may get called several times before the first query completes. I t...

Member assignment in a const function

I have a class member myMember that is a myType pointer. I want to assign this member in a function that is declared as const. I'm doing as follows: void func() const { ... const_cast<myType*>(myMember) = new myType(); ... } Doing this works fine in VC++, but GCC gives an error with the message "lvalue required as left ...

Removing non-alphaNumerics in MySQL

Hi! Do you know any easy way to remove (or replace) all non alphanumeric characters from varchar variable in Mysql? something like String's replaceAll("[^a-zA-Z0-9]", "I") in Java ('I' is my special character but "" would be also good ) ...

Disadvantages of First-class functions

Are there any disadvantages to having first class functions in a language? Joel in this entry says "Object-oriented programming languages aren't completely convinced that you should be allowed to do anything with functions." I might be naïve here, but why don’t all languages support first class functions if there aren’t much issues...

From a usage standpoint, what's the difference between a private and protection class function?

I know the manual definition, but from a real life usage standpoint, what's the difference? When would you use one over the other? ...

Accessing Parameters *and* Events in function from jQuery Event

Hello all, This is a follow-up question to a different question I asked not too long ago. Typically, you can access an event in a function call from a jQuery event like this: $item.live("click", functionToCall); and in the function: function functionToCall(ev) { // do something with ev here, like check 'ev.target' } But what if ...

Passing return value of a function as an argument

What are some ways of passing the return value of one function as an argument to another? What are some examples in programming languages that you favor, JS, Python, etc? ...

prior declarations of functions

Why do functions need to be prior declared in C ? ...