arrays

Is there SQL parameter binding for arrays?

Is there a standard way to bind arrays (of scalars) in a SQL query? I want to bind into an IN clause, like so: SELECT * FROM junk WHERE junk.id IN (?); I happen to be using Perl::DBI which coerces parameters to scalars, so I end up with useless queries like: SELECT * FROM junk WHERE junk.id IN ('ARRAY(0xdeadbeef)'); Clarification: ...

Do the items in an array or list maintain their order?

I am coding VB.NET in VS2008. I have a comma delimited string of numbers, i.e. 16,7,99,1456,1,3 I do this in VB: Dim MyArr() As String = MyString.Split(",") Will MyArr keep the items in the order they were in the string? If I do this: For Each S as String in MyString.Split(",") 'Do something with S 'Will my items be in the...

Best way to return list of objects in C++?

It's been a while since I programmed in C++, and after coming from python, I feel soooo in a straight jacket, ok I'm not gonna rant. I have a couple of functions that act as "pipes", accepting a list as input, returning another list as output (based on the input), this is in concept, but in practice, I'm using std::vector to represent...

convert an integer number into an array

Hi, I am trying to convert an integer number in C into an array containing each of that number's digits i.e. if I have int number = 5400 how can I get to int numberArray[4] where numberArray[0] = 0; numberArray[1] = 0; numberArray[2] = 4; numberArray[3] = 5; Any suggestions gratefully received --dave ...

vba: getting value of a cell across all tabs

Greetings, I'm trying to write a vbscript function that collects the value of a cell ("E1") across all tabs of an excel document into an array (Reviewers). I wrote the following code, but the data is not being stored into the array, can someone please tell me what I'm doing wrong? this is the code: http://img24.imageshack.us/my.p...

How to transfer java array to javaScript array using jsp?

Hello all, I have a list of strings on my server which I am trying to get to the client in the form of an array. The code I am attempting to use is the following: Within the jsp I have a List<String> columns. I am attempting the following code: <%int j = 0; %> for(var i = 0; i < <%=columns.size()%>; i++) {   colArray[i] = "<%=column...

Inserting into Set changing the order of Elements in an Array in Ruby

@search_results = Array.new duplicates = Set.new results.each { |result| @search_results.push(result) unless duplicates.add?(result[:url]) } This piece of code is garbling the order of elements in the array @search_results. Why would inserting the same element in a set and an array change the insertion order for Array? Seems like so...

How to print every element of an ARRAY in PL/SQL?

This is a pretty basic question, but here goes: I have an array of VARCHAR2 strings in PL/SQL. How can I print every element in that array? ...

Is it faster to use an array or bit access for multiple boolean values?

1) On a 32-bit CPU is it faster to acccess an array of 32 boolean values or to access the 32 bits within one word? (Assume we want to check the value of the Nth element and can use either a bit-mask (Nth bit is set) or the integer N as an array index.) It seems to me that the array would be faster because all common computer architectu...

Getting the length of an array in Python

In python is this the only way to get the number of elements: arr.__len__() If so, why the strange syntax? ...

C/C++ private array initialization in the header file

I have a class called Cal and it's .cpp and .h counterpart Headerfile has class Cal { private: int wa[2][2]; public: void do_cal(); }; .cpp file has #include "Cal.h" void Cal::do_cal() { print(wa) // where print just itterates and prints the elements in wa } My question is how do I initialize the array ...

Python loops with multiple lists?

<edit> Thanks to everyone who has answered so far. The zip and os.path.join are really helpful. Any suggestions on ways to list the counter in front, without doing something like this: zip(range(len(files)), files, directories) </edit> Hi, I'm in the process of learning Python, but I come from a background where the following pseudo...

Initializing a list to a known number of elements in Python

Right now I am using a list, and was expecting something like: verts = list (1000) Should I use array instead? ...

How can AWK do array arithmetics?

I want to shift away from Excel to Awk. I need basic mathematical operations, such as addition and division, for arrays. For example, arrays A and B are [1, 3, 2] and [2, 1, 2], respectively. How can I get an array [2, 3, 4] from the multiplication between A and B? What about the addition and division between A and B? ...

PHP Arrays, appending count of array items recursively to an array

Pointless Dribble Okay This is another weird one from me, i want to thank OIS for helping me out on my last question... which deals with this same kind of funky array manipulation... i studied that code in depth and i feel it has helped me become better with recursive array manipulative functions. However, once again i find my self in ...

Checking to see if one array's elements are in another array in PHP

Hi, I have two arrays in PHP as follows: People: Array ( [0] => 3 [1] => 20 ) Wanted Criminals: Array ( [0] => 2 [1] => 4 [2] => 8 [3] => 11 [4] => 12 [5] => 13 [6] => 14 [7] => 15 [8] => 16 [9] => 17 [10] => 18 [11] => 19 [12] => 20 ) How do I check if any of the People...

Reading into arrays in C++

Hi guys! I'm practicing for a competition (that's where my previous question came from). I got the algorithm sorted out for the question, but I'm having some problems with the actual programming. It's a solo competition, so I really need to get this sorted out before I go for it. This is the question. TASK 3: GECKO During the rainy s...

How to "flatten" a multi-dimensional array to simple one in php?

It's probably beginner question but I'm going through documentation for longer time already and I can't find any solution. I thought I could use implode for each dimension and then put those strings back together with str_split to make new simple array. However I never know if the join pattern isn't also in values and so after doing str_...

C/C++ optimize data structures, array of arrays or just array

Working with a program that uses 16bytes 4v4 one byte matrices : unsigned char matrix[4][4]; and a few 256bytes 16v16 one byte matrices: unsigned char bigMatrix[16][16]; Very often due to data manipulation I am forced to loop column wise in the program making cache misses. Will the performance improve if I use an array instead, i....

Java how to: Generic Array creation

Due to the implementation of Java Generics you can't have code like this. How can I implement this while maintaining type safety? public class GenSet<E> { private E a[]; public GenSet() { a = new E[INITIAL_ARRAY_LENGTH]; } } I saw a solution on the java forums that goes like this: import java.lang.refl...