arrays

Simple LinQ question: convert [][] to []

Hello, I would like to get collection or list of Item objects, but I get array of arrays now. Item[][] s = employees.Select(e => e.Orders.Select(o => new Item(e.ID, o.ID)).ToArray()).ToArray(); Can anyone select me solution to do it? P.S. just LinQ solution :) ...

Why do two array values look the same, but don't evaluate as equal?

When I compare two array values I see two strings that look the same. php doesn't agree. $array1 = array('address'=>'32 Winthrop Street','state'=>'NY'); $array2 = array('address'=>'32 Winthrop Street'); $results = array_diff_assoc($array1, $array2); var_dump($results) //echos ['address'] => string(18) "32 Winthrop Street" ['state']=...

jquery: why a selector returns me an array, but attribute doesnt?

Hi. I'm trying to understand JQ better. I'm calling an JQ object $(".FamiliesList li li span[class!='']").prev().find('option:selected') this returns back to me an array of all the options that their span parent's brother has a classname. [option, option] Now- I want to return back an array of the option's values $(".FamiliesLis...

PHP array help getting a value from the key

I have a variable that looks likes this, $rslt['expected_salary_level'] This returns a string similar to LEVEL_3, in another array that looks like this I have a set of salaries, Array ( [LEVEL_1] => Array ( [nice_name] => under £10,000 [low] => 1 [high] => 10000 ) ...

Array not returned correctly

I am trying to return a simple array, but I am not getting the correct result. I am getting the following arr1[0] = 1 arr1[1] = 32767 result while the result should have been arr1[0] = 1 arr1[1] = 15 Please suggest. int *sum(int a, int b){ int arr[2]; int *a1; int result = a+b; arr[0]= 1; arr[1]= result; a1 = a...

Does LaTeX have an array data structure?

Are there arrays in LaTeX? I don't mean the way to typeset arrays. I mean arrays as the data structure in LaTeX/TeX as a "programming language". I need to store a number of vbox-es or hbox-es in an array. It may be something like "an array of macros". More details: I have an environment that should typeset songs. I need to store some s...

splice() not working on correctly

I am setting a cookie for each navigation container that is clicked on. It sets an array that is joined and set the cookie value. if its clicked again then its removed from the array. It somehow buggy. It only splices after clicking on other elements. and then it behaves weird. It might be that splice is not the correct method Thanks...

JavaScript 1.6 Array.map() and Array.filter() not working with built in functions as arguments

This works fine: ["655971", "2343", "343"].map(function(x) { return parseInt(x) }) // [655971, 2343, 343] But this doesnt: ["655971", "2343", "343"].map(parseInt) // [655971, NaN, NaN] The same happens for Array.filter() What am I missing here? ...

Given an array of arrays, how can I replace all empty values with 0?

Example array $myArray[0] = array('23', null, '43', '12'); $myArray[1] = array(null, null, '53', '19'); $myArray[2] = array('12', '13', '14', null); All nulls should be replaced with 0. I was hoping someone would have an efficient way of doing this, perhaps a built in PHP function that I am unaware of. ...

Basic Array Iteration in Ruby

What's a better way to traverse an array while iterating through another array? For example, if I have two arrays like the following: names = [ "Rover", "Fido", "Lassie", "Calypso"] breeds = [ "Terrier", "Lhasa Apso", "Collie", "Bulldog"] Assuming the arrays correspond with one another - that is, Rover is a Terrier, Fido is a Lhasa Ap...

PHP splitting arrays into groups based on one field's value

I have an array containing arrays of names and other details, in alphabetical order. Each array includes the first letter associated with the name. Array ( [0] => Array ( [0] => a [1] => Alanis Morissette ) [1] => Array ( [0] => a [1] => Alesha Dixon ...

in java can one have an array of variables?

in java can you have an array of variables? if so what is the syntax? here's an example if your confused: varint[] ArrayOfVariablesThatAreInts = new varint[#] or var[] ArrayofVariables = new var[#] is something like this legal? ...

help with array

You will write a program that evaluates the integral of sin(x) using the left-hand rectangle rule with 2000 subintervals, over 10 intervals. The intervals to test are [0, 1), [1, 2), …, [8, 9), [9, 10). You will declare an array of type double that can hold 10 elements, and you will use this array to hold all 10 result...

Can't concatenate 2 arrays in PHP

I've recently learned how to join 2 arrays using the + operator in PHP. But consider this code... $array = array('Item 1'); $array += array('Item 2'); var_dump($array); Output is array(1) { [0]=> string(6) "Item 1" } Why does this not work? Skipping the shorthand and using $array = $array + array('Item 2') does not work...

how do I create an array in jquery?

$(document).ready(function() { $("a").click(function() { $("#results").load("jquery-routing.php", { pageNo: $(this).text(), sortBy: $("#sortBy").val()} ); return false; }); }); How do I create an array in jQuery and use that array instead of { pageNo: $(this).text(), sortBy: $("#sortBy").val()} ...

friendship and operator overloading help

hello there, I have the following class #ifndef Container_H #define Container_H #include <iostream> using namespace std; class Container{ friend bool operator==(const Container &rhs,const Container &lhs); public: void display(ostream & out) const; private: int sizeC; // size of Container int capacityC; ...

MPI datatype for 2 d array

I need to pass an array of integer arrays (basically a 2 d array )to all the processors from root.I am using MPI in C programs. How to declare MPI datatype for 2 d array.and how to send the message (should i use broadcast or scatter) ...

Resizing the Array

How can I resize the two dimensional array size without affecting its value? ...

How do I apply a string function to a table column?

As part of a query result, a column with names is returned. I want to apply a function so that the order of first and last name is flipped in my $db results. What is the most efficient way to accomplish this? There answer probably lies in using either the foreach function, array_walk or array_map but I don't know the proper syntax. ...

formatting an array of mobile numbers

Hi, I am creating a SMS app the following code is supposed to: check if the mobile/cell number is 11 characters long. check if the number starts with 07. If neither of these conditions are met, it should remove the number from the array. So the following numbers would be valid: 07123456789,07123456790,07123456791,07123456792,07123...