The documentation on the Bigarray module is somewhat vague. It states that the purpose of arrays in that module is to hold "large arrays", but it doesn't really define what it means by "large array". When should I use a Bigarray over a regular array? Is there a certain number of elements beyond which I should just use a Bigarray? Is ...
I'm currently working through some exercises in a c++ book, which uses text based games as its teaching tool. The exercise I am stuck on involves getting the pc to select a word from a const array of words (strings), mixing the letters up and asking the player to guess the word. This was easy, but as a follow on the book asks to add the ...
I have a situation where I want my program to read in some numbers that will define the size of a two dimensional array (used as a matrix). I originally argued that the only way to do this would be to use a malloc call to put the array on the heap, something like this:
matrixElement* matrix = malloc(sizeof(matrixElement) * numRows * num...
Got this question in an interview today, and its optimized solution stopped me cold (which blows, because I really wanted to work for this company...)
Given a single array of real values, each of which represents the stock value of a company after an arbitrary period of time, find the best buy price and its corresponding best sell price...
I am beginning to write a translator program which will translate a string of text found on a file using parallel arrays. The language to translate is pig Latin. I created a text file to use as a pig latin to English dictionary. I didn't want to use any two dimension arrays; I want to keep the arrays in one dimension.
Basically I want to...
I want to have a url like http://localhost/folder1/folder2/folder3/file
Then i want mod_rewrite to convert it to $_GET['d'] in the url it would look like d[]=folder1&d[]=folder2&d[]=folder3
Is this possible?
Thank You.
...
Is there anyway to directly access the data returned in an array without a temporary variable?
Currently, my code is as follows:
function getData($id) {
// mysql query
return mysql_fetch_array($result);
}
$data = getData($id);
echo $data['name'];
Is there a direct way to get the returned data without the temporary variable?
...
I have an array of values all well within the range 0 - 63, and decided I could pack every 4 bytes into 3 because the values only require 6 bits and I could use the extra 2bits to store the first 2 bits of the next value and so on.
Having never done this before I used the switch statement and a nextbit variable (a state machine like dev...
I would like to read a text file and input its contents into an array. Then I would like to show the contents of the array in the command line.
My idea is to open the file using:
inFile.open("pigData.txt")
And then to get the contents of the file using:
inFile >> myarray [size]
And then show the contents using a for loop.
My prob...
The Java Docs for the method
String[] java.io.File.list(FilenameFilter filter)
includes this in the returns description:
The array will be empty if the directory is empty or if no names were accepted by the filter.
How do I do a similar thing and initialize a String array (or any other array for that matter) to have a length 0?
...
I place the MC in an array and would like to remove it later on from an index maybe till the end.
//Removeing MC from stage, from an index till the end
LISTmc.removeChild(listArray[clickedIndex+1]);
//Removing MC starting from an index till the end
listArray.splice(clickedIndex+1);
Is the way to remove the MC from the stage same with...
Hello,
I'm trying to rewrite code I've written in matlab in C++ instead.
I have a long cell in matlab containing 256 terms where every term is a 2x2 matrix. In matlab i wrote it like this.
xA = cell(1,256);
xA{1}=[0 0;3 1];
xA{2}=[0 0;13 1];
xA{3}=[0 0;3 2];
and so on...
What would be the easiest thing to use in c++?
Can I give ...
I am reading in a bunch of multi-dimensional arrays, and while digging through them I have noticed that some of the keys are incorrect.
For each incorrect key, I simply want to change it to zero:
from:
$array['bad_value']
to:
$array[0]
I want to retain the value of the array element, I just want to change what that individual key...
Hello everyone,
I have a problem when i use json and array. And i need your help.
Here is my code:
while($row = mysql_fetch_assoc($result)){ echo json_encode($row); }
The result is:
{"id":"1","title":"event1","start":"2009-11-10 14:18:15","end":"2009-11-03 14:38:22","allDay":"false","url":null}{"id":"2","title":"event2","start":"20...
Preg_match gives one match.
Preg_match_all returns all matches.
Preg_split returns all splits.
How can I split only the first match?
Example:
preg_split("~\n~",$string);
This is what I want:
array(0=>'first piece',1=>'the rest of the string without any further splits')
...
I have a multi-dimensional array that I'd like to use for building an xml output.
The array is storing a csv import. Where people[0][...] are the column names that will become the xml tags, and the people[...>0][...] are the values.
For instance, array contains:
people[0][0] => first-name
people[0][1] => last-name
people[1][0] => Bob
p...
Ok, been scratching my head on this one for a bit now... seems related to this ol' chestnut
Here's my problem:
var testlength = theForm.elements.length;
var testlastelement = theForm.elements[testlength].type;
testlength returns 60
BUT!
testlastelement comes back as "undefined" (null or not an object)
What gives?
FWIW, my page ha...
Why does this work the way it does? I thought it had something to do with pass-by-reference/value, but that's not the case. Does it have something to do with the new block scopes?
def strip_ids(array)
array.each{ |row| row.reject! {|k, v| k =~ /_id/ } }
end
class Foo
attr_accessor :array
def initialize
@array = []
@array...
For instance
Array(
[0] => Array
(
[0] => hello
[1] => open
)
[1] => Array
(
[0] => good
[1] => center
)
[2] =>...
I'm reading a file using bufferedreader, so lets say i have
line = br.readLine();
I want to check if this line contains one of many possible strings (which i have in an array). I would like to be able to write something like:
while (!line.matches(stringArray) { // not sure how to write this conditional
do something here;
br.readL...