Search Results

Search found 31321 results on 1253 pages for 'array size'.

Page 31/1253 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • Objective-C why doesn't my array of array works?

    - by Quetsche
    This is probably a completely stupid question, but i'm pretty new at objective-C and programing in general. i'm trying to make an array of arrays but can't manage to make it work : @interface ArraysAndDicts : NSObject { NSMutableArray * mySimpleArray; NSMutableArray * myComplicatedArray; } the implementation : -(void)generateValueForArrayOfArrays { [self generateValueForArray]; //this generates an array with 5 elements 'mySimpleArray' [myComplicatedArray addObject:mySimpleArray]; NSMutableArray * mySecondaryArray = [[NSMutableArray alloc] init]; [mySecondaryArray addObject:@"twoone"]; [mySecondaryArray addObject:@"twotwo"]; [myComplicatedArray addObject:mySecondaryArray]; (i edited out all the NSLogs for clarity) When running my app, the console tells me : mySecondaryArray count = 2 mySimpleArray count = 5 myComplicatedArraycount = 0 So, i know there are other ways to make multidimensional arrays, but i'd really like to know why this doesn't work. Thank you.

    Read the article

  • Write a foreach loop for array of SimpleXMLElements

    - by mjames
    Hi, I am using the XPath in PHP 5 to parse a XML document. The problem I have is writing a foreach to correctly display the following array: XML document sample value 1 value 2 $xmlfile = 'link_to_file.xml'; $xmlRaw = file_get_contents($xmlfile); $xml = new SimpleXMLElement($xmlRaw); $install_files = $xml->xpath('//files'); foreach($install_files as $row) { echo $row['file']; } //var_dump for $row gives the following 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

  • echoing our parts of an Array?

    - by Wes
    I have the following array that I get as an output from facebook: http://www.paste.to/v/1jntlnml With the following code: $stream = $facebook->api_client->stream_get('',128342905144,'0','0',30,'','','',''); foreach($stream as $wallpost) { echo '<pre>'; print_r($wallpost); echo '</pre>'; } So I get the data that I need, but I want to call the individual variables within this array. For example, echo out the [message] for each post. Since it only loops once, I cant echo $wallpost['message'] or anything similar. any idea?

    Read the article

  • C++: use array of strings wrapped in namespace?

    - by John D.
    I got the following code, wishing to wrap a group of strings nicely in a namespace: namespace msgs { const int arr_sz = 3; const char *msg[arr_sz] = {"blank", "blank", "blank" }; msg[0] = "Welcome, lets start by getting a little info from you!\n"; msg[1] = "Alright, bla bla bla.."; msg[2] = "etc."; } The code inside works nicely inside a function, but I don't know how to return an array from it. The namespace idea LOOKS fine, but it returns on the last three lines: error: expected constructor, destructor, or type conversion before ‘=’ token Why can't I define the array inside a namespace, do I need to do something first? It's nice because I can call it like printf(msgs::msg[1]) etc. I want to do this I just can't wrap my head around what's wrong :(

    Read the article

  • Pushin each_line into array not working

    - by zettt
    Hi, I've got a weird issue with Ruby. I want to read data from a file and put the data then into an array. The weird thing is, it's working in another script which does basically, the same thing. quoteArray = [] quoteFile = File.new("quotes.txt", "r") or die "Unable to open file..." quoteFile.each_line { |line| quoteArray.push line } puts quoteArray[0] All I get out of this is an array with one element where the whole text file is in. What's wrong? Is it my machine? The text file? Any ideas? Thanks in advance

    Read the article

  • Python - multi-line array

    - by Ockonal
    Hi guys, in c++ I can wrote: int someArray[8][8]; for (int i=0; i < 7; i++) for (int j=0; j < 7; j++) someArray[i][j] = 0; And how can I initialize multi-line arrays in python? I tried: array = [[],[]] for i in xrange(8): for j in xrange(8): array[i][j] = 0

    Read the article

  • Dynamically Generate Multi-Dimensional Array in Ruby

    - by user335729
    Hi, I'm trying to build a multidimensional array dynamically. What I want is basically this (written out for simplicity): b = 0 test = [[]] test[b] << ["a", "b", "c"] b += 1 test[b] << ["d", "e", "f"] b += 1 test[b] << ["g", "h", "i"] This gives me the error: NoMethodError: undefined method `<<' for nil:NilClass. I can make it work by setting up the array like test = [[], [], []] and it works fine, but in my actual usage, I won't know how many arrays will be needed beforehand. Is there a better way to do this? Thanks

    Read the article

  • Finding the median of the merged array of two sorted arrays in O(logN)?

    - by user176517
    Refering to the solution present at MIT handout I have tried to figure out the solution myself but have got stuck and I believe I need help to understand the following points. In the function header used in the solution MEDIAN -SEARCH (A[1 . . l], B[1 . . m], max(1,n/2 - m), min(l, n/2)) I do not understand the last two arguments why not simply 1, l why the max and min respectively. Thanking You.

    Read the article

  • Mouse pointer size inconsistent

    - by charon00
    Since installing Ubuntu 12.04, I've been having a problem with the mouse pointer size. On the desktop, it is quite a bit larger than it should be (24), though the different cursors (editing text, hyperlink hand, etc) are correct. The size changes to the correct size when the pointer is over some application windows (GVim, Netbeans, Firefox), but then changes back once it is moved out of the window. There was a similar question here, but the Xdefaults solution did not work for me, and I didn't want to try the one requiring editing the icon image. In addition, I've tried changing the cursor theme using sudo update-alternatives --config x-cursor-theme as well as using the dconf-editor, but though I can change the theme, the size issue remains. In case it's relevant, I'm running on a dual-screen setup with monitor sizes of 2560x1600 and 1920x1080, using the NVidia video driver. Is there another way to control pointer size, or a setting that might be messing it up? EDIT: These are the values/options I have for update-alternatives and in dconf-editor. I'm now wondering if Netbeans and Firefox are making the mouse pointer smaller than it should be, but I'm not sure how big 24 should be... update-alternatives: Selection Path Priority Status ------------------------------------------------------------ 0 /usr/share/icons/DMZ-White/cursor.theme 90 auto mode 1 /etc/X11/cursors/core.theme 30 manual mode 2 /etc/X11/cursors/handhelds.theme 20 manual mode 3 /etc/X11/cursors/redglass.theme 20 manual mode 4 /etc/X11/cursors/whiteglass.theme 20 manual mode * 5 /usr/share/icons/DMZ-Black/cursor.theme 30 manual mode 6 /usr/share/icons/DMZ-White/cursor.theme 90 manual mode dconf-editor: I can't post the image since I'm a new user but the cursor-size is set to 24 and the cursor-theme is DMZ-Black.

    Read the article

  • How to swap or move 2 string in Array? [on hold]

    - by Wisnu Khazefa
    I have a need to convert .csv file to .dat file. In my problem, there are value pairs, with a name attribute (called Fund) and corresponding numeric value. If the input file has a pair whose value is 0, then that pair (Fund and value) is dropped. The output file should have only those pairs (Fund and value) where the value is non-zero. Here is the prototype of my code. public static void Check_Fund(){ String header = "Text1,Text2,Text3,FUND_UALFND_1,FUND_UALPRC_1,FUND_UALFND_2," +"FUND_UALPRC_2,FUND_UALFND_3,FUND_UALPRC_3,FUND_UALFND_4,FUND_UALPRC_4,FUND_UALFND_5,FUND_UALPRC_5,Text4,Text5,Text6,Text7"; String text = "ABC;CDE;EFG;PRMF;0;PRFF;50;PREF;0;PRCF;0;PRMP;50;TAHU;;BAKWAN;SINGKONG"; String[] head; String[] value; String showText = ""; head = header.split(","); value = text.split(";"); String regex = "\\d+"; String[] fund = {"PREF","PRMF","PRFF","PRCF","PRMP","PDFF","PSEF","PSCB","PSMF","PRGC","PREP"}; for(int i = 0; i < value.length; i++){ for(int j=0;j < fund.length; j++){ if(value[i].equals(fund[j]) && value[i+1].matches(regex)){ if(value[i+1].equals("0")){ value[i] = ""; value[i+1] = ""; } } } showText = showText + head[i] +":" + value[i] + System.lineSeparator(); } System.out.println(showText ); } Expected Result Input: FUND_UALFND_1:PRMF FUND_UALPRC_1:0 FUND_UALFND_2:PRFF FUND_UALPRC_2:50 FUND_UALFND_3:PREF FUND_UALPRC_3:0 FUND_UALFND_4:PRCF FUND_UALPRC_4:0 FUND_UALFND_5:PRMP FUND_UALPRC_5:50 Output: FUND_UALFND_1:PRFF FUND_UALPRC_1:50 FUND_UALFND_2:PRMP FUND_UALPRC_2:50 FUND_UALFND_0: FUND_UALPRC_0: FUND_UALFND_0: FUND_UALPRC_0: FUND_UALFND_0: FUND_UALPRC_0:

    Read the article

  • Convert cell array of cells into cell array of strings in MATLAB

    - by yuk
    Using regexp with tokens on cell array of strings I've got cell array of cells. Here is simplified example: S = {'string 1';'string 2';'string 3'}; res = regexp(S,'(\d)','tokens') res = {1x1 cell} {1x1 cell} {1x1 cell} res{2}{1} ans = '2' I know I have only one match per cell string in S. How I can convert this output into cell arrays of strings in a vectorized form?

    Read the article

  • LINQ - array property contains element from another array

    - by Rob
    I have a object (product), with a property of type 'array' e.g. product.tags = {"tag1","tag2","tag9"} I have an array of input tags to filter on. ... but this is not quite working: List<string> filterTags = new List<string>() { "tag1", "tag3" }; var matches = from p in products where p.Tags.Contains(filterTags) select p; Any recommendations? Thanks.

    Read the article

  • PHP Sum Array - sum only elemants of an array

    - by Homer_J
    Hi all, I have have an array as follows: $row[6] This section of the array has 4 numbers within it that I can display and use without any problems, what I'd like to be able to do is sum the first two numbers and the last two numbers separately. Is there any way to do this? Thanks in advance, Homer.

    Read the article

  • Determining whether one array contains the contents of another array in ruby

    - by Andrew Grimm
    In ruby, how do I test that one array not only has the elements of another array, but contain them in that particular order? correct_combination = [1, 2, 3, 4, 5] [1, 5, 8, 2, 3, 4, 5].function_name(correct_combination) # => false [8, 10, 1, 2, 3, 4, 5, 9].function_name(correct_combination) # => true I tried using include, but that is used to test whether [1,2,3].include?(2) is true or not.

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >