iterate

Loop through System.Collections.Generic.Dictionary via for statement

Hi folks, I have a quick question. Is there way to easy loop through System.Collections.Generic.Dictionary via for statement in C#? Thanks in advance. ...

Iterate through XML nodes that have xmlns attribute declared in a XSL.

I am working on creating an XSL to format some incoming XML from an API I am integrating. The xml I receive looks like: <items> <item xmlns="http://www.tempuri.org/Item.xsd"&gt; <key>value</key> </item> <item> <key>value</key> </item> <item xmlns="http://www.tempuri.org/Item.xsd"&gt; <key>value</key> </item> </i...

jQuery iterating over a function

Pretty new to jquery and having a bit of a problem with a function I wrote, very similar to this problem, and if that's anything to go on then apparently I have a closure problem. As Peter Bailey put it in the above thread, this is what's happening: Iterate over some values Define/assign a function in that iteration that uses iterated ...

Make a html page with content() and jquery

Is there a way to make an html page from the contents() object?? for example iterate over $('body').contents() object and make a output like this: <body> <div>text<a href=#></a></div> <p>%^$$</p> .... </body> thanks!!! and sorry for the english! ...

Iterate in compact json structure using jquery

Hey, Is there easy way to iterate json structure like this ? var xstring = [ {"test1",1} ,{"test2",2} ,{"test77","aa"} ] ; ...

PHP - Getting position within a loop

Hi, I have a function which is called within a foreach loop and takes in two parameters, an integer, representing the number of times the loop has run and an array (of no fixed size). I would like to return the value of the array key that is equal to the counter. For example, if the array has four elements: A, B, C and D and the counte...

How to I extract floats from a file in Python?

So, I have a file that looks like this: # 3e98.mtz MR_AUTO with model 200la_.pdb SPACegroup HALL P 2yb #P 1 21 1 SOLU SET RFZ=3.0 TFZ=4.7 PAK=0 LLG=30 SOLU 6DIM ENSE 200la_ EULER 321.997 124.066 234.744 FRAC -0.14681 0.50245 -0.05722 SOLU SET RFZ=3.3 TFZ=4.2 PAK=0 LLG=30 SOLU 6DIM ENSE 200la_ EULER 329.492 34.325 209.775 FRAC 0.70297 0....

Django Query in a loop fails for no good reason

Hi all, I have this code: msgs = int(post['time_in_weeks']) for i in range(msgs): tip_msg = Tip.objects.get(week_number=i) it always results in an error saying that no values could be found. week_number is an integer field. When I input the value of i directly, the query works. When i print out the value of i I get the expected ...

Any reason PHP don't iterate array by reference?

$arr = array(array(array())); foreach($arr as $subarr) { $subarr[] = 1; } var_dump($arr); Output: array(1) { [0]=> array(1) { [0]=> array(0) { } } } But for object,it's reference: class testclass { } $arr = array(new testclass()); foreach($arr as $subarr) { $subarr->new = 1; } var_dump($arr); Output: array(1...

LINQ: How to skip one then take the rest of a sequence

Hi All, i would like to iterate over the items of a List<T>, except the first, preserving the order. Is there an elegant way to do it with LINQ using a statement like: foreach (var item in list.Skip(1).TakeTheRest()) {.... I played around with TakeWhile , but was not successful. Probably there is also another, simple way of doin...

Merging sequences by type With LINQ

I want to use LINQ to convert this IEnumerable<int>[] value1ByType = new IEnumerable<int>[3]; value1ByType[0]= new [] { 0}; value1ByType[1]= new [] {10,11}; value1ByType[2]= new [] {20}; var value2ToType = new Dictionary<int,int> { {100,0}, {101,1}, {102,2}, {103,1}}; to this var value2ToValue1 = new Dictionary<int,int> { {100, 0},...

How can I randomly iterate through a large Range?

I would like to randomly iterate through a range. Each value will be visited only once and all values will eventually be visited. For example: class Array def shuffle ret = dup j = length i = 0 while j > 1 r = i + rand(j) ret[i], ret[r] = ret[r], ret[i] i += 1 ...

foreach: how to iterate this

object(stdClass)[1] public 'inbox' => array 0 => object(stdClass)[2] public 'from' => string '55512351' (length=8) public 'date' => string '29/03/2010' (length=10) public 'time' => string '21:24:10' (length=8) public 'utcOffsetSeconds' => int 3600 public 're...

is there a way to condense a vector (C++)?

I have a sparsely populated vector that I populated via hashing, so elements are scattered randomly in the vector. Now what I want to do is iterate over every element in that vector. What I had in mind was essentially condensing the vector to fit the number of elements present, removing any empty spaces. Is there a way I can do this? ...

efficiently list items in tuples starting at end

I'd like to list the items in a tuple in Python starting with the back and go to front. Similar to: foo_t = tuple(int(f) for f in foo) print foo, foo_t[len(foo_t)-1] ... I believe this should be possible without Try ...-4, except ...-3. Thoughts? suggestions? ...

ibatis problem using <isNull> whilst iterating over a List

Hi, I'm new to iBatis and I'm struggling with the and elements. I want to iterate over a List of Book instances (say) that are passed in as a HashMap: MyParameters. The list will be called listOfBooks. The clause of the overall SQL statement will therefore look like this: <iterate prepend="AND" property="MyParameters.listOfBooks" ...

Iterating through a JSON object.

[ { "title": "Baby (Feat. Ludacris) - Justin Bieber", "description": "Baby (Feat. Ludacris) by Justin Bieber on Grooveshark", "link": "http://listen.grooveshark.com/s/Baby+Feat+Ludacris+/2Bqvdq", "pubDate": "Wed, 28 Apr 2010 02:37:53 -0400", "pubTime": 1272436673, "TinyLink": "h...

PHP: Iterate through folders and display HTML contents

Hi, I’m currently trying to develop a method to get a overview of all my different web templates I’ve created and (legally) downloaded over the years. I thought about a displaying them like Wordpress is previewing it’s templates view a small preview windows, displaying the concrete file with styles and everything. How to divide them in...

Iterate through directory filenames using JavaScript on ASP.NET C#

Hello all, I'm trying to read all filenames from a specified (server- not client) folder, and insert all the filenames into a javascript Array. It should behave like the Directory.GetFiles method in ASP.NET C#. I created a new array, and I just need the loop method (Javascript or jQuery) to iterate in the specific folder, and insert all ...

jquery iterating through newly created elements

Hi All, I am trying to add new rows in my table, and save them into DB. First, I use .append() to append rows on the table: $("#tablename").append("<tr id='newRow'><td>newly added row</td></tr>"); The appending function works fine. My page displays the correct result. However, I am unable to select them with $("#newRow").each(func...