Search Results

Search found 8019 results on 321 pages for 'for loop'.

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

  • How to break out of a nested parallel (OpenMP) Fortran loop idiomatically?

    - by J.F. Sebastian
    Here's sequential code: do i = 1, n do j = i+1, n if ("some_condition") then result = "here's result" return end if end do end do Is there a cleaner way to execute iterations of the outer loop concurrently other than: !$OMP PARALLEL private(i,j) !$OMP DO do i = 1, n if (found) goto 10 do j = i+1, n if (found) goto 10 if ("some_condition") then !$OMP CRITICAL !$OMP FLUSH if (.not.found) then found = .true. result = "here's result" end if !$OMP FLUSH !$OMP END CRITICAL goto 10 end if end do 10 continue end do !$OMP END DO NOWAIT !$OMP END PARALLEL

    Read the article

  • Why can't i loop through my json object using jquery?

    - by Pandiya Chendur
    I am using jquery to loop through json object... But some how it doesn't seem to work... Here is my code, success: function(jsonObj) { alert(jsonObj); for (var i = jsonObj.length - 1; i >= 0; i--) { var employee = jsonObj[i]; alert(employee.Emp_Name); When alerted my jsonObj i got [object Object] but when i alerted jsonObj.length it showed undefined any suggestion....

    Read the article

  • How do I break out of a loop in Scala?

    - by TiansHUo
    For Problem 4 of Project Euler How do I break out a loop? var largest=0 for(i<-999 to 1 by -1) { for (j<-i to 1 by -1) { val product=i*j if (largest>product) // I want to break out here else if(product.toString=product.toString.reverse) largest=largest max product } } And does anyone know how to turn nested for loops into tail recursion?

    Read the article

  • Consequences of an infinite loop on Google App Engine?

    - by Axidos
    I am not a Google App Engine user. However, I understand you're billed for CPU time and other resources. What are the consequences if you happen to create an infinite loop? Will Google ever terminate it, or will you have to do it yourself manually somehow? I'm a hobbyist developer worried about a small error that might end up costing hundreds.

    Read the article

  • how to print numbers using for loop in java?

    - by Balkrushn Viroja
    I have one text box in which I take the value of how many number do you want to print. Now My question is that how can I use for loop so that the number which I want to print is equal to the number that I got from textbox.One more thing is that i want to print only three numbers in one line. i.e. If I got 14 in my text box the result will look like below. 1 2 3 4 5 6 7 8 9 10 11 12 13 14

    Read the article

  • How do I limit the game loop?

    - by user1758938
    How do I make a game update at a consistent speed? For example, this would loop too fast: while(true) { GetInput(); Render(); } This just wont work (hard to explain): while(true) { GetInput(); Render(); Sleep(16); } How do I sync my game to a certain framerate and still have input and functions going at a consistent rate?

    Read the article

  • Ubuntu 12.10 stucks in a Login Loop

    - by Calvin Wahlers
    My problem: As you can guess my Ubuntu 12.10 stucks in a login loop when trying to enter my desktop. Means the screen gets black and soon after that the login screen comes back. I'm a Ubuntu Newbie so if there's any answer please explain in a simply understandable language :) I've already read that the problem might be caused by an error depending on the graphics, so I post my graphics to: My graphics: ATI Radeon 7670M Hope you can help me, thank you ;)

    Read the article

  • Limit The Game Loop?

    - by user1758938
    How do I make a game go at the same speed? You probly dont understand that so here are examples: This Would Loop Too Fast while(true) { GetInput(); Render(); } This Just Wont Work, Hard To Exlplain while(true) { GetInput(); Render(); Sleep(16); } Basicly How Do I Sync It To Any FrameRate And Still Have To Input And Funtions Going At The Same Rate?

    Read the article

  • Unhandled event loop exception "Unknown Mozilla path" with Eclipse 3.7.1

    - by r.bitter
    I installed the Tizen SDK 2.0 which uses Eclipse 3.7.1 as an IDE on Ubuntu 12.10 64bit. When trying to create a Tizen Web Project I got the following error message from Eclipse: Unhandled event loop exception No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)] The problem is that Eclipse is configured to use Xulrunner as a headless browser inside the IDE. Xulrunner is not in the repositories for Ubuntu 12.10 any more, therefore Eclipse is not able to find the libraries.

    Read the article

  • ubuntu stuck in a login loop after editing profile file

    - by varunit
    I'm stuck in a login loop now. What I did was edited /etc/profile as root and added the following line export PATH = /opt/my jdk 7 path/bin:$PATH After logging out and tried to login, I cannot I have tried booting in recovery mode, entered root prompt and tried to edit the file in vi but it always opens in read only mode and hence cannot be saved. I just need a way to delete that line and boot into ubuntu again. Please help me out guys..

    Read the article

  • how to execute for loop with sed in terminal

    - by vipin8169
    I want to execute the for loop with sed command, and is getting an error for the same for i in <comma-separated server name list>;do "command";echo $i;done where command=sed '/^$/d' /home/nextag/instance.properties|grep -vc '#' I'm getting the following error :- -bash: sed "/^$/d" /home/nextag/instance.properties|grep -vc#: No such file or directory lu1 What is the correct way to execute this command to get the perfect output I tried this as well for i in lu1;do 'sed \'/^$/d\' /home/nextag/instance.properties|grep -vc \'#\'';echo $i;done Also, can some explain the part '/^$/d'in sed '/^$/d' /home/nextag/instance.properties|grep -vc '#'

    Read the article

  • unable to boot and boot-loop on splash screen

    - by Joel St Martin
    hey i have tried to install ubuntu many times, but once it installs it boot-loops at the splash screen. it just loops through the boot sound and the screen not sure why. nothing has seemed to work. also its only alowing me to boot windows all other oporating systems crash and loop just like ubuntu (android x86, linux mint, red hat, ubuntustudio). compac amd 64 3400+ 1gig ram 2 hhd (200 gig/120 gig) 1 ssd (500gig) win7 x86 a video showing what happens

    Read the article

  • Delay command execution over sockets

    - by David
    I've been trying to fix the game loop in a real time (tick delay) MUD. I realized using Thread.Sleep would seem clunky when the user spammed commands through their choice of client (Zmud, etc) e.g. east;south;southwest would wait three move ticks and then output everything from the past couple rooms. The game loop basically calls a Flush and Fill method for each socket during each tick (50ms) private void DoLoop() { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); while (running) { // for each socket, flush and fill ConnectionMonitor.Update(); stopWatch.Stop(); WaitIfNeeded(stopWatch.ElapsedMilliseconds); stopWatch.Reset(); } } The Fill method fires the command events, but as mentioned before, they currently block using Thread.Sleep. I tried adding a "ready" flag to the state object that attempts to execute the command along with a queue of spammed commands, but it ends up executing one command and queuing up the rest i.e. each subsequent command executes something that got queued up that should've been executed before. I must be missing something about the timer. private readonly Queue<SpammedCommand> queuedCommands = new Queue<SpammedCommand>(); private bool ready = true; private void TryExecuteCommand(string input) { var commandContext = CommandContext.Create(input); var player = Server.Current.Database.Get<Player>(Session.Player.Key); var commandInfo = Server.Current.CommandLookup .FindCommand(commandContext.CommandName, player.IsAdmin); if (commandInfo != null) { if (!ready) { // queue command queuedCommands.Enqueue(new SpammedCommand() { Context = commandContext, Info = commandInfo }); return; } if (queuedCommands.Count > 0) { // queue the incoming command queuedCommands.Enqueue(new SpammedCommand() { Context = commandContext, Info = commandInfo, }); // dequeue and execute var command = queuedCommands.Dequeue(); command.Info.Command.Execute(Session, command.Context); setTimeout(command.Info.TickLength); return; } commandInfo.Command.Execute(Session, commandContext); setTimeout(commandInfo.TickLength); } else { Session.WriteLine("Command not recognized"); } } Finally, setTimeout was supposed to set the execution delay (TickLength) for that command, and makeReady just sets the ready flag on the state object to true. private void setTimeout(TickDelay tickDelay) { ready = false; var t = new System.Timers.Timer() { Interval = (long) tickDelay, AutoReset = false, }; t.Elapsed += makeReady; t.Start(); // fire this in tickDelay ms } // MAKE READYYYYY!!!! private void makeReady(object sender, System.Timers.ElapsedEventArgs e) { ready = true; } Am I missing something about the System.Timers.Timer created in setTimeout? How can I execute (and output) spammed commands per TickLength without using Thread.Sleep?

    Read the article

  • Basic Android game loop having issues

    - by WillDaBeast509
    I've set up a very basic game loop that should draw a circle, run 100 times, then draw another. I also have a text field that should display how many times the loop has ran. However, the screen seems to not update. It displays a different value for the tick count (different each time the app is ran) and simply stays there. After exiting the app, I get an error saying "Unfortunately, MyApp has stopped." Here is the relevant code: DrawView public class DrawView extends SurfaceView implements SurfaceHolder.Callback { Paint p = new Paint(); MainThread thread; private int y=0; public DrawView(Context c) { super(c); thread = new MainThread(this, getHolder()); thread.running = true; getHolder().addCallback(this); setFocusable(true); } public void draw(Canvas c) { if(c==null) return; //super.onDraw(c); c.drawColor(Color.WHITE); p.setColor(Color.RED); p.setTextSize(32); p.setTypeface(Typeface.SANS_SERIF); c.drawCircle(getWidth()/2-100,getHeight()/2, 50, p); c.drawText("y = " + y, 50, 50, p); if(y>=100) { Log.i("DRAW", "drawing circle"); c.drawCircle(getWidth()/2+100,getHeight()/2, 50, p); } else y++; Log.i("INFO", "y = " + y); } @Override public boolean onTouchEvent(MotionEvent event) { return true; } public void onDraw(Canvas c){} public void surfaceCreated(SurfaceHolder p1) { thread.start(); } public void surfaceChanged(SurfaceHolder p1, int p2, int p3, int p4) { // TODO: Implement this method } public void surfaceDestroyed(SurfaceHolder p1) { thread.running = false; boolean retry = true; while (retry) { try { thread.join(); retry = false; } catch (InterruptedException e) { Log.i("EX", "cathing exception"); } } } } MainThread public class MainThread extends Thread { private DrawView page; private SurfaceHolder holder; public boolean running; public MainThread(DrawView p, SurfaceHolder h) { super(); page = p; holder = h; } @Override public void run() { while(running) { Canvas c = holder.lockCanvas(); page.draw(c); holder.unlockCanvasAndPost(c); } } } Here is an example log outupt: http://pastebin.com/tM9dUPuk It counts the number of ticks correctly and should draw the second circle, but the screen looks like its not updating. After closing the app, the log continues to run and keep outputting "y = 100 drawing circle" until it crashes and shows the error report. What is going on and how can I fix these two problems?

    Read the article

  • How do I make this loop all children recursively?

    - by Matrym
    I have the following: for (var i = 0; i < children.length; i++){ if(hasClass(children[i], "lbExclude")){ children[i].parentNode.removeChild(children[i]); } }; I would like it to loop through all children's children, etc (not just the top level). I found this line, which seems to do that: for(var m = n.firstChild; m != null; m = m.nextSibling) { But I'm unclear on how I refer to the current child if I make that switch? I would no longer have i to clarify the index position of the child. Any suggestions? Thanks!

    Read the article

  • How to run a loop of queries in access?

    - by tksy
    Hi I have a database with a table which is full of conditions and error messages for checking another database. I want to run a loop such that each of these conditions is checked against all the tables in the second database and generae a report which gives the errors. Is this possible in ms access. For example, querycrit table id query error 1 speed<25 and speed>56 speed above limit 2 dist<56 or dist >78 dist within limit I have more than 400 queries like this of different variables. THe table against which I am running the queries is records table id speed dist accce decele aaa bbb ccc 1 33 34 44 33 33 33 33 2 45 44 55 55 55 22 23 regards ttk

    Read the article

  • VB.NET For Each steps into loop body for an IEnumerable collection! How? Why?

    - by Paul Sasik
    This is weird. I have a class that inherits from IEnumrable whose Count property is reporting 0 (zero) elements but the For Each loop steps into the loop body and tries to use the variable where it should just be moving on. My code: On Error Resume Next Dim d As Foo For Each d In fooCollection ' use d and throws an exception Next d Weirder still, every time d is accessed i get an exception thrown in the output window: A first chance exception of type 'System.NullReferenceException' but i'm not stopping on the exception (not in a try/catch block). Is "On Error Resume Next" causing this weirdness? Weirdness found: Per Rowland's and JohnH's comments i checked the Foo class: The GetEnumerator method inside of Foo didn't actually return anything! It had an empty body. That coupled with the On Error Resume Next before the loop caused the havoc! Wow this was ugly. Thanks for the clues guys!

    Read the article

  • How to get the previous value from incrementing variable in for loop?

    - by Parth
    In My last post I asked : How to create dynamic incrementing variable using "for" loop in php? like wise: $track_1,$track_2,$track_3,$track_4..... so on.... whose answer I selected as for($i = 0; $i < 10; $i++) { $name = "track_$i"; $$name = 'hello'; } and for($i = 0; $i < 10; $i++) { ${'track_' . $i} = 'val' } Now, What If I need the Value of variable previous than the current variable?

    Read the article

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