Search Results

Search found 20582 results on 824 pages for 'double array'.

Page 14/824 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • javascript - Google Chrome cluttering Array generated from .split()

    - by patrick
    Given the following string: var str = "one,two,three"; If I split the string on the commas, I normally get an array, as expected: var arr = str.split(/\s*,\s*/); Trouble is that in Google Chrome (for Mac), it appends extra properties to the array. Output from Chrome's debugger: arr: Array 0: one 1: two 2: three constructor: function Array() index: undefined input: undefined length: 3 So if I iterate over the array with a for/in loop, it iterates over the new properties. Specifically the input and index properties. Using hasOwnProperty doesn't seem to help. A fix would be to do a for loop based on the length of the Array. Still I'm wondering if anyone has insight into why Chrome behaves this way. Firefox and Safari don't have this issue.

    Read the article

  • Merging arrays, adding array as dimension to existing array

    - by JohnDoe
    Lets say i have 2 arrays Array1 array($info) $info['id'] => some id $info['text'] => some text etc lets say i have a function that returns another array called images Array 2 array($images) $images[0] => some link 1 $images[1] => some link 2 etc How do i add $images to the $info array as a new dimension, as such $info['image'][0] => some link 1 $info['image'][1] => some link 2

    Read the article

  • in_array() - help on what specifically would return true

    - by Kerri
    I am using in_array, and I'm trying to use it in a way where it will only return true if it's an exact match of one of the objects in the array, not just if it's "in" the array. e.g. 1. $sample_array = array('123', '234', '345'); 2. $sample_array = array('23', '34', '45'); in_array('23', $sample_array); In the above example, I would only want version 2 to return true, because it has the exact string, '23'. Version 1 returns true as well though, because the array contains instances of the string '23'. How would I get this to work so that only version 2 returns true? Am I even using the right function?

    Read the article

  • Amazon travaillerait sur une version inédite des tablettes Kindle, à double affichage LCD / encre électronique

    Amazon travaillerait sur une version inédite des tablettes Kindle À double affichage LCD / encre électronique Un nouveau dépôt de brevet signé Amazon et dévoilé ce jeudi décrit un dispositif incorporant un double affichage inédit. On y retrouve un écran LCD (ou OLED) d'un côté et un écran statique E-INK (encre électronique ou papier électronique) de l'autre. [IMG]http://idelways.developpez.com/news/images/kindle-lcd-e-ink.jpg[/IMG] Une idée prometteuse que celle d'Amazon en pensant à créer une tablette tactile à double écran Kindle ? Kindle Fire. L'écran Kindle doté d'un affichage à faible éclairage offre un outil eReader avec un plus grand confort de le...

    Read the article

  • building median for each string in IList<IDictionary<string, double>>

    - by Oliver
    Actually i have a little brain bender and and just can't find the right direction to get it to work: Given is an IList<IDictionary<string, double>> and it is filled as followed: Name|Value ----+----- "x" | 3.8 "y" | 4.2 "z" | 1.5 ----+----- "x" | 7.2 "y" | 2.9 "z" | 1.3 ----+----- ... | ... To fill this up with some random data i used the following methods: var list = CreateRandomPoints(new string[] { "x", "y", "z" }, 20); This will work as followed: private IList<IDictionary<string, double>> CreateRandomPoints(string[] variableNames, int count) { var list = new List<IDictionary<string, double>>(count); list.AddRange(CreateRandomPoints(variableNames).Take(count)); return list; } private IEnumerable<IDictionary<string, double>> CreateRandomPoints(string[] variableNames) { while (true) yield return CreateRandomLine(variableNames); } private IDictionary<string, double> CreateRandomLine(string[] variableNames) { var dict = new Dictionary<string, double>(variableNames.Length); foreach (var variable in variableNames) { dict.Add(variable, _Rand.NextDouble() * 10); } return dict; } Also i can say that it is already ensured that every Dictionary within the list contains the same keys (but from list to list the names and count of the keys can change). So that's what i got. Now to the things i need: I'd like to get the median (or any other math aggregate operation) of each Key within all the dictionaries, so that my function to call would look something like: IDictionary<string, double> GetMedianOfRows(this IList<IDictionary<string, double>> list) The best would be to give some kind of aggregate operation as a parameter to the function to make it more generic (don't know if the func has the correct parameters, but should imagine what i'd like to do): private IDictionary<string, double> Aggregate(this IList<IDictionary<string, double>> list, Func<IEnumerable<double>, double> aggregator) Also my actual biggest problem is to do the job with a single iteration over the list, cause if within the list are 20 variables with 1000 values i don't like to iterate 20 times over the list. Instead i would go one time over the list and compute all twenty variables at once (The biggest advantage of doing it that way would be to use this also as IEnumerable<T> on any part of the list in a later step). So here is the code i already got: public static IDictionary<string, double> GetMedianOfRows(this IList<IDictionary<string, double>> list) { //Check of parameters is left out! //Get first item for initialization of result dictionary var firstItem = list[0]; //Create result dictionary and fill in variable names var dict = new Dictionary<string, double>(firstItem.Count); //Iterate over the whole list foreach (IDictionary<string, double> row in list) { //Iterate over each key/value pair within the list foreach (var kvp in row) { //How to determine median of all values? } } return dict; } Just to be sure here is a little explanation about the Median.

    Read the article

  • Python: Create a duplicate of an array

    - by Dan
    I have an double array alist[1][1]=-1 alist2=[] for x in xrange(10): alist2.append(alist[x]) alist2[1][1]=15 print alist[1][1] and I get 15. Clearly I'm passing a pointer rather than an actual variable... Is there an easy way to make a seperate double array (no shared pointers) without having to do a double for loop? Thanks, Dan

    Read the article

  • Excel formula - sometimes array formula, sometimes not

    - by Jonas
    I want to write some data to an Excel file, and I want the first page to show a summary of the data that are spread all over the sheets. The individual data items on a sheet can be included or excluded, and I want the summary to be calculated only on the included values. Thus, I thought I'd use a formula like this to show, for example, an average (for which empty fields shouldn't be counted, either): =AVERAGE(IF('dataSheet1'!$B:$B=1,IF('dataSheet1'!$I:$I<>"",'dataSheet1'!$I:$I,""),"")) If I have this formula in dataSheet1, everything works fine. If I have this formula in the summary sheet, I need to enter it as an array formula, and I have to specify the exact ranges to make it work. Is there a way (aside from adding the average in dataSheet, and then referencing the result in summary) to make the formula work without having it turn into an array formula?

    Read the article

  • PHP - Counting matching arrays in array

    - by Sergio
    hi there, I have an array structure that looks like this: Array ( [0] => Array ( [type] => image [data] => Array ( [id] => 1 [alias] => test [caption] => no caption [width] => 200 [height] => 200 ) ) [1] => Array ( [type] => image [data] => Array ( [id] => 2 [alias] => test2 [caption] => hello there [width] => 150 [height] => 150 ) ) ) My question is, how can I get a count of the number of embedded arrays that have their type set as image (or anything else for that matter)? In practise this value can vary. So, the above array would give me an answer of 2. Thanks

    Read the article

  • 2 dimensional array

    - by ankit
    we have these arrays.... $cities = array("nagpur","kanpur","delhi","chd","Noida","mumbai","nagpur"); $names = array("munish","imteyaz","ram","shyam","ankit","Rahul","mohan"); now i want a 2 dimensional array with name of city as key and all the corresponding names as its values. <?php $cities = array("nagpur","kanpur","nagpur","delhi","kanpur"); $names = array("ankit","atul","aman","amit","manu"); foreach ($cities as $i => $value) { echo "\n"; echo $value; $city=$value; $k=0; foreach ($cities as $ii => $m) { If($city==$m) { echo$names[$ii] ; $final[$i][$k]=$names[$ii]; $arr = array($city => array($k =>$names[$ii] )); $k++; } } echo"\n<tr></tr>"; } wat i tried is this.but it doesnt work.help me

    Read the article

  • Unable to access value of nested array element

    - by John Conde
    I'm having an issue getting the value of a nested array element. Here's what I've got: print_r($environment); // Outputs Array ( [0] => Array ( ['parameter'] => Vibration ['conditions'] => 204 ['method'] => D ) [1] => Array ( ['parameter'] => Immersion ['conditions'] => 104 ['method'] => B ) [2] => Array ( ['parameter'] => Shock ['conditions'] => 213 ['method'] => I ) [3] => Array ( ['parameter'] => Humidity ['conditions'] => 106 ['method'] => - ) ) print_r($environment[0]); // Outputs Array ( ['parameter'] => Vibration ['conditions'] => 204 ['method'] => D ) echo $environment[0]['parameter']; // Nothing Maybe I've been looking at this for too long. Any ideas would be greatly appreciated.

    Read the article

  • In .NET, What Is Fastest Way to Initialize Multi-Dimensional Array to Non-Default Value

    - by AMissico
    How do I initialize a multi-dimensional array of a primitive type as fast as possible? I am stuck with using multi-dimensional arrays. My problem is performance. The following routine initializes a 100x100 array in approx. 500 ticks. Removing the int.MaxValue initialization results in approx. 180 ticks just for the looping. Approximately 100 ticks to create the array without looping and without initializing to int.MaxValue. Routines similiar to this are called a few tens-of-thousands to several million times. I am open to suggestions on how to optimize this non-default initialization of an array. One idea I had is to use a smaller primitive type when available. For instance, using byte instead of int, saves 100 ticks. I would be happy with this, but I am hoping that I don't have to change the primitive data type. public int[,] CreateArray(Size size) { int[,] array = new int[size.Width, size.Height]; for (int x = 0; x < size.Width; x++) { for (int y = 0; y < size.Height; y++) { array[x, y] = int.MaxValue; } } return array; }

    Read the article

  • php - replace array elements with another array's elements?

    - by Simpson88Keys
    Not sure how to go about this... But, I have two arrays, one with updated information, another with outdated information... There are a lot more elements in the second array, but I'm looking to "update" the outdated one with the updated information. Here's what the arrays look like: //Outdated Array ( [0] => Array ( [anum] => 3236468462 [cid] => 4899097762 [mid] => 1104881401 [na_title] => [na_fname] => JOHN [m_initial] => [na_lname] => DOE [na_suffix] => [na_addr1] => 1234 SAMPLE AVENUE [na_addr2] => [na_city] => NORWALK [state] => OH [zip] => [zip_plus_4] => [route] => R002 [dma_code] => 510334 ) ) //Updated Array ( [1] => Array ( [0] => YUD990 [1] => 98 [2] => 1234 Sample Avenue [3] => [4] => Norwalk [5] => OH [6] => 44857-9215 [7] => 3236468462 ) ) To clarify, I want to: (1) Match up the value for [7] from the updated array with the value for [anum] in the outdated array, and then update [na_addr1], [na_addr2], [na_city], [state], [zip], [zip_plus_4] in the outdated array with the values for [2],[3],[4],[5],[6] (I know I'll need to split the updated [6] in order to get it to map corrected to the outdated) Feel like I'm making this very confusing... sorry about that...

    Read the article

  • Copy a multi-dimentional array by Value (not by reference) in PHP.

    - by Simon R
    Language: PHP I have a form which asks users for their educational details, course details and technical details. When the form is submitted the page goes to a different page to run processes on the information and save parts to a database. HOWEVER(!) I then need to return the page back to the original page, where having access to the original post information is needed. I thought it would be simple to copy (by value) the multi-dimensional (md) $_POST array to $_SESSION['post'] session_start(); $_SESSION['post'] = $_POST; However this only appears to place the top level of the array into $_SESSION['post'] not doing anything with the children/sub-arrays. An abbreviated form of the md $_POST array is as follows: Array ( [formid] = 2 [edu] = Array ( ['id'] = Array ( [1] = new_1 [2] = new_2 ) ['nameOfInstitution'] = Array ( [1] = 1 [2] = 2 ) ['qualification'] = Array ( [1] = blah [2] = blah ) ['grade'] = Array ( [1] = blah [2] = blah ) ) [vID] = 61 [Submit] = Save and Continue ) If I echo $_SESSION['post']['formid'] it writes "2", and if I echo $_SESSION['post']['edu'] it returns "Array". If I check that edu is an array (is_array($_SESSION['post']['edu])) it returns true. If I echo $_SESSION['post']['edu']['id'] it returns array, but when checked (is_array($_SESSION['post']['edu]['id'])) it returns false and I cannot echo out any of the elements. How do I successfully copy (by value, not by reference) the whole array (including its children) to an new array?

    Read the article

  • Reverse alphabetic sort multidimensional PHP array maintain key

    - by useyourillusiontoo
    I'm dying here, any help would be great. I've got an array that I can sort a-z on the value of a specific key but cannot sort in reverse z-a. sample of my array which i'd like to sort by ProjectName (z-a): Array ( [0] => Array ( [count] => 1 [ProjectName] => bbcjob [Postcode] => 53.471922,-2.2996078 [Sector] => Public ) [1] => Array ( [count] => 1 [ProjectName] => commercial enterprise zone [Postcode] => 53.3742081,-1.4926439 [Sector] => Public ) [2] => Array ( [count] => 1 [ProjectName] => Monkeys eat chips [Postcode] => 51.5141492,-0.2271227 [Sector] => Private the desired results would be to maintain the entire array key - value structure but with the order: Monkeys eat chips Commericial enterprise zone bbcjob I hope this makes sense

    Read the article

  • Android: Defined array resource not found ?!

    - by David
    Hi, i have a strange (?) error in my android application. I have defined some arrays in values/arrays.xml the following way: <?xml version="1.0" encoding="utf-8"?> <resources> <array name="perimeter"> <item>10 miles</item> <item>20 miles</item> <item>30 miles</item> </array> <array name="regvalues"> <item>1</item> <item>2</item> <item>3</item> </array> </resources> Now I want to use them in a ListPreference for a PreferenceActivity (defined by an xml file). So i set android:entries="@array/perimeter" android:entryValues="@array/regvalues" for this ListPreference. When I try to use this on my device the app crashes. (NullPointer in Dialog.close()) If I try to use the regvalues-items as Entries for the ListPreference i get a NullPointer in ArrayAdapter.createViewFromResource(int, View, ViewGroup, int) line: 355 So there seems to be sth wrong with the regvalues array. But what ?!? Eclipse shows me no errors at compile time. So everything in the xml-file and java-code is written correctly and there are no typos. Where is the problem?!?

    Read the article

  • php how to serialize array of objects?

    - by hequ
    Hello, I have small class called 'Call' and I need to store these calls into a flat file. I've made another class called 'CallStorage' which contains an array where I put these calls into. My problem is that I would like to store this array to disk so I could later read it back and get the calls from that array. I've tried to achieve this using serialize() and unserialize() but these seems to act somehow strange and part of the information gets lost. This is what I'm doing: //write array to disk $filename = $path . 'calls-' . $today; $serialized = serialize($this->array); $fp = fopen($filename, 'a'); fwrite($fp, $serialized); fclose($fp); //read array from serialized file $filename = $path . 'calls-' . $today; if (file_exists($filename)) { $handle = fopen($filename, 'r'); $contents = fread($handle, filesize($filename)); fclose($handle); $unserialized = unserialize($contents); $this->setArray($unserialized); } Can someone see what I'm doing wrong, or what. I've also tried to serialize and write arrays that contains plain strings. I didn't manage to get that working either.. I have a Java background so I just can't see why I couldn't just write an array to disk if it's serialized. :)

    Read the article

  • For each result in MySQL query, push to array (complicated)

    - by Dylan Taylor
    Okay, here's what I'm trying to do. I am running a MySQL query for the most recent posts. For each of the returned rows, I need to push the ID of the row to an array, then within that ID in the array, I need to add more data from the rows. A multi-dimensional array. Here's my code thus far. $query = "SELECT * FROM posts ORDER BY id DESC LIMIT 10"; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ $id = $row["id"]; $post_title = $row["title"]; $post_text = $row["text"]; $post_tags = $row["tags"]; $post_category = $row["category"]; $post_date = $row["date"]; } As you can see I haven't done anything with arrays yet. Here's an ideal structure I'm looking for, just incase you're confused. The master array I guess you could call it. We'll just call this array $posts. Within this array, I have one array for each row returned in my MySQL query. Within those arrays there is the $post_title, $post_text, etc. How do I do this? I'm so confused.. an example would be really appreciated. -Dylan

    Read the article

  • C - Error with read() of a file, storage in an array, and printing output properly

    - by ns1
    I am new to C, so I am not exactly sure where my error is. However, I do know that the great portion of the issue lies either in how I am storing the doubles in the d_buffer (double) array or the way I am printing it. Specifically, my output keeps printing extremely large numbers (with around 10-12 digits before the decimal point and a trail of zeros after it. Additionally, this is an adaptation of an older program to allow for double inputs, so I only really added the two if statements (in the "read" for loop and the "printf" for loop) and the d_buffer declaration. I would appreciate any input whatsoever as I have spent several hours on this error. #include <stdio.h> #include <fcntl.h> #include <sys/types.h> #include <unistd.h> #include <string.h> struct DataDescription { char fieldname[30]; char fieldtype; int fieldsize; }; /* ----------------------------------------------- eof(fd): returns 1 if file `fd' is out of data ----------------------------------------------- */ int eof(int fd) { char c; if ( read(fd, &c, 1) != 1 ) return(1); else { lseek(fd, -1, SEEK_CUR); return(0); } } void main() { FILE *fp; /* Used to access meta data */ int fd; /* Used to access user data */ /* ---------------------------------------------------------------- Variables to hold the description of the data - max 10 fields ---------------------------------------------------------------- */ struct DataDescription DataDes[10]; /* Holds data descriptions for upto 10 fields */ int n_fields; /* Actual # fields */ /* ------------------------------------------------------ Variables to hold the data - max 10 fields.... ------------------------------------------------------ */ char c_buffer[10][100]; /* For character data */ int i_buffer[10]; /* For integer data */ double d_buffer[10]; int i, j; int found; printf("Program for searching a mini database:\n"); /* ============================= Read in meta information ============================= */ fp = fopen("db-description", "r"); n_fields = 0; while ( fscanf(fp, "%s %c %d", DataDes[n_fields].fieldname, &DataDes[n_fields].fieldtype, &DataDes[n_fields].fieldsize) > 0 ) n_fields++; /* --- Prints meta information --- */ printf("\nThe database consists of these fields:\n"); for (i = 0; i < n_fields; i++) printf("Index %d: Fieldname `%s',\ttype = %c,\tsize = %d\n", i, DataDes[i].fieldname, DataDes[i].fieldtype, DataDes[i].fieldsize); printf("\n\n"); /* --- Open database file --- */ fd = open("db-data", O_RDONLY); /* --- Print content of the database file --- */ printf("\nThe database content is:\n"); while ( ! eof(fd) ) { /* ------------------ Read next record ------------------ */ for (j = 0; j < n_fields; j++) { if ( DataDes[j].fieldtype == 'I' ) read(fd, &i_buffer[j], DataDes[j].fieldsize); if ( DataDes[j].fieldtype == 'F' ) read(fd, &d_buffer[j], DataDes[j].fieldsize); if ( DataDes[j].fieldtype == 'C' ) read(fd, &c_buffer[j], DataDes[j].fieldsize); } double d; /* ------------------ Print it... ------------------ */ for (j = 0; j < n_fields; j++) { if ( DataDes[j].fieldtype == 'I' ) printf("%d ", i_buffer[j]); if ( DataDes[j].fieldtype == 'F' ) d = d_buffer[j]; printf("%lf ", d); if ( DataDes[j].fieldtype == 'C' ) printf("%s ", c_buffer[j]); } printf("\n"); } printf("\n"); printf("\n"); } Post edits output: 16777216 0.000000 107245694331284094976.000000 107245694331284094976.000000 Pi 33554432 107245694331284094976.000000 2954938175610156848888276006519501238173891974277081114627768841840801736306392481516295906896346039950625609765296207682724801406770458881439696544971142710292689518104183685723154223544599940711614138798312668264956190761622328617992192.000000 2954938175610156848888276006519501238173891974277081114627768841840801736306392481516295906896346039950625609765296207682724801406770458881439696544971142710292689518104183685723154223544599940711614138798312668264956190761622328617992192.000000 Secret Key 50331648 2954938175610156848888276006519501238173891974277081114627768841840801736306392481516295906896346039950625609765296207682724801406770458881439696544971142710292689518104183685723154223544599940711614138798312668264956190761622328617992192.000000 -0.000000 -0.000000 The number E Expected Output: 3 rows of data ending with the number "e = 2.18281828" To reproduce the problem, the following two files need to be in the same directory as the lookup-data.c file: - db-data - db-description

    Read the article

  • Sorting a multidimensional array in objective-c

    - by Zen_silence
    Hello, I'm trying to sort a multidimensional array in objective-c i know that i can sort a single dimensional array using the line of code below: NSArray *sortedArray = [someArray sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; I can't seem to figure out how to sort a 2D array like the one below: ( ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY"), ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY"), ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY") ); If someone could provide me code that would sort the array by SOME_CATEGORY it would be of great help to me. Thanks, Zen_Silence

    Read the article

  • Java HashSet<Integer> to int array

    - by jackweeden
    I've got a HashSet with a bunch of (you guessed it) integers in it. I want to turn it into an array, but calling hashset.toArray(); returns an array of Object type. This is fine, but is there a better way to cast it to an array of int, other than iterating through every element manually? A method I want to pass it to void doSomething(int[] arr) Won't accept the Object[] array, even if I try casting it like doSomething((int[]) hashSet.toArray());

    Read the article

  • Perl, array referencing

    - by Mike
    Consider this Perl code my @a=[[1]]; print $a[0][0] . "\n"; **output** ARRAY(0x229e8) Why does it print an Array instead of 1? I would have expected @a to create an array of size 1 with a reference to a second array containing only one element, 1

    Read the article

  • from one-dimensional to two-dimensional array

    - by Thijs
    Hi again, I have this PHP one dimensional array: Array ( [Female--N] => 11 [Male--N] => 11 [Humans--N] => 11 [Adult--N] => 8 [Adolescent--N] => 8 [Reaction Time-physiology--N] => 6 [Acoustic Stimulation-methods--N] => 6 [Schizophrenia-genetics--Y] => 5 [Motion Perception--N] => 3 ) And i want a new array from this that looks like (i think this tow-dimensional..?): Array ( [Female][N] => 11 [Male][N] => 11 [Humans][N] => 11 [Adult][N] => 8 [Adolescent][N] => 8 [Reaction Time-physiology][N] => 6 [Acoustic Stimulation-methods][N] => 6 [Schizophrenia-genetics][Y] => 5 [Motion Perception][N] => 3 ) Can i use split method on key elements? Little bit harder... i also need to split on the single '_' underscore, i did this to prevent the columns getting mixed up... But the example below doesn't do the job right... $new_array = array(); foreach($MeshtagsArray as $key => $value) { $parts = explode('__', $key, 2); $parts2 = explode('_', $key, 2); $new_array[] = array( 'discriptor' => $parts[0], 'qualifier' => $parts2[1], 'major' => $parts[1], '#occurence' => $value ); So the output should be something like: [0] => Array ( [discriptor] => Female [qualifier] => [major] => N [#occurence] => 11 ........ [5] => Array ( [discriptor] => Reaction Time [qualifier] => physiology [major] => N [#occurence] => 6 Best regards, Thijs

    Read the article

  • list or container O(1)-ish insertion/deletion performance, with array semantics

    - by Chris Kaminski
    I'm looking for a collection that offers list semantics, but also allows array semantics. Say I have a list with the following items: apple orange carrot pear then my container array would: container[0] == apple container[1] == orangle container[2] == carrot Then say I delete the orange element: container[0] == apple container[1] == carrot I don't particularly care if sort order is maintained, I'd just like the array values to function as accelerators to the list items, and I want to collapse gaps in the array without having to do an explicit resizing.

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >