Search Results

Search found 15255 results on 611 pages for 'sparse array'.

Page 22/611 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • Three 1D Arrays to One 2D Array

    - by Steven
    I have a function which accepts a 2D array, but my data is in three 1D arrays. How do I create a 2D array consisting of the three arrays to pass to the subroutine? Dim Y0(32) As Double Dim Y1(32) As Double Dim Y2(32) As Double 'Code to fill arrays' 'Attempting to call:' Sub PlotYMult(YData(,) as Double)

    Read the article

  • Matlab - building an array while looping

    - by Mark
    Hello, I have a for loop that loops over one array... for i=1:length(myArray) In this loop, I want to do check on the value of myArray and add it to another array myArray2 if it meets certain conditions. I looked through the Matlab docs, but couldn't find anything on creating arrays without declaring all their values on initialization or reading data into them in one shot. Many thanks!

    Read the article

  • Write a foreach loop for this array.

    - by mjames
    Hi, I am using the xpath in php5 to parse a xml document. The problem I have is writing a foreach to correctly display the following array array(1) { [0]= object(SimpleXMLElement)#21 (2) { ["file"]= string(12) "value 1" ["folder"]= string(8) "value 2" } } Ideally i would like to get the value by using $row['file'] or $row['folder']. Thanks for any help.

    Read the article

  • Loop through Javascript array, print with string.

    - by Adam
    I have a simple array like: var myArr=["one","two","three"]; an I have a counting loop, which increases the value of var "i" by one. What I want to do is print the next value from the array each time the loop runs, next to a text string, like so: alert('value number '+myArr[i]+); But for some reason I can't get this to work. The following code works, so I'm assuming I'm not calling the counter right: alert('value number '+myArr[0]+);

    Read the article

  • [C#] Get Index of Control in an Control-Array

    - by Cocaine112358
    I have a TextBox Array private TextBox[,] Fields = new TextBox[9, 9]; and all the TextBoxes have got the same TextChanged-Event void Field_Changed( object sender, EventArgs e ) Is there a way to get the Index of the sender in the Array (without giving each TextBox it's own EventHandler)?

    Read the article

  • php array key issue

    - by Fearghal
    Hi guys.. ok so i have the following array: 0 - 208533 1 - 208523 2 - 208522 3 - 208572 4 - 208518 5 - 208501 6 - 208534 7 - 208499 All i need is a quick function that'll start the array key at 1 rather than 0. eg: 1 - 208533 etc Any ideas? Thanks!

    Read the article

  • Loop through array, print with string.

    - by Adam
    I have a simple array like: var myArr=["one","two","three"]; an I have a counting loop, which increases the value of var i by one. What I want to do is print the next value from the array each time the loop runs, next to a text string, like so: alert('value number '+myArr[i]+); But for some reason I can't get this to work. The following code works, so I'm assuming I'm not calling the counter right: alert('value number '+myArr[0]+);

    Read the article

  • Adding to an Array

    - by j-t-s
    Hi All I have an array: String[] ay = { "blah", "blah number 2" "etc" }; ... But now I want to add to this array at a later time, but I see no option to do so. How can this be done? I keep getting a message saying that the String cannot be converted to String[]. Thank you

    Read the article

  • iPhone: How to write plist array of dictionary object

    - by Alessandro
    Hello, I'm a young Italian developer for the iPhone. I have a plist file (named "Frase") with this structure: Root Array - Item 0 Dictionary Frase String Preferito Bool - Item 1 Dictionary Frase String Preferito Bool - Item 2 Dictionary Frase String Preferito Bool - Item 3 Dictionary Frase String Preferito Bool exc. An array that contains many elements dictionary, all the same, consisting of "Frase" (string) and "Preferito" (BOOL). The variable "indirizzo", increase or decrease the click of the button Next or Back. The application interface: http://img691.imageshack.us/img691/357/schermata20100418a20331.png When I click on AddPreferito button, the item "Preferito" must be YES. Subsequently, the array must be updated with the new dictionary.The code: (void)addpreferito:(id)sender { NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Frase" ofType:@"plist"]; MSMutableArray *frase = [[NSMutableArray alloc] initWithContentsOfFile:plistPath]; NSMutableDictionary *dictionary = [frase objectAtIndex:indirizzo]; [dictionary setValue: YES forKey:@"Preferito"]; [frase replaceObjectAtIndex:indirizzo withObject:dictionary]; [frase writeToFile:plistPath atomically:YES]; } Why not work? Thanks Thanks Thanks!

    Read the article

  • Gomoku array-based AI-algorithm?

    - by Lasse V. Karlsen
    Way way back (think 20+ years) I encountered a Gomoku game source code in a magazine that I typed in for my computer and had a lot of fun with. The game was difficult to win against, but the core algorithm for the computer AI was really simply and didn't account for a lot of code. I wonder if anyone knows this algorithm and has some links to some source or theory about it. The things I remember was that it basically allocated an array that covered the entire board. Then, whenever I, or it, placed a piece, it would add a number of weights to all locations on the board that the piece would possibly impact. For instance (note that the weights are definitely wrong as I don't remember those): 1 1 1 2 2 2 3 3 3 444 1234X4321 3 3 3 2 2 2 1 1 1 Then it simply scanned the array for an open location with the lowest or highest value. Things I'm fuzzy on: Perhaps it had two arrays, one for me and one for itself and there was a min/max weighting? There might've been more to the algorithm, but at its core it was basically an array and weighted numbers Does this ring a bell with anyone at all? Anyone got anything that would help?

    Read the article

  • Traverse 2D Array (Matrix) Diagonally

    - by jonobr1
    So I found this thread that was extremely helpful in traversing an array diagonally. I'm stuck though on mirroring it. For example: var m = 3; var n = 4; var a = new Array(); var b = 0; for(var i = 0; i < m; i++) { a[i] = new Array(n); for(var j = 0; j < n; j++) { a[i][j] = b; b++; } } for (var i = 0; i < m + n - 1; i++) { var z1 = (i < n) ? 0 : i - n + 1; var z2 = (i < m) ? 0 : i - m + 1; for (var j = i - z2; j >= z1; j--) { console.log(a[j][i - j]); } } Console reads [[0],[4,1],[8,5,2],[9,6,3],[10,7],[11]] I'd like it to read [[8],[4,9],[0,5,10],[1,6,11],[2,7],[3]] Been stumped for awhile, it's like a rubik's cube _<

    Read the article

  • Variable number of two-dimensional arrays into one big array

    - by qlb
    I have a variable number of two-dimensional arrays. The first dimension is variable, the second dimension is constant. i.e.: Object[][] array0 = { {"tim", "sanchez", 34, 175.5, "bla", "blub", "[email protected]"}, {"alice", "smith", 42, 160.0, "la", "bub", "[email protected]"}, ... }; Object[][] array1 = { {"john", "sdfs", 34, 15.5, "a", "bl", "[email protected]"}, {"joe", "smith", 42, 16.0, "a", "bub", "[email protected]"}, ... }; ... Object[][] arrayi = ... I'm generating these arrays with a for-loop: for (int i = 0; i < filter.length; i++) { MyClass c = new MyClass(filter[i]); //data = c.getData(); } Where "filter" is another array which is filled with information that tells "MyClass" how to fill the arrays. "getData()" gives back one of the i number of arrays. Now I just need to have everything in one big two dimensional array. i.e.: Object[][] arrayComplete = { {"tim", "sanchez", 34, 175.5, "bla", "blub", "[email protected]"}, {"alice", "smith", 42, 160.0, "la", "bub", "[email protected]"}, ... {"john", "sdfs", 34, 15.5, "a", "bl", "[email protected]"}, {"joe", "smith", 42, 16.0, "a", "bub", "[email protected]"}, ... ... }; In the end, I need a 2D array to feed my Swing TableModel. Any idea on how to accomplish this? It's blowing my mind right now.

    Read the article

  • weird result with c# winForms array of Lists

    - by jello
    so I'm trying to store values in an array of Lists in C# winForms. In the for loop in which I make the sql statment, everything works fine: the message box outputs a different medication name each time. for (int i = 0; i < numberOfMeds; i++) { queryStr = "select * from biological where medication_name = '" + med_names[i] + "' and patient_id = " + patientID.patient_id; using (var conn = new SqlConnection(connStr)) using (var cmd = new SqlCommand(queryStr, conn)) { conn.Open(); using (SqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { medObject.medication_date = (DateTime)rdr["patient_history_date_bio"]; medObject.medication_name = rdr["medication_name"].ToString(); medObject.medication_dose = Convert.ToInt32(rdr["medication_dose"]); medsList[i].Add(medObject); } } conn.Close(); MedicationTimelineClass medObjectx = medsList[i][0] as MedicationTimelineClass; MessageBox.Show(medObjectx.medication_name); } } but then, when I take the message box code out of the loop, meaning that the array of Lists is supposed to be populated, I always get the same value: the last value entered. the same medication name, no matter what number I put between those brackets. It's like if the whole array of Lists is populated with the same data. for (int i = 0; i < numberOfMeds; i++) { queryStr = "select * from biological where medication_name = '" + med_names[i] + "' and patient_id = " + patientID.patient_id; using (var conn = new SqlConnection(connStr)) using (var cmd = new SqlCommand(queryStr, conn)) { conn.Open(); using (SqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { medObject.medication_date = (DateTime)rdr["patient_history_date_bio"]; medObject.medication_name = rdr["medication_name"].ToString(); medObject.medication_dose = Convert.ToInt32(rdr["medication_dose"]); medsList[i].Add(medObject); } } conn.Close(); } } MedicationTimelineClass medObjectx = medsList[0][0] as MedicationTimelineClass; MessageBox.Show(medObjectx.medication_name); what's going on here?

    Read the article

  • Trouble with C# array

    - by Biosci3c
    Hi, I am writing a card playing program as a way of learning C#. I ran into an issue with an array going out of bounds. Here is my code: namespace Pcardconsole { class Deck { public Deck() { // Assign standard deck to new deck object int j; for (int i = 0; i != CurrentDeck.Length; i++) { CurrentDeck[i] = originalCards[i]; } // Fisher-Yates Shuffling Algorithim Random rnd = new Random(); for (int k = CurrentDeck.Length - 1; k >= 0; k++) { int r = rnd.Next(0, k + 1); int tmp = CurrentDeck[k]; CurrentDeck[k] = CurrentDeck[r]; CurrentDeck[r] = tmp; // Console.WriteLine(i); } } public void Shuffle() { // TODO } // public int[] ReturnCards() // { // TODO // } public int[] originalCards = new int[54] { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x50, 0x51 }; public int[] CurrentDeck = new int[54]; } class Program { static void Main(string[] args) { // Create a Deck object Deck mainDeck = new Deck(); Console.WriteLine("Here is the card array:"); for (int index = 0; index != mainDeck.CurrentDeck.Length; index++) { string card = mainDeck.CurrentDeck[index].ToString("x"); Console.WriteLine("0x" + card); } } } The hexidecimal numbers stand for different cards. When I compile it I get an array index out of bounds error, and a crash. I don't understand what is wrong. Any help would be much appreciated.

    Read the article

  • PHP: Array of objects is empty when I come to retrieve one from the array

    - by Tom
    Good morning, I am trying to load rows from a database and then create objects from them and add these objects to a private array. Here are my classes: <?php include("databaseconnect.php"); class stationItem { private $code = ''; private $description = ''; public function setCode($code ){ $this->code = $code; } public function getCode(){ return $this->code; } public function setDescription($description){ $this->description = $description; } public function getDescription(){ return $this->description; } } class stationList { private $stationListing; function __construct() { connect(); $stationListing = array(); $result = mysql_query('SELECT * FROM stations'); while ($row = mysql_fetch_assoc($result)) { $station = new stationItem(); $station->setCode($row['code']); $station->setDescription($row['description']); array_push($stationListing, $station); } mysql_free_result($result); } public function getStation($index){ return $stationListing[$index]; } } ?> As you can see I am creating a stationItem object per database row (which for now has a code and description) and I then push these on to the end of my array which is held as a private variable in stationList. This is code which creates this classes and attempts to access the properties on them: $stations = new stationList(); $station = $stations->getStation(0); echo $station->getCode(); I am finding that the sizeof($stationList) at the end of the constructor is 1 but then it is zero when we come to try to get an object from the array using the index. Therefore the error that I get is: Fatal error: Call to a member function getCode() on a non-object Please can someone explain to me why this is happening? I guess I am misunderstanding how object references work in PHP5.

    Read the article

  • Return an Oracle Associative Array from a function

    - by Paul Johnson
    Does anybody know if it is possible to return an associative array as the result of an Oracle function, if so do you have any examples? I have an Oracle package which contains an associative array declaration as defined below: TYPE EVENTPARAM IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; This is then used in a stored procedure outside the package as follows: v_CompParams areva_interface.eventparam; The intention is to store an associative array of strings in the variable v_CompParams, returned from a Parse function in another package. The definition for which is as follows: PACKAGE STRING_MANIP IS TYPE a_array IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; FUNCTION Parse (v_string VARCHAR2, v_delim VARCHAR2) RETURN a_array; FUNCTION RowCount(colln IN a_array) RETURN NUMBER; END; The code which implements this is: v_CompParams := STRING_MANIP.PARSE(v_CompID,v_Delim); Unfortunately it doesn't work, I get the error 'PLS-00382: expression is of wrong type'. I foolishly assumed, that since a_array derives from the same source Oracle type as the variable v_CompParams, that there would be no problem casting between them. Any help much appreciated. Kind Regards Paul J.

    Read the article

  • remove values from an array php

    - by LiveEn
    I have a array of links and i have another array which contains certain values i would like to filter in the list eg: http://www.liquidshredder.co.uk/shop%3Fkw%3Dsurfboards%26fl%3D330343%26ci%3D3889610385%26network%3Ds http://www.bournemouth-surfing.co.uk/index.php%3FcPath%3D32 http://www.stcstores.co.uk/wetsuit-range-sizing--pricing-info-1-w.asp http://www.kingofwatersports.com/wetsuit-sale-c227.html http://www.uk.best-price.com/search/landing/query/bodyboards/s/google/altk/Surf%2Band/koid/1944273223/ http://www.surfinghardware.co.uk/Results.cfm%3Fcategory%3D20%26kw%3Dbodyboards%26fl%3D11407%26ci%3D3326979552%26network%3Ds http://www.teste.co.uk/adtrack/baod.html http://www.teste.co.uk/bodyboards/ www.sandskater.co.uk/ www.sandskater.co.uk/bodyboards/+Bodyboards&sa=X&ei=GwSWS-KaGM24rAeF-vCKDA&ved=0CBMQHzAKOAo http://www.extremesportstrader.co.uk/buy/water/bodyboarding/ www.extremesportstrader.co.uk/buy/water/bodyboarding/+Bodyboards&sa=X&ei=GwSWS-KaGM24rAeF-vCKDA&ved=0CBYQHzALOAo www.circle-one.co.uk/+Bodyboards&sa=X&ei=GwSWS-KaGM24rAeF-vCKDA&ved=0CBkQHzAMOAo http://www.teste.co.uk/bodyboards/p1 http://www.teste.co.uk/bodyboards/p2 http://www.amazon.co.uk/s/%3Fie%3DUTF8%26keywords%3Dbodyboards%26tag%3Dgooghydr-21%26index%3Daps%26hvadid%3D4764625891%26ref%3Dpd_sl_2lyzsfw1ar_e http://www.teste.co.uk/bodyboards/p3 www.extremesportstrader.co.uk/buy/water/ and i would like to remove all the instances of "http://www.teste.co.uk"? i tried the below code but it doesn't work :( $remove=array("teste.co.uk","127.0.0.1","localhost","wikipedia.org","gmail.com","answers.yahoo.com"); foreach ($list[0] as $key=>$clean) { if (in_array($clean,$remove)) { unset($list[0][$key]); } echo $clean; echo '<br>'; }

    Read the article

  • Please help with passing multidimensional arrays

    - by nn
    Hi, I'm writing a simple test program to pass multidimensional arrays. I've been struggling to get the signature of the callee function. void p(int (*s)[100], int n) { ... } In the code I have: int s1[10][100], s2[10][1000]; p(s1, 100); This code appears to work, but it's not what I intended. I want to the function p to be oblivious whether the range of values is 100 or 1000, but it should know there are 10 pointers. I tried as a first attempt: void p(int (*s)[10], int n) // n = # elements in the range of the array and also: void p(int **s, int n) // n = # of elements in the range of the array But to no avail can I seem to get this correct. I don't want to hardcode the 100 or 1000, but instead pass it in, but there will always be 10 arrays. Obviously, I want to avoid having to declare the function: void p(int *s1, int *s2, int *s3, ..., int *s10, int n) FYI, I'm looking at the answers to a similar question but still confused.

    Read the article

  • PHP , How can I get values out of a complex array ?

    - by Joe appleton
    I am calling a soap function that returns the following array: Array ( [FastAddressResult] = Array ( [IsError] = false [ErrorNumber] = 0 [ErrorMessage] = [Results] = Array ( [Address] = Array ( [Id] = 13872147.00 [OrganisationName] = [DepartmentName] = [Line1] = Methley Grove [Line2] = [Line3] = [Line4] = [Line5] = [PostTown] = Leeds [County] = West Yorkshire [Postcode] = LS7 3PA [Mailsort] = 64121 [Barcode] = [IsResidential] = false [IsSmallOrganisation] = false [IsLargeOrganisation] = false [RawData] = [GeographicData] = Array ( [GridEastM] = 0 [GridNorthM] = 0 [Objective2] = false [Transitional] = false [Longitude] = 0 [Latitude] = 0 [WGS84Longitude] = 0 [WGS84Latitude] = 0 ) ) ) ) I need to exstract the values the following does not seem to work:          $this-adressline1 = $result-FastAddressResult-Results-Address-Line1; Any ideas ?

    Read the article

  • How can I pass a const array or a variable array to a function in C?

    - by CSharperWithJava
    I have a simple function Bar that uses a set of values from a data set that is passed in in the form of an Array of data structures. The data can come from two sources: a constant initialized array of default values, or a dynamically updated cache. The calling function determines which data is used and should be passed to Bar. Bar doesn't need to edit any of the data and in fact should never do so. How should I declare Bar's data parameter so that I can provide data from either set? union Foo { long _long; int _int; } static const Foo DEFAULTS[8] = {1,10,100,1000,10000,100000,1000000,10000000}; static Foo Cache[8] = {0}; void Bar(Foo* dataSet, int len);//example function prototype Note, this is C, NOT C++ if that makes a difference; Edit Oh, one more thing. When I use the example prototype I get a type qualifier mismatch warning, (because I'm passing a mutable reference to a const array?). What do I have to change for that?

    Read the article

  • Default boolean value in a array of record - Delphi

    - by James
    Hi, I am helping out my company with some old delphi 7 code. There is a record declared at the start that is used throughout to store all the data we want outputted. type TOutput_Type = record result: String; resultoffset: String; selected: boolean; resultcategory: integer; end; and then an array of this is declared Output: array of TOutput_Type; The length is set at the start to a large value, as actual length is unknown. This array is used all over the place, but unfortunately the value selected is not always set when used. My problem is I am adding in a summary of the data, but because selected is not set, delphi seems to give it a random true or false status. Is there a way of setting all instances of selected as true at the start? Seems like a simple enough thing to do, but I'm not a delphi programmer so am unsure if its possible? I know I can go through and add in selected := true every time a new record is made, but I'd like to do it cleanly at the start if possible.... Thanks in advance

    Read the article

  • Define an empty array in Perl class new()

    - by Laimoncijus
    Hi, I am just beginner with Perl, so if it sounds stupid - sorry for that :) My problem is - I am trying to write a class, which has an empty array, defined in constructor of a class. So I am doing this like this: package MyClass; use strict; sub new { my ($C) = @_; my $self = { items => () }; bless $self, ref $C || $C; } sub get { return $_[0]->{items}; } 1; Later I am testing my class with simple script: use strict; use Data::Dumper; use MyClass; my $o = MyClass->new(); my @items = $o->get(); print "length = ", scalar(@items), "\n", Dumper(@items); And while running the script I get following: $ perl my_test.pl length = 1 $VAR1 = undef; Why am I doing wrong what causes that I get my items array filled with undef? Maybe someone could show me example how the class would need to be defined so I would not get any default values in my array? Thanks!

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >