function

Rewrite simple ruby function to use a block

I dont know the correct terminology for what i am asking I tried to google it and couldnt ind anything for the same reason I am writing a ruby library, and i want to rewite the functions so they work as below as i prefer it for readability (inside a block?) at the moment i have a function that does this @dwg = Dwg.new("test.dwg") @dwg...

Function argument already initialized in function declaration C++

So here's my question in the function declaration there is an argument and it is already initialized to a certain value. What are the procedures to call this function and use that default value, or is it just a way to document code, telling other programmers what you expect them to use as a value for the parameter? Thank you. enum File...

How to find where implementation of a function is located in PHP in this case?

Hello, I was just traversing the workflow of zend framework and cant really find where the function "findByUri()" is located, I found the class it belongs , simply dumping it, but going through the hierarchy of that class(parents , interfaces and so forth) I cant really find it. I found where it is called from .... call_user_func_arra...

Evaluating variable within R loop

I'm trying to iteratively generate some functions using a For Loop: # Create a list to hold the functions funcs <- list() funcs[] # loop through to define functions for(i in 1:21){ # Make function name funcName <- paste( 'func', i, sep = '' ) # make function func = function(x){x * i} funcs[[funcName]] = func ...

global php class in functions?

Hi, is there a way to access one instance of a class inside functions in php? like this: include("class.php"); $bla=new Classname(); function aaa(){ $bla->DoSomething(); //Doesnt Work } $bla->DoSomething(); //works. thanks! ...

how do I make a portable isnan/isinf function.

I've been using isinf,isnan functions on linux platforms which worked perfectly. But this didn't work on osx, so I decided to use std::isinf std::isnan which works on both linux and osx. But the intel compiler doesn't recognize it, and I guess its a bug in the intel compiler according to http://software.intel.com/en-us/forums/showthread...

Regarding stack reuse of a function calling itself?

if a function calls itself while defining variables at the same time would it result in stack overflow? Is there any option in gcc to reuse the same stack. void funcnew(void) { int a=10; int b=20; funcnew(); return ; } can a function reuse the stack-frame which it used earlier? What is the option in gcc to reuse the same...

function to return the windows installed drive ?

i would like to know the function which returns the drive where the windows has been installed. for example if we run a program with following code in windows which is installed in "C:\" temp_char = getWindowsInstalledDrive(); should return "C:\". please point me to that function if you know. it should be a C/C++ function. Thanks...

Running Javascript function after variables are set

Hi and thanks. I have the following functions: // NATION var x, y, z; function flag(nation,area) { x = nation; this.nation=nation; var el=document.getElementById("desc"); el.innerHTML='The region you have selected is <b>'+area+'</b>'; document.getElementById("flag").innerHTML='<img src="images/flags/'+nation+'.jpg">'; } // SERVICE func...

send array to function in php

Here is the code : function dosomething () { ... do something with the array... like print value ! } $ar = array(1,2,3); dosomething ($ar); That piece of code work fine... What i try to do is to pass the array DIRECTLY to the function i have try this, non work... HELP ! dosomething ([12,32,56]); dosomething ({12,45,87}); dosomet...

Executing a function passed as an argument in Javascript?

Hey all, I'm trying to write a generic function that will block out the UI while an AJAX call is made. What I'm trying to do is have a function A run any other function passed in as an argument. This is what I've got so far: function blockWhileLoading(fn, msg) { if (msg == null) { msg = 'Please wait while the next page is loa...

Making MEDIAN a function like AVG in SQL server

Hello, I am new to SQL server. I need to calculate the median of the time stamp values in my table, Table1: _TimeStamp 2009-12-20 11:59:56.0 2009-12-20 11:59:56.5 2009-12-20 11:59:56.3 2009-12-20 11:59:56.4 2009-12-20 11:59:56.4 2009-12-20 11:59:56.9 There is a nice solution to calculating medians here, http://stackoverflow.com/que...

hash functions family generator in python

Hi, I am looking for a hash functions family generator that could generate a family of hash functions given a set of parameters. I haven't found any such generator so far. Is there a way to do that with the hashlib package ? For example I'd like to do something like : h1 = hash_function(1) h2 = hash_function(2) ... and h1 and h2 would...

get element after page loads

how do i call a function to count the number of divs with an id of 'd1' after the page loads. right now i have it in my section but doesnt that execute the script before anything in the loads? because it works if i put the code below the div tags... ...

MATLAB: How do I pass a parameter to a function?

I have the following function: function ypdiff = ypdiff(t,y) a = 0.01; b = 0.1; ypdiff(1) = -a*y(1)*y(2); ypdiff(2) = b*y(1)*y(2)-b*y(2); ypdiff(3) = b*y(2); ypdiff = [ypdiff(1) ypdiff(2) ypdiff(3)]'; If I want to solve this, I would call the ode45 function as follows: [t y] = ode45(@ypdiff, [to tf], yo); Bu...

PHP Foreach array as a error in function (invalid argument for foreach in...)

Im working on a new minimal Project, but i've got an error, i dont know why. Normally, i use arrays after i first created them with $array = array(); but in this case i create it without this code, heres an example full code, which outputs the error: <?php $i = array('demo', 'demo'); $array['demo/demodemo'] = $i; ?> <?php $i = array('...

In R, how do I set the first values of a long vector to the values of a shorter one?

In R, how can I overwrite the first values of a long vector with values obtained from a file, where the file contains possibly fewer values? Example: # fill with n=100 values vec1 <- runif(100) # read m values, where m <= n vec2 <- scan("myfile", sep="\n") # now want to set the first m values of vec1 # to the values in vec2 I coul...

How to execute some code when a file is modified using python?

Hello, I want to execute one funtion each time a file gets written with new data (gets modified) and I'm using Python. How can I do it? Thanks in advance! :) ...

How to do an if statement on a function in PHP?

I just realized that you can't just use an if statement on a function, for example this doesn't work: function sayHello() { echo "Hello World"; } if(sayHello()) echo "Function Worked"; else echo "Function Failed"; I also saw that a function can't be put as the value of a variable. So how can I do an if statement to check ...

List comprehension and functions

I'm a little confusing when try something like this b = [lambda x:x**i for i in range(11)] When I then try b[1](2) I have 1024 as a result that is wrong. But when I write so b = [(lambda i: lambda x:x**i)(i) for i in range(11)] all is OK >>> b[1](2) 2 >>> b[5](2) 32 It works fine but what's wrong in first code? ...