How do you loop through a string in Ruby?
Pretty simple question from a first-time Ruby programmer. How do you loop through a slab of text in Ruby? Everytime a newline is met, I want to re-start the inner-loop. def parse(input) ... end ...
Pretty simple question from a first-time Ruby programmer. How do you loop through a slab of text in Ruby? Everytime a newline is met, I want to re-start the inner-loop. def parse(input) ... end ...
Hi I have got a timerEvent that adds 25 movieclips to the stage and animates them from x:0,y:0, this all works fine! What i would like to do is assign each movie clip a y value of 25px more than the last movieClip added to the stage. I did a little test by trying to increment a number value each time the timer did a loop but it didnt inc...
I am very new to SQL i can work with basic statements fairly easily but i haven't figured out loops yet. Foreach(JobHeaderID AS @OldJobHeaderID in dbo.EstimateJobHeader WHERE EstimateID=@OldEstimateID) { INSERT EstimateJobHeader (ServiceID,EstimateID) SELECT ServiceID, @NewEstimateID FROM EstimateJobHeader WHERE EstimateI...
Dear all, The following codes try to generate random strings over K runs. But we want the newly generated strings to be totally different with its reference string. For that I tried to use "continue" to restart the random string generation process. However it doesn't seem to work. What's wrong with my approach below? #include <iostre...
Hi, I have a question about the std::vector. I have a very memory intensive algorithm where I forsee that predicting vector sizes and reserving enough memory for the vectors in advance will help me a lot with reducing memory usage. Which of the following is better: for ( ... ) { std::vector<Type> my_vector; my_vector.reserve(stuff...
Was looking at some code earlier, and am thinking that there has to be a more elegant way of writing this.... (returnVar.Warnings is a string array, it could be returned as any size depending on the number of warnings that are logged) For Each item In items If o.ImageContent.ImageId = 0 Then ReDim Preserve returnVar.Warning...
In reference to this I've created a question in a webform like this: <div class="form_row"> <label for="features[]">Features:</label> <% [ 'scenarios', 'role_profiles', 'private_messages', 'polls' ].each do |feature| %> <br><%= check_box_tag 'features[]', feature, (params[:features] || {}).in...
Dear all, I have a data that looks like this: >day11:1:356617 ACTTCTGATTCTGACAGACTCAGGAAGAAACCAT >day11:2:283282 CTCAGCCCGTAGCCCGTCGGTTCCGGAGTAAGTT >day11:3:205058 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN >day11:4:202520 AGTTCGATCGGTAGCGGGAGCGGAGAGCGGACCC >day11:5:107099 AGGCATTCAGGCAGCGAGAGCAGAGCAGCGTAGA >day11:6:106715 CTCTTTGCCCCATCTACTGC...
Hi, I need to retrieve data from several rows and then insert the results into an enumerated array so then I can use a "for" loop to echo it... I have this (I already connected to the database): $genres_sql = 'SELECT genreID FROM genres WHERE imdbID = ?'; if ($stmt->prepare($genres_sql)) { // bind the query parameters $stmt->bind_par...
What is the special case with the foreach/for loop that eliminates bounds checking? Also which bounds checking is it? ...
I have an array which contains the categories for a particular article ($link_cat). I'm then using mysql_fetch_array to print out all of the categories available into a list with checkboxes. While it's doing this I want it to compare the value it's on, to a value from the other array. If there is a match, then it means that one of the ca...
I have a situation where I'm marching through a vector, doing things: std::vector::iterator iter = my_list.begin(); for ( ; iter != my_list.end(); ++iter ) { if ( iter->doStuff() ) // returns true if successful, false o/w { // Keep going... } else { for ( ; iter != m_list.begin(); --iter ) // ...This won't work......
What is the difference between for..in and for each..in statements in javascript? Are there subtle difference that I don't know of or is it the same and every browser has a different name for it? ...
LOOP This works with do: x=0 loop do puts x; x+=1; break if x == 100 end but not with a semicolon: x=0 loop; puts x; x+=1; break if x == 100 end UNTIL However, this works with 'do': until x == 100 do puts x; x+=1 end and with a simicolon: until x == 100; puts x; x+=1 end With certain Ruby syntax I have a choice of u...
I am having some trouble with my program logic that loops through a collection of data that exists in two separate ListViews. After looping though and extracting the data from the ListView, I then add everything into a comma delimited text file (CLOSEULDCONFIG.TXT). The first time that I execute this logic, everything works as it shoul...
I am very puzzled about this code: var closures = []; function create() { for (var i = 0; i < 5; i++) { closures[i] = function() { alert("i = " + i); }; } } function run() { for (var i = 0; i < 5; i++) { closures[i](); } } create(); run(); From my understanding it should print 0,1,2,3,4 (isn't this the conc...
Upon debugging i had thought i did it right. But it was only the first member as the first element in the vector that was corrected. while ( !inFile->eof() ) { getline( *inFile, str1, ',' ); sStruct.str1 = str1; getline( *inFile, str2, ',' ); sStruct.str2 = str2; getline( *inFile, str3, ',' ); sStruct.str3 ...
I am attempting to create a fixed step loop in my program, but for some reason I just can't seem to get it to work properly. Basically what I need is a loop that does: while(!over) { Update(elapsedtime); Draw(elapsedtime); } or something similar, with a . I've tried using Thread.Sleep but I'm not so sure it gave me a real fixe...
I am putting an XSL together than will create a NAnt build script using as input an XML file that defines all of the items that need to be built. We have a lot of very similar projects with standard layouts and defined standards for handover areas and so having an XML file that defines what the developers want to happen rather than desc...
I've started fiddling with C to improve my programming skills, and decided to try and implement a Tetris game. Nothing too fancy, it'll run on the console. I never implemented a game that keeps running despite user input, and didn't figure out I'd have to deal with this problem until I started thinking about the game algorithm. Googl...