function

How to specialize a type parameterized argument to multiple different types for in Scala?

I need a back-check (please). In an article ( http://www.win-vector.com/blog/2010/06/automatic-differentiation-with-scala/ ) I just wrote I stated that it is my belief in Scala that you can not specify a function that takes an argument that is itself a function with an unbound type parameter. I have edited this question to try and si...

Get number of posts in a topic PHP

How do I get to display the number of posts on a topic like a forum. I used this... (how very noobish): function numberofposts($n) { $sql = "SELECT * FROM posts WHERE topic_id = '" . $n . "'"; $result = mysql_query($sql) or die(mysql_error()); $count = mysql_num_rows($result); echo numb...

need a button that calls a php function

I need to have a button that calls a php function to resort displayed data from the db. How the heck do I do this? I just found out that because php is server side this sucks. So any help please? ...

Where do I put utility functions in my Python project?

I need to create a function to rotate a given matrix (list of lists) clockwise, and I need to use it in my Table class. Where should I put this utility function (called rotateMatrixClockwise) so I can call it easily from within a function in my Table class? ...

pointer to const member function typedef

I know it's possible to separate to create a pointer to member function like this struct K { void func() {} }; typedef void FuncType(); typedef FuncType K::* MemFuncType; MemFuncType pF = &K::func; Is there similar way to construct a pointer to a const function? I've tried adding const in various places with no success. I've played ...

Python - output from functions?

Hi I have a very rudimentary question. Assume I call a function, e.g., def foo(): x = 'hello world' How do I get the function to return x in such a way that I can use it as the input for another function or use the variable within the body of a program? When I use return and call the variable within another functions I get a Na...

Can overloading is possible with two version of function, constant member function and function without const

Hello, I just came across various overloading methods like type of parameter passed, varying number of parameters, return type etc. I just want to know that can I overload a function with following two version //function which can modify member String //constant member function String Please let me know the reason behind it. Than...

how to use a bash function defined in your .bashrc with find -exec

my .bashrc has the following function function myfile { file $1 } export -f myfile it works fine when i call it directly rajesh@rajesh-desktop:~$ myfile out.ogv out.ogv: Ogg data, Skeleton v3.0 it does not work when i try to invoke it through exec rajesh@rajesh-desktop:~$ find ./ -name *.ogv -exec myfile {} \; find: `myfile': No...

How to use R's ellipsis feature when writing your own function?

The R language has a nifty feature for defining functions that can take a variable number of arguments. For example, the function data.frame takes any number of arguments, and each argument becomes the data for a column in the resulting data table. Example usage: > data.frame(letters=c("a", "b", "c"), numbers=c(1,2,3), notes=c("do", "re...

How to find a value in array and remove it by using PHP array functions

How to find a value exist in an array and how to remove it. If any php builtin array functions for doing this. After removing I need the sequential index order. any body knows please help me. ...

how to Invoke User-Defined Functions That Return a Table Data Type

here my code- create function dbo.emptable() returns Table as return (select id, name, salary from employee) go select dbo.emptable() error: Msg 4121, Level 16, State 1, Line 1 Cannot find either column "dbo" or the user-defined function or aggregate "dbo.emptable", or the name is ambiguous. while when I run sp_helptext emptabl...

Excel: Use text and time function.

I have a cell that takes the time value from another cell. I want to include an addition of this time as well as a dash '-' to format the time into a sort of schedule. Example: userinput cell: 5:00 AM Formated cell (how I would like it to look): 5:00 AM - 3:30 PM What would the function be to get something like this? ...

Use jquery cookies in showing/hiding elements (jQuery)

Hello, How to use jquery cookies in showing/hiding elements in a page ? I got the plugin from here Tried some method but i am not successful. I used slideUp() and slideDown() functions to show/hide elements. When a element is slided up a cookie should be set. when the page is refreshed, the element should be in slided up position How...

What does it mean to pass a &variable to a function? E.g., string& insert ( size_t pos1, const string& str );

I understand passing a pointer, and returning a pointer: char * strcat ( char * destination, const char * source ); You're passing a variable that contains the address to a char; returning the same. But what does it mean to pass something using the reference operator? Or to return it? string& insert ( size_t pos1, const string& str ...

C character from string shortcut

In javascript I am used to just being able to pick any character from a string like "exm[2]" and it would return to me the third character in a string. In C is there a way to do that or something without a function that requires a buffer? ...

How to Create an Array from a Single Variable and Form Multiple Foreach Loops?

I'm fairly proficient in HTML/CSS, but very new when it comes to the likes of PHP and Javascript. I've jumped headfirst into coding Wordpress shortcodes (basically php functions), and so far, through trial and error and seemingly endless browser refreshes, I've been able to figure everything out. I just hit a huge wall though, hence wh...

Haskell IO Passes to Another Function

This question here is related to http://stackoverflow.com/questions/3066956/haskell-input-return-tuple I wonder how we can passes the input from monad IO to another function in order to do some computation. Actually what i want is something like -- First Example test = savefile investinput -- Second Example maxinvest :: a maxinvest...

C++: Where can I define the body for a private function?

Hi, I have a header like this (header guards not shown): class GameSystem { public: GameSystem(Game *pcGame); virtual ~GameSystem(); void Setup(); private: void InitGame(); void RunGame(); void ExitGame(); Game *m_pcGame; /* Properties */ int m_nWidth; int m_nHeight; int m_nFps; bool m_b...

Mysql count rows function

I have created a simple function which takes user id and show total no. of post by the user id function totalpost($user_id){ $sql = 'SELECT * FROM posts WHERE u_id='.$user_id; $total = mysql_num_rows(mysql_query($sql)) or die(mysql_errno()); return $total; } Its working fine, but when 0 record found, it not returns anything. I want ...

jQuery Button.click() event is triggered twice

Hello everyone I have the following problem with this code: <button id="delete">Remove items</button> $("#delete").button({ icons: { primary: 'ui-icon-trash' } }).click(function() { alert("Clicked"); }); If I click this button, the alert show up two times. It's not only with this specific button but with ...