arrays

Rotate 2D Array by 45 degrees

Hi, how can i rotate 2d rectangular array of integers that has odd number of rows by 45 degrees so something like int[] myArray = new int[,] { {1, 0 ,1}, {0, 1 ,0}, {0, 0 ,0}, } into int[] rotatedArray = new int[,] { {0, 1 ,0}, {0, 1 ,1}, {0, 0 ,0}, } for any dimension (3x3, 5x5, 7x7, etc.) by this "f...

java array sorting

how to sort an simple array logically (for both string & int) ? without using Arrays.sort(arr) or any comparators. ...

Evaluate string as Object without eval() dynamically?

EDIT: Thanks Kenny and everyone else who answered similarly. It really was a DOH...So stupid of me not to remember this. Maybe the answer is so simple it's eluding me...but I know someone here can school me on this hopefully. So I've got a rather large project that's dealing with tons of very large JSON, Objects, Arrays, etc..And I ne...

why is this syntax exclusively used to initialize string literals and can't be used for an array of characters?

Possible Duplicate: initializing char arrays in a way similar to initializing string literals below is a sample of initializing a string literal in which a terminating null character is added at the end of string, necessarily: char reshte[]="sample string"; I wonder why can't we initialize an array of characters without ter...

sort perl numeric array

Hi, I have an array which looks like this: array[0]: 6 8 array[1]: 12 9 6 array[2]: 33 32 5 array[3]: 8 6 What I want to do is to sort this array that it looks like this: array[0]: 6 8 array[1]: 6 9 12 array[2]: 5 32 33 array[3]: 6 8 I know I can sort the array with @newarray = sort {$a cmp $b} @array;, but I need to sort the eleme...

concatenate Array Recursively

I want to merge recursively arrays.. My code is: var allitemorder; var itemorder; $('.divclass').each(function () { itemorder = $(this).sortable('toArray'); allitemorder = $.merge([], itemorder); }); Kindly help. ...

How do I sort a multi-dimensional array by value?

I have an array as following and I want to order that array by the value of the key "attack". First keys of the arrays (15, 13, 18) are ID of some certain item from database, so I don't want these keys to be changed when the array is sorted. Any help would be greatly appreciated. This is the array: $data = array('15' => array('attack' ...

How do I search an array of objects by attribute (Java)

Hi, Is it possible to search an array of objects in Java by a private attribute with the Array.binarySearch method? I was thinking there must be something similar to the sorting technique, where you create a class that implements Comparator and pass this in to Array.sort, but I can't seem to find anything (maybe there is something wher...

Array Key in ColdFusion Structure

What is the proper syntax for creating a key within a ColdFusion structure which is an array? Preferably in the cfscript tags. To give a clearer idea of what I'm trying to do, here's what I thought it might be: StructInsert(account[i], "child[numChildren]", z); where "child" was supposed to be an array and numChildren was a counter i...

LINQ to SQL many to many int ID array criteria query

Ok this should be really simple, but I am doing my head in here and have read all the articles on this and tried a variety of things, but no luck. I have 3 tables in a classic many-to-many setup. ITEMS ItemID Description ITEMFEATURES ItemID FeatureID FEATURES FeatureID Description Now I have a search interface where you can select a...

Perl: Can't pass an "on-the-fly" array to a sub

strftime(), as per cpan.org: print strftime($template, @lt); I just can't figure the right Perl code recipe for this one. It keeps reporting an error where I call strftime(): ... use Date::Format; ... sub parse_date { if ($_[0]) { $_[0] =~ /(\d{4})/; my $y = $1; $_[0] =~ s/\d{4}//; $_[0] =~ /(\d\d)\D(\d\d)/; return [$2,$1,...

User defined array sizes in C

I'm reading through "Illustrated C" and the first exercise question asks: Program MATMUL multiplies matrices of fixed size. Make the program deal with any specified sizes. So below is the code that I have come up with thus far. However I read that all attributes need to be declared before the main function. So how do I get custom s...

xsl iterate through list of alphabet

I need to iterate through the alphabet a-z, and for each one, print the letter, and then place some code that i already have working to display all items in my database that begin with that letter. Currently, i'm using a select to retrieve the first letter of all the item names which i display. However, the requirement is to display all ...

Compare two arrays or arraylists, find similar and different values

Hi all, I have two arrays (or arraylists if it is easier) of strings. I need to compare these, find which only exist in the first array, which exist in both, and which only exist in the second array. These arrays are different lengths, and may be in different orders. If necessary, I suppose I could sort them... I know I could hack th...

Error imploding $_POST[] array containing php variable

Hello, I am trying to implode an array in a $_POST[]. I am doing this inside of a loop which searches for values in ~31 arrays...$_POST['1'], $_POST['2'], $_POST['3'], etc. I am trying to do this with: while($i <= $_SESSION['daysInMonth']){ $month = $_SESSION['month']; $day = $i; $names = implode(',',$_POST['names_'.$i]); $region = $...

PHP How do I shift subset of array values to do something like asort?

Hello. First off I am new to this site and it is a big help, so thanks in advance for the input. I am trying to shift a subset of array values after comparing them, like asort. Here is what I have: $array[name] = "name"; $array[date] = "date"; $array[item1] = 7; $array[item2] = 16; $array[item3] = 3; $array[item4] = 16; $array[item...

AS3 using array to add EventListener to existing Button

I'm trying to use an array to add a click listener to an existing Button. Black,Blue...etc are the button Names. the location of the nested button would be: this.mc1.mc2.contents.m3.black.addEventListener(MouseEvent.CLICK, doThisFunction); var myArray:Array = new Array ("black","blue","green","orange"); for(var k:int =1; k<myArray.len...

Is this a Bug in the Array.fill method in Ruby?

Should this be the case i.e. I am misunderstanding, or is it a bug? a = Array.new(3, Array.new(3)) a[1].fill('g') => [["g", "g", "g"], ["g", "g", "g"], ["g", "g", "g"]] should it not result in => [[nil, nil, nil], ["g", "g", "g"], [nil, nil, nil]] Any advice would be most helpful! Regards, ...

reposition array elements based on a condition in php

So I have this array: $dates[0] = array('start'=>'2010-07-22', 'end'=>'2010-07-23'); $dates[1] = array('start'=>'2010-07-22', 'end'=>'0000-00-00'); $dates[2] = array('start'=>'2010-07-29', 'end'=>'0000-00-00'); $dates[3] = array('start'=>'2010-07-31', 'end'=>'2010-07-31'); $dates[4] = array('start'=>'2010-07-08', 'end'=>'2010-07-31'); $...

Generate random sentence on button press, code looks right but isnt working

I'm not sure what's wrong here, all i want to do is randomly grab an item from my array. Which is just like a random sentence. Then generate another once the button is pressed. All my code looks good to me but it's causing a crash when i hit the button. any ideas? package com.my.package; import java.util.Random; import android.app.Ac...