function

Ruby: Array contained in Array, any order

Suppose I have the following Ruby code: array_1 = ['a', 'b'] array_2 = ['a', 'b', 'c'] some_function(array_1, array_2) # => True some_function(array_2, array_1) # => False some_function(['a', 'b'], ['a', 'd']) # => False some_function(['x', 'y'], array_2) # => False I am pretty much looking for some_function to return True when Param...

Can I share variables between different functions in PHP?

I'll try to explain with an example... Let's say I have two different functions, and one of them has a defined variable. In the second function, I don't wanna write the same variable again, can I simply use the variable from the first function in the second one WITHOUT redefining it in the second function? Something like: function a()...

im working on this php function list to make things easier.. im I go well so far? should i stop? am i doing something wrong?

<?php function con() { mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("main")or die(mysql_error()); $connected = $_SESSION['connected'] = true; } function getinfo() { $string = "SELECT * FROM info"; $q = mysql_query($string) or die(mysql_error()); while($q...

PHP security sha2: &$salt = null??

Hi, I am now creating a sha2 login form after researching and asking for help around online, I find the example code from this link below is quite useful and practical (I hope I am right!??), the only thing I don't understand is the way this programmer wrote the function and getting the salt value from the function. http://hungred.com/...

How to use jQuery Countdown Plugin functions

I am working on this piece of code using the jQuery Countdown Plugin it works but how ever if i try using a function with " function showPauseTime ()" I keep getting an error showPauseTime undefined. Can any body take a look at the code and tell me how I could solve this thanks $('#beginExercise').click(function() { //check if ter...

Does GCC create typedefs for arrays passed to functions?

While debugging some C code with gdb I came across something I've not seen nor heard of before! The compiler (gcc -O0) seems to have created a new type for passing an array of vectors to a function... I think! Have a look at the code and gdb information below: /* The Vector type - nothing unusual */ typedef struct { float x,y,z; } V...

Function help in c++

I'm trying to create a very simple function in c++ however I keep getting a "Link error". My code: #include <iostream> using namespace std ; int fun(int,int); main(){ int width,height,w,h,mult; cin>>width; cin>>height; mult = fun(width,height); int fun(int w,int h);{ w * h ; } cout << mul...

Is there any way to make a variable length array global in c++?

I've created a variable length array in one function, however I need to refer to this array in a second function. The problem occurs when I put the declaration above main() seeing as its length hasn't been defined yet, my compiler gets angry. How does one typically go about this? EDIT: Here is my code so far. I need to make the ar...

is it okay if i put all my db queries in one file?

i have function file called models.php, which stores all my database functions, for example // get the updates for the $user_id profile function getProfileUpdates($user_id) { $query="SELECT m . * , u.picture, u.username FROM notes m, user u WHERE m.user_id = u.user_id AND u.user_id ='$user_id' ...

How to call textual function in javascript/jquery?

For example: <input id="#me" type="button" callme="doAction()"/> <script> var result = callFunction( $("#me").attr('callme') ); /// ????????? </script> ...

Java: general function X->Y interface

Hi, I need an interface like: interface Function<X,Y> { Y eval(X obj); } Is there something like this in Java already or do I need to define my own? ...

Plot multiple functions in different intervals (Mathematica)

Hi, I need some help in Mathematica. I'm trying to plot functions that are stored in lists like: list = {{3x,1,5},{2x^2,0,4}} I need get an output similar to if I inputted: Show[Plot[3x,{x,1,5}],Plot[2x^2,{x,0,4}]] But I am not quite sure how this is achieved? Thanks in advance ...

What event does JQuery $function() fire on?

We have a JQuery $(function() statement as: <script type="text/javascript"> $(function(){ //Code.. }) </script> Dumb question - when exactly is this function executed? Is it when the entire HTML page has been downloaded by the client? What is benefit of using the wrapping your code within $(function() as opposed to just doing: ...

JavaScript lib reference variables in core script?

We have an HTML page with some global JavaScript variables. We have some utility functions that manipulate these variables. Can you move these util functions to a separate JavaScript file and include the file using the <script> tag? Wasn't sure if the functions in the external file could get/set the global variables that are defined i...

javascript function not calling possibly due to scope issue

I am looking to call my clear() JS function to clear the text values in some input fields on my webpage, but for some reason, the function doesn't appear to be called correctly. I believe this may be a scope issue, but I'm not sure. Here is my markup, script and styling kept together for ease-of-use currently, but will be mended once s...

What is wrong with this Lisp Function?

This function is a CLisp function, this is part of a homework problem, but which is supposed to be written in this different format (the second function). (defun range (m M) (cond ((> m M) '() ) ((= m M) '() ) ((< m M) (cons m (range (+ m 1) M ) ) ) ) ) (define (range m M) (cond ((> m M) '() ) ((= m M) '() ) ((< m M) (co...

Javascript question

John Resig wrote a nifty Class function, swanky. I'm trying to figure out what is going on, and have pretty much everything figured out except a single line: fnTest = /xyz/.test(function () {xyz;}) ? /\b_super\b/ : /.*/; A couple things immediately jump to mind, first xyz is never initialized as a variable; so why then does this work?...

using optimization function to fix two thresholds

sir, I have a data with m rows and n columns. how to generate an objective function for this data so that it calculates the values of two thresholds automatically instead of user specifying the thresholds. ...

PHP function fails to append results.

This is my function http://www.ideone.com/slpPe If i don't use function preg_match_all("{http://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}[^\s\"\\\'\&lt;&amp;]*}ix", $html, $marches); $download = $marches[0]; //var_dump(); $i = 0; for ($i; $i <= count($download); $i++) { echo "download|"; $links = $download[$i]; ...

How to restrict a anonymous function's boundary?

I saw a below code: Map(1 -> "one", 2 -> "two") map _._1 this return a Iterable[Int], but if I want to do nothing with map, how to do it? I want to do something like below, but the below code can't compile, I know because it a object instance not a function, but how to create a function to do x => x and use placeholder: Map(1 -> "on...