function

applying methods to object and private variables in javascript

hello, I am trying to apply a method to an existing object which involves using its private variables. The object is setup like so: function a(given_id) { var id= given_id; } now I want to apply some new method to it like so my_obj = new a('some_id'); my_obj.myMethod = function(){ alert(id); } now if I go my_obj.myMethod() ...

Another jQuery noob question about functions

I want to "functionalize" more of my jQuery code, instead of writing little standalone snippets. Here's an example. Let's say I have some li's that I'd like to use as triggers, like so: <li class="alpha-init" id="a-init">A</li> <li class="alpha-init" id="b-init">B</li> <li class="alpha-init" id="c-init">C</li> And some stuff I'd like ...

excel vba: functions as arguments of functions

There is no special type for functions, therefore it is hard for me to see, how to add functions as arguments to functions in excel vba. What I try to accomplish is something like this: function f(g as function, x as string) as string f = g(x) end function Concerning the motivation: I have a masse of little functions all repe...

call a function named in a string variable in c

Hello everybody, I want to call a function using a variable.Is it possible in C?? Actually, what I want to do is, get the function name from the user and store it in a variable say var. Now I want to call the function that has its name stored in the variable var. Can anyone tell me how this can be done in C? Actually I want to develop ...

How do I dynamically create functions that are accessible in a parent scope?

Here is an example: function ChildF() { #Creating new function dynamically $DynFEx = @" function DynF() { "Hello DynF" } "@ Invoke-Expression $DynFEx #Calling in ChildF scope Works DynF } ChildF #Calling in parent scope doesn't. It doesn't exist here DynF I was wondering whether you could define DynF in such a way...

Why should default parameters be added last in C++ functions?

Why should default parameters be added last in C++ functions? ...

In Erlang, is there a way to create an empty function?

I'm writing an Erlang function which prints every even number up to a given parameter. So far, I've written the function with guards like this: printEven(I,N) when I < N -> if I rem 2 == 0 -> io:format("~p~n",[I]), printEven(I+1,N); I rem 2 == 1 -> printEven(I+1,N) end; printEven(I,N) -> io:format("Done"). I'd really l...

Why are some functions extremely long? (ideas needed for an academic research!)

Hi, I am writing a small academic research project about extremely long functions. Obviously, I am not looking for examples for bad programming, but for examples of 100, 200 and 600 lines long functions which makes sense. I will be investigating the Linux kernel source using a script written for a Master's degree written in the Hebrew ...

Trying to return input from a function in C.

#include <stdio.h> #include <stdlib.h> #include <time.h> void initDeck (int deck[]); void showDeck (int deck[]); void shuffleDeck (int deck[]); int getBet (); main() { int deck[52]; int playerBet; char z; initDeck(deck); shuffleDeck(deck); showDeck(deck); playerBet = getBet(); //scanf ("%d\n", &playe...

What is the equivalent function for REPLACE(of Oracle) in sybase

strong text ...

How can I write Erlang's list concatenate without using the lists module?

The book I'm reading about Erlang has exercises in the back of it and one is to re-create the lists:append function. I could do this simply using the ++ operator, but isn't this really slow? And I think the point of the exercise is to do it using list operations that I write. So far the only approach that I could think of is to do some...

Is finding the equivalence of two functions undecidable?

Is it impossible to know if two functions are equivalent? For example, a compiler writer wants to determine if two functions that the developer has written perform the same operation, what methods can he use to figure that one out? Or can what can we do to find out that two TMs are identical? Is there a way to normalize the machines? E...

Function Parameter best practice

I have question regarding the use of function parameters. In the past I have always written my code such that all information needed by a function is passed in as a parameter. I.e. global parameters are not used. However through looking over other peoples code, functions without parameters seem to be the norm. I should note that these ...

jquery adds own events/functions to html elements of choice???

is it possible to add to an element type or maybe a css selection an own event function? something like: $("a").bind("blub", function() { alert("aaa" + this); }); $("a").get(0).blub(); i want define some functions which are only available for some special elements eg.: the <div class="myDivContainer">...</div> should have the func...

re-assigning parameters

I've seen the following in legacy code: public void someFunction(List myList){ List myList2 = myList; } Is there a good reason to re-assign parameters as local variables in a function? ...

KeyUp event of one button navigating to Enter event of other button

Hello, I have a keyUp event in button1 and EnterEvent in button2 When i press button1 and use my up arrow automatically control is navigating to Enter Event of button2 after entering into the KeyUp event of button1 Feels something fishy; Please help !! ...

How to Find All Callers of a Function in C++?

I'm refactoring some code in C++, and I want to deprecate some old methods. My current method for finding all of the methods looks like this: Comment out the original method in the source file in which I'm working. Try to compile the code. If a compiler error is found, then make a note comment out the call and try to recompile. Once th...

Re-Initializing "ThisWorkbook.Path"

First, thanks to those of you who gave me the suggestion on using "ThisWorkbook.Path". It worked like a charm. However, my code walks through seven (7) workbooks and when using "ThisWorkbook.Path" I can not re-initialize the "This.Workbook". Let me elaborate. This is the workbook where the Macro resides: Workbooks("Financial_Aggrega...

Making it clear a function can modify its parameters

Why is it that so many programming languages make it possible for a function to modify an object passed to it as a parameter, without having some sort of syntax to make that clear to the caller. Eg consider: SomeObject A(15), B B = DoSomething(A) print(A + " " + B + "\n) Reading that code you would expect the output to be something li...

help combining jquery functions in one file

I'm trying to combine a couple of functions on a single js file. I'm very new to jquery, right now I've got the functions working on separate files, being called on diferent pages (working on drupal), but the strings are so small that I thing it would be best to combine them all in the script.js file. Here are the functions: $(document...