function

How do I flatten an associative array into an array with only values in PHP?

I have an array that has keys and values. For eg: Array ( [name] => aalaap [age] => 29 [location] => mumbai ) I want to convert the keys from this into values, but I want the values to apear right after the keys. For eg: Array ( [0] => name [1] => aalaap [2] => age [3] => 29 [4] => location [5] => ...

Bag of words model: 2 PHP functions, same results: Why?

Hello! I have two PHP functions to calculate the relation between two texts. They both use the bag of words model but check2() is much faster. Anyway, both functions give the same results. Why? check1() uses one big dictionary array containing ALL words - as described in the bag of words model. check2() doesn't use one big array but an ...

Equivalent for Python's lambda functions in Java?

Hi all, Can someone please tell me if there is an equivalent for Python's lambda functions in Java? ...

How can I find all the methods that call a given method in Java?

I need to get a list of all caller methods for a method of interest for me in Java. Is there a tool that can help me with this? Edit: I forgot to mention that I need to do this from a program. I'm usig Java Pathfinder and I want to run it an all the methods that call my method of interest. ...

How to run one last function before getting killed in Python?

Is there any way to run one last command before a running Python script is stopped by being killed by some other script, keyboard interrupt etc. Thanks for your help! ...

Java equivalent of function mapping in Python

In python, if I have a few functions that I would like to call based on an input, i can do this: lookup = {'function1':function1, 'function2':function2, 'function3':function3} lookup[input]() That is I have a dictionary of function name mapped to the function, and call the function by a dictionary lookup. How to do this in java? ...

A question about referencing functions in Javascript

The problem: I have a jQuery heavy page that has a built in admin interface. The admin functions only trigger when an admin variable is set. These functions require a second library to work properly and the second file is only included if the user is an admin when the page is first created. The functions will never trigger for normal use...

is PHP and C++ the only 2 places that we need to careful about what looks like pass-by-value is indeed pass-by-reference?

is PHP and C++ the only 2 places that we need to careful about passing a simple data type variable as a function argument and the value can be changed? such as $count = 2; foo($count); echo $count; and the 3rd line, echo $count display something other than 2. I only know of PHP and C++ where it can happen. Is there any other place ...

JQuery pass more parameters into callback

Hi all, Is there a way to pass more data into a callback function in Jquery? I have two functionsm and I want the callback to the $.post, for example, to pass in both the resulting data of the AJAX call, as well as a few custom arguments function clicked() { var myDiv = $("#my-div"); // ERROR: Says data not defined $.post("someurl.php...

Function pointer problem

I am trying to use a function pointer, but the 3 lines below just do not seem to want to cooperate... I'm getting error code C3867. Can you see what I'm doing wrong? In .h file void MyFunc(int, FILEINFO*(*)(FILEINFO*), FILEINFO*, int); The definition in the .cpp file void MyFunc(int number, FILEINFO*(*GetFiles)(FILEINFO*), FILEINF...

Point-free style with objects/records in F#

I'm getting stymied by the way "dot notation" works with objects and records when trying to program in a point-free functional style (which I think is a great, concise way to use a functional language that curries by default). Is there an operator or function I'm missing that lets me do something like: (.) object method instead of objec...

Non-anonymous function for jQuery: $( ..selector.. ).click( myFunc())

I've been exploring the use of custom functions for event handlers. In this stripped down example, I'm trying to get an alert to pop up when the user clicks a button. But the alert box pops up immediately as the page loads! What am I doing wrong? ( the commented portion does the exact same thing). If I define the bclick() function...

jQuery delay between animations

I have two elements that shouldn't be active at the same time, so when one is toggled I fade the other out, however I would like to be able to fade the open element out and then bring the other one in. Is there a way to do this that isn't a hack? <script ="text/javascript"> $(function() { $('#jlogin').click(function() { $('#login')....

Passing a pointer to an array in a different function in C

Ok, so I am trying to pass a pointer rgb that is initialized with memset to 0 and then looped through to place a 32 bit integer only in the bounds that I create with height and width input (h and w) as well as offset from the top left corner of the 2d array (x and y). after compiling, I seem to have the value with printf of the pointer ...

Make alias to document.getElementById in Javascript

How can I alias the function "document.getElementById" I've seen it done using $ Thanks ...

Functions inside functions in C

Hi. I'm making a code that is similar to this: #include <stdio.h> double some_function( double x, double y) { double inner_function(double x) { // some code return x*x; } double z; z = inner_function(x); return z+y; } int main(void) { printf("%f\n", some_function(2.0, 4.0)); return 0; } This compiles perf...

Javascript function parameters

Hello, I am working on a project which involves the ExtJS library and I came upon this piece of code which did not make sense (but it works). Please help :(. TreePanel.on('click', showDocumentFromTree); function showDocumentFromTree(node) { if (TreePanel.getSelectionModel().isSelected(node)) { dataStore.baseParams = { ...

Any sucess using UI-based program structuring?

Have you ever structured your source code based on your user interface parts? For example if your UI consists of: GridView for showing some properties 3D rendering panel panel for choosing active tools , then you name and group your variables and functions more or less in the following way: class Application { string Properties...

languages with functions that do not need parentheses?

IIRC, vb6 allowed function calls with no (). IIRC, it was allowed whenever the func didn't have a return value, and you could always use func(same, params, here). What other languages allow this? What do you think func with no parentheses should mean? What are the rules for them? Disclaimer: I am designing a language, so if you are a...

What's wrong with this function?

Hello, I'm using this function to determine whether my application should be online or offline: function online() { if ($online == "0") { if($_SESSION['exp_user']['userlevel'] != "1") { include("error/offline.php"); exit(); } } ...