function

What is different about C++ math.h abs() compared to my abs()

I am currently writing some glsl like vector math classes in c++, and I just implemented an abs() function like this: template<class T> static inline T abs(T _a) { return _a < 0 ? -_a : _a; } I compared its speed to the default c++ abs from math.h like this: clock_t begin = clock(); for(int i=0; i<10000000...

PHP - My array returns NULL values when placed in a function, but works fine outside of the function

Okay, let me see if I can explain this. I am making a newspaper WordPress theme. The theme pulls posts from categories. The front page shows multiple categories, organized as "newsboxes". Each post should show up only ONCE on the front page, even if said post is in two or more categories. To prevent posts from duplicating on the front ...

"Unhandled exception"/"Access violation writing location" error with referenced array pointers

I'm trying to fill a pointer matrix with values from a text file. It's a double pointer to a simple struct with 2 ints, time and tons. void get_changes(change** &c){ ifstream file("change_data_time.prn"); //data file, time only, size is the same as tons string line, var; //string placeholders for the getlines ...

Call javascript from objective-c, only works with system functions like alert() etc / phonegap

hi havent found the solution yet in the forum. i want to call a function i created in the index.html via a objective-c function. As explained in stringByEvaluatingJavaScriptFromString so the network detection doesnt work for me the function gets called but no javascript is called in the index.html here is the code i use - (void)up...

C function only called once and cyclomatic complexity

Hi! I think this question is more about style: I have an algorithm that has a very high CC (and a lot of lines!). I want to reduce it, and it's easy since there are pieces of code that can be grouped. The problem is that doing things this way I would have a "big" function calling "small" functions which are only called once. In my opin...

Assigning function within function object without invoking the function itself.

Dear experts, I am trying to assign an function within an function object property without actually invoking then function itself. for instance, I have the following function object class definition function objectOne(name, value, id){ this.name=name; this.value=value; this.id=id; this.methodOne=methodFunction(this);...

How can I pass two lists to a Perl subroutine?

Is it possible to pass two lists to a sub in Perl, for example: sub Foo { my(@list1,@list2) = @_; } I know I could make @_ two lists, with each sublist being the desired argument, I'm just wondering if there is a cleaner way ...

How to run a bat file from a C# program?

so i need a simple function to run bat file. How to do such thing? ...

how to use expressons as function parameters in powershell

This is a very simple task in every language I have ever used, but I can't seem to figure it out in PowerShell. An example of what I'm talking about in C: abs(x + y) The expression x + y is evaluated, and the result passed to abs as the parameter... how do I do that in PowerShell? The only way I have figured out so far is to create ...

Parsing getopts in bash

I've got a bash function that I'm trying to use getopts with and am having some trouble. The function is designed to be called by itself (getch), with an optional -s flag (getch -s), or with an optional string argument afterward (so getch master and getch -s master are both valid). The snippet below is where my problem lies - it is...

problem with random function in python

how can i using random function (in python) to choice a string from a txt list ? thanks a lot ...

What is the function from which all other functions can be derived?

I seem to remember reading about a function that could be used to make all other functions. Does anyone know what it is? And how could such a function be used? I can't remember where I read it and my google-fu is not strong enough. ...

PHP callback function not being called

Hi everyone, I've got the following code: function failureCallback($host, $port) { print "memcache '$host:$port' failed"; } $this->memcache = new Memcache; ## bool Memcache::addServer ( string $host [, int $port = 11211 [, bool $persistent [, int $weight [, int $timeout [, int $retry_interval [, bool $status [, ca...

bash: function + source + declare = boom

Here is a problem: In my bash scripts I want to source several file with some checks, so I have: if [ -r foo ] ; then source foo else logger -t $0 -p crit "unable to source foo" exit 1 fi if [ -r bar ] ; then source bar else logger -t $0 -p crit "unable to source bar" exit 1 fi # ... etc ... Naively I tried to create ...

MySQL function return more than 1 row

I'd like to write a MySQL stored function that returns multiple rows of data. Is this possible? It seems to be locked at 1 row -- can't even return 0 rows. For example DELIMITER // create function go() RETURNS int deterministic NO SQL BEGIN return null ; -- this doesn't return 0 rows! it returns 1 row -- return 0 ; END // DEL...

Oracle function always returning null

I can't get this function to behave as i desire. Can anyone point out why it always returns null instead of CURRENT_TIMESTAMP? CREATE OR REPLACE FUNCTION nowts RETURN TIMESTAMP IS vTimestamp TIMESTAMP; BEGIN SELECT type_date INTO vTimestamp FROM param_table WHERE param_table = 3 AND exists ( SELECT * FROM param_tab...

Cast LINQ Function Result to Domain Object

Hello, I have a table valued function to perform full text search on SQL server. The result type of my full text search function in LINQ is a special autogenerated type which includes KEY and RANK in addition to my regular domain object properties. So, if my regular domain object is PERSONS (with properties FirstName, LastName etc.), ...

How do you find a functions virtual call address in assembly?

I've googled around but i'm not sure i am asking the right question or not and i couldn't find much regardless, perhaps a link would be helpful. I made a c++ program that shows a message box, then I opened it up with Ollydbg and went to the part where it calls MessageBoxW. The call address of MessageBoxW changes each time i run the ap...

Delay function from running for n seconds then run it once. (2minute question)

TLDR I have a function that runs on the end of a pan in an openlayers map. Don't want it to fire continously. I have a function that runs on the end of panning a map. I want it so that it will not fire the function until say 3 secconds after the pan has finished. Although I don't want to queue up the function to fire 10 or so times li...

C question: error: expected ')' before '*' token

Edit 2 Thanks for all the suggestions, I edited the code below from the suggestions given. However, it still doesnt seem to compile. But nevertheless, thanks a lot for the help hands. Edit I apologize for not putting the pcb struct into the code snippet. There is a struct called pcb defined in above the two structs I originally posted...