function

Function in ASP.NET MVC

A function returns only one view. what if I want to return multiple views in a function? For example, I have this code: Function Index() As ActionResult Dim _news As DataTable = News.newsSelect() Dim _announcement As DataTable = Announcement.SelectAnnouncement() Return View() End Function I want to return _news and _ann...

Where should I put miscellaneous functions in a .NET project?

I found myself having to remove the first line of a string quite often while working on a text parser in C#. I put together a simple function to do that for me, but coming from a PHP background, I have no idea where to put it since I can't define a function outside a class. What's a customary way of doing that in .NET? Do I create a stat...

jQuery .click function doesn't work with middle button.

Hello, I have the following code: $(document).ready(function() { $("#TestLink").click(function() { $("#LinkHolder").html("test"); }); }); <span id="LinkHolder"> <a href="SomeLink" id="TestLink" target="_blank">Click here to test</a> </span> Everything works like a charm when I click with left ...

Haskell function composition

I am reading this tutorial on Haskell. They define function composition as the following: (.) :: (b->c) -> (a->b) -> (a->c) f . g = \ x -> f (g x) No examples were provided, which I believe would enlighten me as to what is being defined here. Can someone provide a simple example (with explanation...

gdb, set breakpoint on all functions in a file.

Is there a single command in gdb which can set breakpoints on all the functions in a given file ? I know about rbreak regex which sets breakpoints in matching regular expression functions, but my file doesnt have fixed patterned functions. In another way, is there a command by which I can set a breakpoint on a filename. Which will mean...

How do I write a function to permanently change a passed string

If i have char* str; how do I write a function that accepts str and can make changes to str so that, the changes persist after the function returns? what I have is: char *str = (char *) malloc(10); sprintf(str, "%s", "123456789"); //str points to 1 move_ptr(&str); //str points to 2 void move_ptr(char** str) { *str++; } is there ...

Python chat : delete variables to clean memory in functions?

I'm creating a chat daemon in python and twisted framework. And I'm wondering if I have to delete every variable create in my functions to save memory in the long run when multiple users are connected, or are those variable automatically clear?. Here's a strip down version of my code to illustrate my point: class Chat(LineOnlyReceiver...

Is there a function in c that will return the index of a char in a char array?

Is there a function in c that will return the index of a char in a char array? For example something like: char values[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char find = 'E'; int index = findInedexOf( values, find ); ...

jQuery - triggering function after click on <option> tag

Hello, I've got this code, that works in the latest version of firefox, opera and I'm not sure if in IE8, but it doesn't work in Google Chrome, Safari and ofc IE7 and 6. The script I have is a bit more complicated, but the problem is in this: <select> <option class='gramaz_vyber'>1</option> <option class='gramaz_vyber'>2</option> </s...

passing input from standard input to a file (C programming)

I wrote a program in C which has a function that processes files which can be passed to it by a file pointer. void process_my_file(FILE *fptr, ...) { /* do work */ } I would like to read some input from standard input and pass it to my function, without having to write the input to a temporary file. Would it be possible to pass it ...

In common-lisp, how do I modify part of a list parameter from within a function without changing the original list?

I'm trying to pass a list to a function in Lisp, and change the contents of that list within the function without affecting the original list. I've read that Lisp is pass-by-value, and it's true, but there is something else going on that I don't quite understand. For example, this code works as expected: (defun test () (setf origina...

buffering when passing input from standard input to a function

I asked about this yesterday, but I'm still having problems. I wrote a program in C which has a function that processes files which can be passed to it by a file pointer. void process_my_file(FILE *fptr, ...) { /* do work */ } I asked how to read input from standard input and pass it to my function, and it was recommended to me th...

Why use an object instance rather than class::staticFunction?

Why should I use an object instance to access member functions rather than class::staticFunction? ( or why not? ) ...

passing a block of memory from a function

I'm trying to figure out how to allocate a block of memory in a function and pass back a pointer to that block through one of the arguments. This is a C program. I seem to be having some trouble. Here's the code: void foo(char *ptr) { if (!(ptr = malloc(size))) printf("error"); /* code here */ printf("buffer a...

Conditionally defining functions

Is there any advantage to conditionally defining functions in PHP? For example, if I have a script similar to this function abc() { ... } function xyz() { ... } if (user_is_logged_in()) { ... abc(); ... xyz(); } else echo 'Not logged in.'; Would there be any advantage, and would it be legal, to mo...

Rounding output from by function in R

I'm trying to round an output from a simple by() function in R. This is what I have... > by(glaciers[,1:3],glaciers$activity.level,mean) glaciers$activity.level: Active aspect sun.duration latitude -9.444444e+00 1.771778e+03 3.247643e+09 ------------------------------------------- glaciers$activity.level: Inactive ...

Can I increment a char* passed to a function?

I'm working on a C++ application that will build a fixed-length record from a set of database fields. I'm writing a function that will accept the output record as a char*, the string to write, and the total length of the field. The purpose of the function is to copy the string to the current position of the char pointer, and then fill th...

How to apply Min or Max to each result of a function separately?

I have a function to calculate the inverse of a quadratic equation. By default it gives the two possible solutions: invquad<-function(a,b,c,y,roots="both") { #Calculate the inverse of a quadratic function y=ax^2+bx+c (i.e. find x when given y.) #Gives NaN with non real solutions. root1<-sqrt((y-(c-b^2/(4*a)))/a)-(b/(2*a)) ...

Can you store a function in a PHP array?

e.g.: $functions = array( 'function1' => function($echo) { echo $echo; } ); Is this possible? What's the best alternative? ...

How do you call a function defined in .bashrc from the shell?

In my .bashrc, I have a function called hello: function hello() { echo "Hello, $1!" } I want to be able to invoke hello() from the shell as follows: $ hello Lloyd And get the output: > Hello, Lloyd! What's the trick? (The real function I have in mind is more complicated, of course.) EDIT: This is REALLY caused by a syntax e...