A function (also called a procedure, method, subroutine, or routine) is a portion of code intended to carry out a single, specific task.

learn more… | top users | synonyms

1
vote
2answers
71 views

Making datastore inserts with Google App Engine and WTForms

I have a class for making datastore inserts with Google App Engine and WTForms. Now I want to refactor it into smaller units but I'm not sure how to do it. Can you help me find what needs to be done? ...
1
vote
1answer
25 views

Injecting an object in each function in Go

My current project uses a database represented as object. Furthermore I want to implement methods like CreateUser(), ...
4
votes
1answer
61 views

MVC'd login form

I've written this small MVC login application as an example for someone, would anyone let me know what they think of it? index ...
8
votes
2answers
129 views

Find arity of a rebol function

I needed a way to find the number of arguments a function or operation in Rebol accepts (the functions arity). I could not find any direct support for this in the language, so I made my own ...
0
votes
0answers
72 views

Time-course of drug amounts in the different compartments of a pharmacokinetic system

I am looking for a way to speed up applying my function to every individual in the data frame. Currently I am using the ddply but it is very slow for big data sets. ...
4
votes
1answer
55 views

Luhn algorithm MS-SQL

This a solution Luhn algorithm for credit validation. This algorithm is a basic one inspired by wikipedia. I mean no check for length, type, and so on. You can enhance the base code as you want it to ...
1
vote
0answers
45 views

Efficient Strip Special Characters

I have a private function in PHP that takes a given URL string and just leave the Alpha or numeric and certain punctuation left. I need the stripping of string due to having it match against ...
1
vote
1answer
30 views

Naming a complex crud function

I have a function below that does the following uses a bunch of smaller CRUD operations which I call create, ...
3
votes
1answer
139 views

Counting Lines and Sum of Lines

I have a small function that when passed a str that names a file that contains a program; it returns a 2-tuple with the number of the non-empty lines in that program, and the sum of the lengths of all ...
3
votes
2answers
137 views

Recursive functions for sorting

I made a few recursive functions for learning purposes which do a variety of tasks. Here is my current and functioning code: ...
5
votes
2answers
211 views

Functions with mutable and non-mutable named tuples

I am making some functions within a function for learning which when passed information about a named tuple: it returns a reference to a class object from which we can construct instances of the ...
3
votes
3answers
124 views

Functions taking iterables: peaks, compress, and skipper

I am just testing out a few small functions for learning purposes: ...
2
votes
1answer
46 views

Use of dictionary for file-saving function

I have the following function: ...
3
votes
1answer
84 views

Passing arguments to a SendMail function referenced by addressOf operator

I am trying to send daily mail alert to users based on some timer values. For that I've used Addhandler to call the sendmail() ...
5
votes
2answers
236 views

Interleaving values from several iterables

I am new to Python and am trying to see if there is a cleaner way to write my code. The following code take iterables as parameter it produces the first value from the first parameter, then the first ...
1
vote
0answers
45 views

AI for an online contest

I'm actually creating an AI for the online contest Vindinium. The fact is that's also an exam for my school because I'm going to have a note with that work. I created an AI based on ants pheromones ...
3
votes
2answers
133 views

Magic square functions

I'm writing a program for magic square and I'm a relative beginner to C++ and programming. I was hoping someone could help me find alternate or better ways to implement my code. This is the main ...
4
votes
3answers
106 views

Defining a certain member function

Consider the following: ...
4
votes
1answer
128 views

Google Maps Api Lat/Lng pair to Fusion Tables Query

I'm trying to learn Javascript, and as a practice tool I recently wrote a simple web app that uses the Google Maps API Geocoder to get the latitude and longitude of a location (user input), manipulate ...
2
votes
2answers
72 views

Improving the BigPicture

I'm currently working on the library BigPicture.js with live demo here. There surely are lots of little improvements possible in the main .js file (< 300 lines of code), here are some little ...
3
votes
1answer
693 views

Reading numbers from a text file into an array

I work in a project based on C language. I want to read a file that contains two lines of numeric characters. Example 9 8 9 5456 32 2 45 34 98 5 I want to ...
0
votes
0answers
51 views

Signature verifier for a javascript/node.js function

I wrote a function that verifies the arguments against an expected set of arguments. test('hello', 'world'); ...
4
votes
0answers
126 views

Wrap function pointers in template classes

I'm working on a C++ library for Arduino and other embedded systems. I'm currently working on wrapping up function pointers and member-function pointers into two C++ template classes (function and ...
1
vote
1answer
107 views

Function to return percentages in Python

I created a function for giving me percentages from two integers. I want two decimal places in the result. ...
0
votes
2answers
81 views

Pick a column for each row by column-header name

I am parsing a table: |-------| |Bar|Foo| |-------| | 5 | 6 | |'f'|'g'| | 1 | 8 | |_______| I've tried a number of ways of ...
2
votes
1answer
797 views

Defining functions in Vigenere cipher

I'm trying to learn the process of defining/calling a (somewhat) complex function. I understand the main idea, and can do it on a small (simple) scale. A simple example: ...
3
votes
2answers
144 views

Cleaner structure for Battleships code

The code provided is working fine, but I would like to see if there is room for improvement for the code provided: ...
1
vote
1answer
154 views

Checking form input for an AJAX request

I've made a few functions to check form input for an AJAX request. I am still getting used to JavaScript and some of these AJAX requests. I am looking for any suggestions to better work with ...
3
votes
1answer
66 views

Improving fading functions

Regarding these two functions, which do the same thing... Large and confusing: ...
3
votes
2answers
129 views
2
votes
1answer
34 views

Reusing select statement

I am checking if there are any rows in a table with some conditions. If there are more than 1 row, it should filter again with some more conditions. ...
12
votes
2answers
635 views

Function wrapper like std::function that uses “small buffer” allocation

My Function class is similar to std::function with the small-buffer optimization. However, it always uses a small buffer and ...
3
votes
1answer
112 views

Web page based on a sample from a book

I've created a web page based on a sample from a book. It works fine, but seems to have become too complicated. ...
11
votes
2answers
154 views

Mapping enum to function - request / response library encapsulation

I'm writing code for an embedded device - specifically, a camera. The idea is different camera manufacturers can implement the code so it properly works with their camera. Here, I'm encapsulating the ...
3
votes
2answers
158 views

Returning nested array with added key=>value

This works, but do I have to make a new array, result, or is there a way to just insert the field I need into each $key of the ...
1
vote
1answer
103 views

Optimizing method and removing useless code

I have such function which is parsing beautiful soup elements: ...
4
votes
2answers
241 views

Updating necessary data using just one function

My objective is to update necessary data using one function instead of having different functions to update different fields. So, I've created one and I think this is not really elegant, efficient or ...
6
votes
1answer
76 views

Drawing and Painting a Menu Component

I have produced a working menu component for a project I'm working on, but would like to reduce the amount of code used and improve the methods - especially in the Paint implementation - still ...
3
votes
1answer
94 views

Taking data from staging table and inserting into target tables

I have the below mentioned function written in plpgsql which is working fine. I want someone to review it and let me know how can I improve its performance. This function takes data from staging ...
10
votes
2answers
97 views

Scalability of running commands from user input

Here is some code I have that has been extracted and shrunk down from a project of mine. ...
6
votes
1answer
142 views

Test if Excel is open without relying on catching an error

Getting a hook on an open instance of Excel is something I do all the time. I'm now questioning if I'm doing this the best way. I'm particularly concerned with the fact that I rely on the ...
5
votes
1answer
182 views

Soccer winning probabilies from ELO strength indicator

What can I do to improve this function, which calculates the win expectancy of a soccer team, given their strength: ...
3
votes
2answers
488 views

How to organize a paint cost calculator using functions?

This is the task I was given after completing my program. I don't have a clue what procedures and functions are to be honest. Therefore I have no clue on how to break down my program into different ...
1
vote
2answers
101 views

Series of repetitive content-loading functions

A friend helped me put the following code together. As can be seen, it's made up of a series of repetitive loadContent() functions. I've just shown the first two ...
2
votes
1answer
163 views

How can I optimize my insert function for the cuckoo hash table?

I'm working on class for a hash table where collisions are corrected using cuckoo hashing, I had difficulty writing the insert function, the function is supposed to insert the key if the ...
4
votes
1answer
1k views

jQuery animate opacity, fade, & slide up page load effect

This is the first time I've actually made my own jQuery script from scratch, because I couldn't find exactly what I was looking for. My code works how I want it to, although I don't know if I did it ...
0
votes
2answers
44 views

Default arguments for functions in Python [closed]

I was wondering what is the convention for return default types for python functions for e.g the below should Official return ...
10
votes
2answers
430 views

Hangman game with hard-coded word or phrase

I feel that this implementation can still be simplified. I've tried to keep variable scopes low and have used as much of the standard library as I could. It currently works with a hard-coded word or ...
3
votes
2answers
92 views

This snippet of scheme calculates a value in pascal's triangle

I'm working through SICP and have implemented exercise 1.11 (Pascal's Triangle). What I'm curious about here is performance considerations by defining functions within the main function. I would ...