function

Postgresql - Edit function signature

POSTGRESQL 8.4.3 - i created a function with this signature CREATE OR REPLACE FUNCTION logcountforlasthour() RETURNS SETOF record AS realised i wanted to change it to this CREATE OR REPLACE FUNCTION logcountforlasthour() RETURNS TABLE(ip bigint, count bigint) record AS but when i apply that change in the query tool it isnt accept...

PHP function to find out the number of parameters passed into function?

Hi all, Is there a PHP function to find the number of parameters to be received/passed to a particular function? ...

Name and parameters of parent function

I'm trying to figure out how to get the name and parameters of a parent function. Example: function foo($a,$b){ bar(); } function bar(){ // Magic Print } foo('hello', 'world'); Output: foo('hello','world') Any tips? ...

How to use two parameters pointing to the same structure in one function ?

Hey guys, I have my code below that consits of a structure, a main, and a function. The function is supposed to display two parameters that have certain values, both of which point to the same structure. The problem I dont know how to add the SECOND parameter onto the following code : #include<stdio.h> #define first 500 #define sec 5...

How do you create a formula that has diminishing returns?

I guess this is a math question and not a programming question, but what is a good way to create a formula that has diminishing returns? Here are some example points on how I want the curve to look like. f(1) = 1 f(1.5)= .98 f(2) = .95 f(2.5) = .9 f(3) = .8 f(4) = .7 f(5) = .6 f(10) = .5 f(20) = .25 Notice that as the input gets hig...

Creating a Function in SQL Server with a Phone Number as a parameter and returns a Random Number

Hi Guys, I am hoping someone can help me here as google is not being as forthcoming as I would have liked. I am relatively new to SQL Server and so this is the first function I have set myself to do. The outline of the function is that it has a Phone number varchar(15) as a parameter, it checks that this number is a proper number, i.e....

JavaScript - Passing a reference to this current anonymous function

window.addEventListener('unload', function(e) { MyClass.shutdown(); window.removeEventListener('unload', /* how to refer to this function? */); }, false); ...

C++ return type overload hack

I was bored and came up with such hack (pseudocode): 1 struct proxy { 2 operator int(); // int function 3 operator double(); // double function 4 proxy(arguments); 5 arguments &arguments_; 6 }; 7 8 proxy function(arguments &args) { 9 return proxy(args); 10 } 11 int v = function(...); 12 double u = function(....

referencing (this) in a function

I have elements being generated by dynamic html, I would like to reference the particular href that is calling the function when one of many may be calling it. <a href="javascript:Foo(this)">Link</a> Does not work when I try to reference $(this). Is there another way to do this or do I have to make dynamic ids? ...

How to implement XXTEA in MySQL?

Anyone knows how to implement XXTEA in MySQL? For example - SELECT xxtea_encrypt('text here', 'key here'); possible implementation is by creating a FUNCTION in MySQL using CREATE FUNCTION statement, e.g. CREATE FUNCTION xxtea_encrypt XXTEA Procedures here... RETURN encrypted string Thanks & Best regards ...

Constructing a function call in C

Given that I have a pointer to a function (provided by dlsym() for example) and a linked list of typed arguments, how can I construct a C function call with those arguments? Example: struct param { enum type { INT32, INT64, STRING, BOOL } type; union { int i32; long long i64; char *str; bool b; } value; struct param *next; };...

Why does this PHP program not work?

I'm new to PHP and was learning about PHP functions from w3schools. It said "PHP allows a function call to be made when the function name is in a variable" This program worked <?php $v = "var_dump"; $v('foo'); ?> But this program did not work: <?php $v = "echo"; $v('foo'); ?> But if I do echo('foo'); it works. What am I doing wr...

update global variable from a function in the javascript

Here is the situation: I have one function which has local variable. I would like to assign that value to global variable and us it's value in another function. Here is the code: global_var = "abc"; function loadpages() { local_var = "xyz"; global_var= local_var; } function show_global_var_value() { alert(global_var); }...

[WordPress] Paging on Index Page Not Working With posts_per_page

I'm working on a theme that has both a project page and a blog. I want to keep the blog posts at the default of 10, so I used the posts_per_page option to limit the number of projects on the first page, like this: <?php $catID = get_cat_id('Projects'); $number = get_option('grd_portfolio_number'); if(have_posts()) : $paged = (get_query...

If a MATLAB function returns a variable number of values, how can I get all of them as a cell array?

I am writing a function to remove some values from a cell array, like so: function left = remove(cells, item); left = cells{cellfun(@(i) ~isequal(item, i), cells)}; But when I run this, left has only the first value, as the call to cells{} with a logical array returns all of the matching cells as separate values. How do I group these...

Creating a javascript function to switch classes between list elements depending on which one has been clicked.

I am trying to create a function to change the class on a series of 5 list elements depending on which has been clicked. The goal is to change the style of the element depending on which one is the current element. I had tried something like this: function addClass(obj) { obj.className="highlight"; } and then added this to my elemen...

Specialization of a member of a template class for a template class parameter type

I have a templated class Matrix. I want to specialize a function for the type complex, where T can be anything. I have tried this : 6 template <typename T> 7 class Matrix { 8 public : 9 static void f(); 10 }; 11 template<typename T> void Matrix<T>::f() { cout << "generic" << endl; } 12 template<> v...

Calling a function within a class

I am having trouble calling a specific function within a class. The call is made: case "Mod10": if (!validateCreditCard($fields[$field_name])) $errors[] = $error_message; break; and the class code is: class CreditCardValidationSolution { var $CCVSNumber = ''; var $CCVSNumberLeft = ''; var $CC...

Using an element against an entire list in Haskell

I have an assignment and am currently caught in one section of what I'm trying to do. Without going in to specific detail here is the basic layout: I'm given a data element, f, that holds four different types inside (each with their own purpose): data F = F Float Int, Int a function: func :: F -> F-> Q Which takes two data eleme...

Variadic functions and arguments assignment in C/C++

I was wondering if in C/C++ language it is possible to pass arguments to function in key-value form. For example in python you can do: def some_function(arg0 = "default_value", arg1): # (...) value1 = "passed_value" some_function(arg1 = value1) So the alternative code in C could look like this: void some_function(char *arg0 = "d...