Hi,
I've got a weird issue with Ruby. I want to read data from a file and put the data then into an array.
The weird thing is, it's working in another script which does basically, the same thing.
quoteArray = []
quoteFile = File.new("quotes.txt", "r") or die "Unable to open file..."
quoteFile.each_line { |line| quoteArray.push line }
...
Hi everyone.
Working with an array of dates (opening times for a business). I want to condense them to their briefest possible form.
So far, I started out with this structure
Array
(
[Mon] => 12noon-2:45pm, 5:30pm-10:30pm
[Tue] => 12noon-2:45pm, 5:30pm-10:30pm
[Wed] => 12noon-2:45pm, 5:30pm-10:30pm
[Thu] => 12noon-2:45...
I am trying to display results from a database where the results are contained in three tables. How do I echo out the results?
$p-> works, but $img-> or $branch-> doesn't. What am I doing wrong?
Example code is below
Sample controller:
$p_id = $this->uri->segment(3);
$this->load->model('One_model');
$data['prop'] = $this-...
Hi, I'm trying to initialise a structure which ends with an array[0] (here, char iedata[0]) for the actual packet payload. If I try to initialise it inline, like this:
struct some_packet pkt = {
.elem1 = blah, .elem2 = bleh,
.iedata = {
1, 2, 3, 4
}
};
I get a warning from gcc:
warning: (near initialization for ‘pkt.ie...
Hi everybody,
I have tried to get my head around building a recursive function to handle formatting of a unknown depth multi-dimensional array to HTML and nested Divs. I thought that it should be a piece of cake, but no.
Here's what I have come up with this far:
function formatHtml($array) {
$var = '<div>';
foreach ($array a...
Basically I have x amount of matrices I need to establish of y by y size. I was hoping to name the matrices: matrixnumber1 matrixnumber2..matrixnumbern
I cannot use an array as its matrices I have to form.
Is it possible to use a string to name a string (or a matrix in this case)?
Thank you in advance for any help on this!
for (int ...
So I have a couple of arrays
$array_1 = Array('one','two','three');
$array_2 = Array('red','blue','green');
Is there a dynamic way to create the Setters and Getters for an array with single value entries?
So the class would be something like:
class xFromArray() {
}
So the above if I passed $array_1 it would generate something li...
Hi everybody,
I have tried to make a function that iterates through the following array to flatten it and add parent id to children, where applicable. I just can't make it work, so I hope that anyone here has an idea of what to do:
Here's the starting point:
Array
(
[0] => Array (
[id] => 1
[children] => ar...
Given the following two indexed arrays:
$a = array('a', 'b', 'c');
$b = array('red', 'blue', 'green');
What is the most straighforward/efficient way to produce the following associative array?:
$result_i_want = array('a' => 'red', 'b' => 'blue', 'c' => 'green');
Thanks.
...
In Visual Basic within STATISTICA (a stats program), I am trying to run "LOWESS," an existing STATISTICA Matrix Library Function. I have defined my arrays based on the number of rows and columns I either know or expect they should have. Unfortunately, my macro gets an error of "(10025) Array has different number of indexes" when runnin...
k = [1,2,3,4,5]
for n in k
puts n
if n == 2
k.delete(n)
end
end
puts k.join(",")
# Result:
# 1
# 2
# 4
# 5
# [1,3,4,5]
# Desired:
# 1
# 2
# 3
# 4
# 5
# [1,3,4,5]
This same effect happens with the other array iterator, k.each:
k = [1,2,3,4,5]
k.each do |n|
puts n
if n == 2
k.delete(n)
end
end
puts k.join(",")
ha...
I am working on an algorithm in Python that uses arrays of int64s heavily. The arrays are typically sparse and are read from and written to constantly. I am currently using relatively large native arrays and the performance is good but the memory usage is high (as expected).
I would like to be able to have the array implementation not ...
I have my menu button bringing up a Settings option, which brings up numerous ListPreferences such as weight and various sizes for glasses (it's a BAC calculator app). I'll pick one example... weight will work.
Depending on how much you weigh it will affect your BAC. I have a int for Weight, set at 180. I would like someone to be able t...
I have an array like
Array
(
[0] => A
[2] => B
[4] => C
[6] => D
)
I want to remove the first element and then re-index array to get the output
(
[0] => B
[1] => C
[2] => D
)
Which PHP function i need to use?
Update
Input array is
Array
(
[0] => Array
(
[0] => Some Unwanted ...
READ FIRST: I have rewritten this question with the help of a friend to be hopefully more specific in what is required. It can be found here
I'm not very clear on n-cubes, but I believe they are what I am referring to as the square family.
New Question Wording:
Perhaps I wasn't clear enough. What I'm asking, is how to set a 1D array to...
I have an array of GLuint with fixed size:
GLuint textures[10];
Now I need to set a size of array dynamically. I wrote something like this:
*.h:
GLuint *textures;
*.m:
textures = malloc(N * sizeof(GLuint));
where N - needed size.
Then it used like this:
glGenTextures(N, &textures[0]);
// load texture from image
-(GLuint)ge...
I have an xml layout file which contains a few widgets including a Spinner
I want to display a list of strings in the spinner, the list is generated at runtime as a result of a function so it can not be in arrays.xml.
I tried doing:
String[] SpinnerItems = GetMyCustomItems();
((Spinner)findViewById(R.id.MySpinner)).setAdapter(new Ar...
You're given a big array with Integral type value, How do you move all zero values within it to the front portion of the array in a Time Efficiency way?
e.g. 0,1,72,3,0,5,9,0,6,51,0,3 ---> 0,0,0,0,1,72,3,5,9,6,51,3
Regards!
...
If I can pass in an array of a known size:
void fn(int(*intArray)[4])
{
(*intArray)[0] = 7;
}
why can't I return one:
int intArray[4] = {0};
int(*)[4] fn()
{
return &intArray;
}
here, the ")" in "(*)" generates "syntax error : )".
...
Hi There, I am trying to submit some data to a PHP script, however the PHP scripts expects the data to arrive in a specific format, like this example which is a dump of the post,
Array ( [save] => Add to shortlist [cv_file] => Array ( [849709537] => Y [849709616] => Y [849709633] => Y ) )
The process is currently that a user selects t...