arrays

How do I use an array as an object attribute in Perl?

Hello guys, I need some help regarding the arrays in Perl This is the constructor I have. BuildPacket.pm sub new { my $class = shift; my $Packet = { _PacketName => shift, _Platform => shift, _Version => shift, _IncludePath => [@_], ...

Magento Api and Downloadable Url

I need to know how to set the downloadable URL for a downloadable new product created using Magento API. Problem is find the appropriate array value for the downloadable URL. here is my code: $productData = array( 'name' => $stealth_item->Title, 'websites' => array(1), 'short_description' => ltrim( ereg_replace( "\...

Why is only the second array dimension important?

Why when working with two dimensional arrays only second dimension is important for a compiler? Just can't get my head around that. Thanks ...

Counting viable sublist lengths from an array.

This is for a genetic algorithm fitness function, so it is important I can do this as efficiently as possible, as it will be repeated over and over. Lets say there is a function foo(int[] array) that returns true if the array is a "good" array and false if the array is a "bad" array. What makes it good or bad does not matter here. This ...

Find most common string in an array

I have this array, for example (the size is variable): x = ["1.111", "1.122", "1.250", "1.111"] and I need to find the most commom value ("1.111" in this case). Is there an easy way to do that? Tks in advance! EDIT #1: Thank you all for the answers! EDIT #2: I've changed my accepted answer based on Z.E.D.'s information. Thank...

php smarty loop multidimensional array

I'm using smarty for my site, and I'm trying to loop through an array to print out table rows... The array looks like this: Array ( [TM98800G] => Array ( [zid] => Array ( [0] => 90001 [1] => 90002 [2] => 90003 [3] =...

How do I print array values in a range when values are supplied?

My php reads in xml and I want to ouput the values within a given range. I have no way of knowing the size of the array or the range. However, I do know where to start; I have a $key that holds my current location. I also know where to stop; I have the word "ENDEVENTS" between each set. I want to get the values from my current position (...

Why do I have to provide default ctor?

Why do I have to provide default ctor if I want to create an array of objects of my type? Thanks for answers ...

AS3 equivalent of PHP key array

Hey all, title may be abit misleading but i didnt know the correct way to write it. Basically, how can i do the AS3 equivalent of this php code: return array('x' => 0, 'y' => 0); ...

array loop not working correctly? c++

Trying to count how many elements within the array are not equal to 0, is something set up wrong? I'd like to check all values in the array (it's a sudoku board) and then when all elements are "full" I need to return true. Is something off? bool boardFull(const Square board[BOARD_SIZE][BOARD_SIZE]) { int totalCount=0; for (int ...

Better use a tuple or numpy array for storing coordinates

Hi, I'm porting an C++ scientific application to python, and as I'm new to python, some problems come to my mind: 1) I'm defining a class that will contain the coordinates (x,y). These values will be accessed several times, but they only will be read after the class instantiation. Is it better to use an tuple or an numpy array, both in...

Array.Copy: strange exception while concatenating two byte arrays

In a application of mine that is developed in C# I have the following code: byte[] resb = new byte[Buffer.ByteLength(blockAr) + Buffer.ByteLength(previous)]; Array.Copy(blockAr, 0, resb, 0, blockAr.Length); Array.Copy(previous, 0, resb, blockAr.Length, previous.Length); It's a very simple code to concatenate two byte arrays. The pro...

How are two-dimensional arrays formatted in memory?

In C, I know I can dynamically allocate a two-dimensional array on the heap using the following code: int** someNumbers = malloc(arrayRows*sizeof(int*)); for (i = 0; i < arrayRows; i++) { someNumbers[i] = malloc(arrayColumns*sizeof(int)); } Clearly, this actually creates a one-dimensional array of pointers to a bunch of separate ...

What type of data is this JavaScript code!?

Hello, Well, I'm completely new to JavaScript. Can you please tell me what type of data is this JavaScript code: var options = { sourceLanguage: 'en', destinationLanguage: ['hi', 'bn', 'fa', 'gu', 'kn', 'ml', 'mr', 'ne', 'pa', 'ta','te','ur'], shortcutKey: 'ctrl+g', transliterationEnabled: true }; I've reviewed JavaSc...

How to store arrays in single array

How can I store arrays in single array? e.g. I have four different arrays, I want to store it in single array int storeAllArray [] and when I call e.g. storeAllArray[1] , I will get this output [11,65,4,3,2,9,7]instead of single elements? int array1 [] = {1,2,3,4,5,100,200,400}; int array2 [] = {2,6,5,7,2,5,10}; int array3 [] = {11,65...

transpose 1D array of leading dimension N

how can i transpose an 1d array of leading dimension N, without extra space ? any language is fine ...

How should I do a loop a nokogiri search in ruby?

I have the following that I retreive the title of each url from an array that contains a list of urls. require 'rubygems' require 'nokogiri' require 'open-uri' @urls = ["http://google.com", "http://yahoo.com", "http://rubyonrails.org"] @found_titles = Array.new @found_titles[0] = Nokogiri::HTML(open("#{@urls[0]}")).search("title").inn...

Holding variables in memory, C++

Today something strange came to my mind. When I want to hold some string in C (C++) the old way, without using string header, I just create array and store that string into it. But, I read that any variable definition in C in local scope of function ends up in pushing these values onto the stack. So, the string is actually 2* bigger t...

Matching array elements to get an array element at another index

I have a PHP array that I'm using to generate an HTML form. The PHP array is this: <?php $vdb = array ( array( "Alabama", 275), array( "Alaska", 197), array( "Arizona", 3322)); ?> The PHP to generate the HTML form is below. I need to have the value be the name of the s...

How to flatten 2D array to 1D array?

How can I flatten the 2 dimensions array int originalArray[][] to 1 dimension array? int a [] = {1,2,6,7,2}; int b [] = {2,44,55,2}; int c [] = {2,44,511,33}; int originalArray [][] = new array[][]{a,b,c}; ...