arrays

How can I delete empty arrays/refs from a Perl hash?

Lets say I have the following Perl hash: %hash = ( 'A' => { 'B' => ['C', 'D', 'E'], 'F' => { 'G' => [], 'H' => [] }, 'I' => [] } ); and I'd like to get rid of the []'s to get the hash result below: %hash = ( 'A' => [ 'B' => ['C', 'D', 'E'], 'F' => [ 'G', 'H', 'I' ] ...

jquery .each() take image and title from a class and add each one to 5 diffrent div's

I am stuck on this what I am trying to do is: there will be div's with the class of feature there could be an x amount of them but i only want 5 most resent. take the img src and a.html witch is a title link from each and add each one to 5 containing divs at the top of the page. the image as a background-image and the other prepend to an...

Relational container in c++ and polymorphism issues

Hi everyone. I would appreciate any help with this. I have a simple container template class Dataset. Also there is a specialization to allow a different implementation when a Dataset of Datasets is instantiated. Since a Dataset of Datasets would be a heterogeneous container, there is a base abstract class List wich must declare a com...

Javascript : How should I run one `for`, for two arrays?

I have: var array1 = []; var array2 = []; array1 contains 1,2 array2 contains 3,4 And I want to do this: for(var a in array1){ for(var b in array2){ doSomething(array1[a],array2[b]); } } But the problem is that function doSomething() runs twice for each array because of the two for's. How should run it just once...

Parse js arrays in ruby

Hi All, i've js file that holds Array objects and data assigns var A_1_val = new Array(7); var B_1_txt = new Array(7); A_1_val[0] = '111'; B_1_txt[0] = 'utf8_content'; A_1_val[1] = '222'; B_1_txt[1] = 'bar'; etc.. need to get these arrays in ruby. found http://github.com/jbarnette/johnson, but it can't correctly return a...

Using NSMutableArray in a class

Whenever I try to add something to my array in the method nothing gets added to the array. I'm wanting it to when you press the button it will add a new object to the array. // JBNumberGeneration.h #import <Cocoa/Cocoa.h> @interface JBNumberGeneration : NSObject { IBOutlet NSTextField *displayLabel; int randNum; int level; int i...

using array difference ([array] - [other array] )with different, equivalent instances

I'm trying to use the difference method (array1 - array2), and it isn't working as expected. My unit test: a = DeepsEdge.new(Set[1,2]) b = DeepsEdge.new(Set[3,4]) c = DeepsEdge.new(Set[3,4]) assert a != b, "these are equal and should not be" assert_equal c, b assert_not_equal a, b assert_not_same c, b x = [a,b] y = [c] assert_equal x,...

C struct with many [char array ] problem.

I have a struct with many char array like this (and it works) : struct maytinh { char tenmay[10]; char mamay[10]; char test[10]; float manhinh; int gia; }; But if its like this, struct maytinh { char tenmay[99]; char mamay[99]; char test[99]; float manhinh; int gia; }; it breaks when I compil...

Problem while scanning a char and float simultaneously.

I am trying to take five character and 5 float input. main() { char c[5]; float q[5]; int i; for(i=0;i<5;i++) { printf("\n%d ",i); scanf("%c",c+i); scanf("%f",q+i); } } But the output is absurd. After two sequential scans, it skips third scan and then again skips fifth scan. I am not ab...

How to exit the loop with the number 0? but now i have other problems

package hw3; public class Main { public static void main(String[] args) { final int NumberOfElements = 1000; int[] num = new int[NumberOfElements]; int var = 0; //create input java.util.Scanner input = new java.util.Scanner(System.in); for (int i = 0; i < NumberOfElements; i++) { ...

java - list question - Why did it print out -4 on the 3rd printout when i ran it?

package javaapplication8; public class Main { public static void main(String[] args) { int[] list1 = {1, 2, 3,4}; int[] list2 = {5, 6, 7,8}; for (int i = 0; i < list2.length; i++){ System.out.print(list2[i] + " "); } System.out.println(""); list2 = list1; for (int i = 0; i < list2.length;...

How do I find max values in a multidimensional array?

I Have an array which looks like this: Array ( [0] => Array ( [0] => Array ( [product] => 2003 [date] => 2010-09-15 13:27:35 [status] => 3 ) [1] => Array ( [product] => 2004...

How to order an array of objects by a certain property in XCode

Let's say I have an array of custom objects. The custom class looks like this Person ------- name number Now let's say I want to rearrange the array of these objects so that the objects are sorted by the number. How can this be done? ...

java - Can someone explain to me what is going on? there's a lot of things going on in which I haven't been taught yet.

public class Main { public static void main(String[] args) { int[] x = {1, 2, 3}; increase(x); Reverse rev = new Reverse(); rev.reverse(x); System.out.println(x[0] + " " + x[1] + " " + x[2]); } //Increase every element in the array by 1 //For example: array : 0, 1, 2 will become 1, 2, 3 public s...

Creating array from string.

I need to create array like that: Array('firstkey' => Array('secondkey' => Array('nkey' => ...))) From this: firstkey.secondkey.nkey.(...) ...

Javascript Array, find and combine entries with duplicate values

Hi, I have the following dynamically generated array: var myArray = ("0% { left:74px; top:202px; }" , "44% { left:427px; top:122px; }", "0% { font-size:11px; }", "55% { font-size:49px; }" ); There are 2 entries that have the same start value: 0%. How can I find this and combine it together: form: 0% { left:74px; top:202px; }, 0% { ...

Getting error when added NSNumber to an array

When my program gets to the line: [userNumSequence addObject:[NSNumber numberWithInteger: sequenceNumber]]; it gets the error: Program received signal: “EXC_BAD_ACCESS”. All I'm wanting to do is to store an integer in the array. // JBNumberGeneration.m #import "JBNumberGeneration.h" @implementation JBNumberGeneration - (id) init...

How to overwrite pointer assoziation in php? Or how to operate on arrays with n dimensions?

Hi, I have a nasty little problem with the pointer opperator in php (&). I want to loop through a while loop, which writes data in an array. Each time it is supposed to write into the next dimension of the array (1st in $array, then in $array[0], then in array[0][0], etc). I wanted to do this by linking to $array with a pointer, then ch...

Sorting in arrays

While sorting an array for ex: A[5]={1,4,5,3,2} the output must be 1,2,3,4,5 in ascending order. in using the concept of bubble sorting my output is 0,1,2,3,4 what would be the problem in my code int A[5]={1,5,3,2,4}; for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ if(A[j]>A[j+1]) { int t=A[j]; A[j]=A[j+1]...

Using Raphael javascript for hovering with arrays

Hi, using Raphael, I'm trying to get a shape to appear when you hover over an invisible area near the shape. The following code does not work - where am I going wrong? Each shape has two Raphael paths associated with it: one for the visible shape, and the other for the invisible area. <script type="text/javascript" charset="utf-8"> $("...