A function (also called a procedure, method, subroutine, or routine) is a portion of code intended to carry out a single, specific task.
17
votes
7answers
1k views
Is_numeric_array() missing!
I found that in PHP (or i probably can't find it) a proper is_numeric_array($array) function is missing. So i created one. The problem is that i don't think it's great and i don't know how to improve ...
10
votes
3answers
491 views
Fastest Parameter Passing in delphi 7?
I have a function that accepts a big amount of data as a parameter (sometimes 1 megabyte) I was thinking which would be the fastest way to pass that data, dunno if I got this right, but here is what I ...
7
votes
6answers
456 views
What looks better in java
I wonder what is better code practice or just what looks better in Java.
Version 1:
protected Boolean doSomething(int amount) {
if (amount < 1) return false;
return ...
5
votes
2answers
131 views
Can I use this function to store passwords?
Just wrote this function, wondering if it's secure enough to store passwords in a database:
public static function hash($salt, $str) {
$salt = md5($salt);
$salt = ...
4
votes
3answers
175 views
Calling functions (or invoking methods) in constructor
I had written something like the following,
public class ClassName {
//private instance variables
public ClassName() {
//initialize instance variables
this.someFunction();
}
public void ...
4
votes
3answers
3k views
Min / Max function of 1D array in C / C++
Due to software constraints, I cannot use the standard libraries, math.h,algorithm, templates, inline, or boost. I am also using standard C (ISO C99) such that array is not a reserved keyword like it ...
4
votes
3answers
401 views
Javascript function and global variables
I have a getValue function which just grabs some numbers from an HTML page – How can I access those variables in later functions without passing them down the entire chain of functions? As they sit ...
4
votes
2answers
799 views
Do I always have to return something in an anonymous function?
I have inherited this snippet of jQuery JavaScript and am currently brushing up on my jQuery. NetBeans IDE complains that Anonymous function does not always return a value. So there is not always an ...
4
votes
3answers
225 views
C Split function review
I started learning C a week ago, and here is my implementation for the split function:
char** my_split(const char* str, char delim, int* size)
{
int index = 0, start;
char** results = NULL;
...
4
votes
1answer
220 views
Python, WeakBoundMethod
I've written this small class in Pyhon that wraps bound methods but does not prevent the deletion of self. Do you have any though on my code? Do you think I handle errors appropriately? Is it missing ...
4
votes
2answers
749 views
Function pointers and switch statements
I feel like I can make my switch statements more elegant with a function pointer, i.e. I'd like to set the digestLength and a pointer to a function in the same switch statement instead of setting the ...
4
votes
1answer
184 views
Is this code efficient?
I was wondering if this was a decent way of handling this function. Please take a look.
// Use Less Mixins from Theme Options to adjust Stylesheets before Parsing Less to CSS
add_filter( 'less_vars', ...
3
votes
2answers
180 views
Cross-post from SO- Palindrome finding function
I didn't know this site existed before now... awesome!
I just made a thread here: http://stackoverflow.com/questions/8511620/c-palindrome-finder-optimization
#include <iostream>
#include ...
3
votes
2answers
154 views
How to improve these Haskell functions?
This is the algorithm for calculating sun rise/set time at various places on Earth.
I took it as an example of multiple functions inside of one top function.
(if someone figure out better title, ...
3
votes
2answers
98 views
Please review my function code for adherence to C standards and whatever else could be improved to it
I am relatively new to C and would like some feedback on a function that I have written, if it adheres to C standards or if there are some other things which I could have done better/differently.
The ...