arrays

python dictionary with constant value-type

hi there, I bumped into a case where I need a big (=huge) python dictionary, which turned to be quite memory-consuming. However, since all of the values are of a single type (long) - as well as the keys, I figured I can use python (or numpy, doesn't really matter) array for the values ; and wrap the needed interface (in: x ; out: d[x])...

MODX parse error function implode (is it me or modx?)

Update 4-June-2010: This appears to be a bug in MODx v 1.0.3, nothing to do with the implode function but rather a problem with mis-matched datatypes in the resulting filter clause. Bug has been filed with JIRA: MODX-2035. Hi, I cannot for the life of me figure this out, maybe someone can help. Using MODX a form takes user criteria to ...

In Ruby, how do I make a hash from an array?

I have a simple array: arr = ["apples", "bananas", "coconuts", "watermelons"] I also have a function f that will perform an operation on a single string input and return a value. This operation is very expensive, so I would like to memoize the results in the hash. I know I can make the desired hash with something like this: h = {} a...

IronPython: Creating & Adding An Array Of Points To A GraphicsPath

Greetings; I'm having a bit of trouble correctly instantiating an Array of System.Drawing.Point instances, and then adding the Array of Points to a GDI+ GraphicsPath instance using IronPython in a WinForms application. The following code compiles or builds correctly under SharpDevelop 3.2 with IronPython 2.6: import System.Drawing imp...

java: primitive arrays -- are they initialized?

If I use a statement in my code like int[] a = new int[42]; Will it initialize the array to anything in particular? (e.g. 0) I seem to remember this is documented somewhere but I am not sure what to search for. ...

PHP Arrays: Pop an array of single-element arrays into one array.

Using a proprietary framework, I am frequently finding myself in the situation where I get a resultset from the database in the following format: array(5) { [0] => array(1) { ["id"] => int(241) } [1] => array(1) { ["id"] => int(2) } [2] => array(1) { ["id"] => int(81) } [3] => array(1) { ["id"] => int(560)...

Arrays- Square root of an Array and printing the result JAVA

Hello, The title says it all, really. I'm trying to get an array of (9) numbers square rooted then printed but I keep coming back with only one result - the number of numbers in the array squared- obviously not what I want. Thanks for any help. Ok, here is my terrible code so far. Trying to pass it to a method as well. public stat...

Java Applet - ArrayIndexOutOfBoundsException (pt 2)

Hi there, I fixed my previous problem. But now when on my tile map... if I try to go 9 tiles to the RIGHT, and on trying to get to the 9th tile.... I will get this error: Exception in thread "AWT-EventQueue-1" java.lang.ArrayIndexOutOfBoundsException: 8 at tileGen.blocked(tileGen.java:125) at tileGen.keyPressed(tileGen.java:58) ...

In C, as free() knows an array size, why isn't there a function that gets the array size?

Possible Duplicate: If free() knows the length of my array, why cant I ask for it in my own code? Searching around (including here at stackoverflow), I got that malloc() allocates an array and also creates a header to control the array info. In this header, there's also the array size. free() use such information to know how ...

Counting number of values between interval

Is there any efficient way in python to count the times an array of numbers is between certain intervals? the number of intervals i will be using may get quite large like: mylist = [4,4,1,18,2,15,6,14,2,16,2,17,12,3,12,4,15,5,17] some function(mylist, startpoints): # startpoints = [0,10,20] count values in range [0,9] count v...

In C, is it possible do free only an array first or last position?

Hi there! I've an array, but I don't need its first (or last) position. So I point a new variable to the rest of the array, but I should free the array first/last position. For instance: p = read_csv_file(); q = p + 1; // I don't need the first CSV file field // Here I'd like to free only the first position of p return q; Otherwise I...

merging arrays of hashes

I have two arrays, each holding arrays with attribute hashes. Array1 => [[{attribute_1 = A}, {attribute_2 = B}], [{attribute_1 = A}, {attribute_4 = B}]] Array2 => [{attribute_3 = C}, {attribute_2 = D}], [{attribute_3 = C, attribute_4 = D}]] Each array in the array is holding attribute hashes for an object. In the above example, the...

array_key_exists is not working

array_key_exists is not working for large multidimensional array. For ex $arr=array( '1'=>10, '2'=>array('21'=>21, '22'=>22, '23'=>array('test'=>100, '231'=>231), ), '3'=>30, '4'=>40 ); array_key_exists('test',$arr) returns ...

Getting the last element of a Postgres array, declaratively

How to obtain the last element of the array in Postgres? I need to do it declaratively as I want to use it as a ORDER BY criteria. I wouldn't want to create a special PGSQL function for it, the less changes to the database the better in this case. In fact, what I want to do is to sort by the last word of a specific column containing mu...

foreach loop from multiple arrays c#

This should be a simple question. All I want to know is if there is a better way of coding this. I want to do a foreach loop for every array, without having to redeclare the foreach loop. Is there a way c# projects this? I was thinking of putting this in a Collection...? Please, critique my code. foreach (TextBox tb in vert) ...

Array filteration PHP

I have an array with values like: Array ( [0] => Array ( [parent] => Basic [parentId] => 1 [child] => Birthday [childId] => 2 ) [1] => Array ( [parent] => Basic [parentId] => 1 [child] => Gender [childId] => 3...

Using jQuery, how do I way attach a string array as a http parameter to a http request?

I have a spring controller with a request mapping as follows @RequestMapping("/downloadSelected") public void downloadSelected(@RequestParam String[] ids) { // retrieve the file and write it to the http response outputstream } I have an html table of objects which for every row has a checkbox with the id of the object as the valu...

How do I pass an array to a method?

Hey, I have not been able to find a proper answer on any forums about this. But how exactly do I pass an array to a class constructor? public class TestArray { String name; String[] array; public TestArray(String name, String[] anArray){ this.name = name; int len = anArray.length; this.array = ne...

Find "not the same" elements in two arrays

I have two integer lists (List<int>). They contain the same elements, but List 1 contains elements that are not in the List 2. How to find which elements of the List 1 ARE NOT in the List 2. Thanks :) PS. lang is c# ...

Problem adding UITableViewCell manually

I am trying to add a UITableViewCell at the very bottom of my UITableView programatically. I am getting an index out of bounds error, which I am not sure how to resolve: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [items count]+1; ...