arrays

Register javascript array from code behind in facebook

I need to set a javascript array from code behind using C# in Asp.Net2008 the problem now is that when i register the array using the following C# code: string ArrVal = ""; string Sep = ""; for (int i = 0; i < 17; i++) { ArrVal += Sep + FilesCount[i].ToString(); Sep = ","; } ...

Why can't I write @F[1..-1] to get elements 1..last?

In Perl, the array index -1 means the last element: @F=(1,2,3); print $F[-1]; # result: 3 You can also use the $# notation instead, here $#F: @F=(1,2,3); print $F[$#F]; # result: 3 So why don't -1 and $#F give the same result when I want to specify the last element in a range: print @F[1..$#F]; # 23 print @F[1..-1]; # <empty> T...

comparing object attribute in one array to an object attribute in another array

Hello all ... i seem to be having difficulties in accessing and comparing objects in NSMutableArrays in objective c. I'm very new so when explaining , some code would be nice. I have a character class and a characterfound class. The code looks like this: @implementation character @synthesize IDE, name; - (void) dealloc { [text ...

Why won't this echo in PHP?

I'm curious why this won't echo the HTML; I've perused the other questions in SO having to do with echo and print. It must be the PHP while loop in the string, but I've escaped the double quotes. There is something more complex happening, namely the error "Object of class WP-Query could not be converted to string." Am I being too simpl...

returning index array objective c

Does anyone know a quick way to return the index of my array in a simple function something like this if([appDelegate.exerciseReference containsObject:aExerciseRef.IDE]) { //return indexofwhere the object is the same .... } so let's say these two are the same at the index:5 from my array it would return a 5 integer. ...

Array Homework Question

You are given an array with integers between 1 and 1,000,000. One integer is in the array twice. How can you determine which one? Can you think of a way to do it using little extra memory. Algo: Solution 1: Have a hash table Iterate through array and store its elements in hash table As soon as you find an element which...

php arrays with only one type

I'm looking to create an array or list with elements of a certain type (eg objects the implement a certain interface). I know I can create an object that does the same thing implementing Traversable and Iterator, or override ArrayObject. But maybe there's another way I have missed. ...

Accessing Objective-C / Cocoa Touch Arrays

Hi there, I'm using Cocoa Touch to build an iPhone app. I have an NSMutableArray called stories, that on printing to the console displays something like this: 2009-07-20 12:38:30.541 testapp[4797:20b] ( { link = "http://www.testing.com"; message = "testing"; username = "test"; }, { link = "http://www.testing2.c...

Can i store serializable array data in DataColumn?

I am trying to automatically convert object's properties to DataTable (object is array and has properties that instantiated from special class which has value type). The code: static public DataTable f_GetDataTableFromClassObject(object _objInstance) { // geri dönecek datatable DataTable dataTable = new DataTable(); // ne...

Java: Anyway to declare an array in-line?

Let's say I have a method m() that takes an array of Strings as an argument. Is there a way I can just declare this array in-line when I make the call? i.e. Instead of: String[] strs = {"blah", "hey", "yo"}; m(strs); Can I just replace this with one line, and avoid declaring a named variable that I'm never going to use? Thanks! ...

c# Fastest way to randomly index into an array

I have an array of double values "vals", I need to randomly index into this array and get a value. GenRandomNumber() returns a number between 0 and 1 but never 0 or 1. I am using Convert.ToInt32 to basically get everything to the left of my decimal place, but there must be a more efficient way of doing this? Here's my code: public doub...

*FIXED* Good with PHP arrays? HELP!

I know there are a lot of smart people, so prove me right! I want to combine arrays where similar named keys merge together to form a single array. See example: [Bob] => Array ( [BobsDetails] => Array ( [Title] => Mr ) ) [Bob] => Array ( [BobsDetails] => Array ( [Surname] => Smith ) ) How do ...

Which program creates a C array given any file?

I remember seeing in the past a program that would take any file and generate a C array representing that file as output; it would prevent distribution of a separate file in some cases. Which Unix/Linux program does that? ...

Best way of making an argument optional for a C# webmethod

What is the best way of supporting optional data passed to a C# function? I have web service function in .Net which defines 5 arguments: [WebMethod] public string UploadFile( string wsURL , byte[] incomingArray , string FileName , string RecordTypeName , MetaData[] metaDataArray) The code of this ...

Handling a multi-dimensional data structure in .Net 3.5 and above

I want to build a 2 dimensional (non ragged at this point) object array. I can easily build a 2 dimensional Array[,], and will do so if it is the best option available, but have tended to avoid arrays in favour of the advanced functionality of .NET's List and Dictionary structures. I could also use a List<List<T>> to store a 2 dimensio...

[Ruby] Updating a Hash

So I've got this hash here, and I have a loop. When the loop detects that the hash already has a value vendor = "something" -- and the loop's value is "something" -- I want it to just go to the hash and update some values (price, visits). To simplify this, basically I have an array of hashes, and when I find that I already have a hash ...

Array and foreach

$posts = array( "message" => 'this is a test message' ); foreach ($posts as $post) { echo $post['message']; } Why does the above code only output the first letter in message? "t". Thanks! ...

Merge sorted lists in python

I have a bunch of sorted lists of objects, and a comparison function class Obj : def __init__(p) : self.points = p def cmp(a, b) : return a.points < b.points a = [Obj(1), Obj(3), Obj(8), ...] b = [Obj(1), Obj(2), Obj(3), ...] c = [Obj(100), Obj(300), Obj(800), ...] result = magic(a, b, c) assert result == [Obj(1), Obj(...

array_flip in javascript?

Is there any shortcut to accomplishing the equivalent of PHP's array_flip in javascript or does it have to be done via brute force looping? It has to be used for dozens of arrays so even small speedups will probably add up. ...

jQuery equivalent to Prototype array.last()

Prototype: var array = [1,2,3,4]; var lastEl = array.last(); Anything similar to this in jQuery? ...