• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Query on 4b (Say) "unrolling loops" nitpick

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a bit befuddled in 4b(Say) at the moment.
I have it "working" in the broadest possible sense, but I'm obviously overcomplicating matters somewhat, as one of the nitpicks was:

You are putting a whole lot of effort into setting things up so you can use a loop... 3 times. 4 at the most.
I'd like you to "unroll" the loop, hard code each instance, and we'll take it from there.


...and I'm not not quite sure how to "unroll" a loop (or loops)
Should I go from this:

to (something like) this:

Any advice on unrolling loops?
Should I stop rolling my own?
Cheers,
Brian.
 
Bartender
Posts: 1847
14
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just want to say that I don't know the answer... and I hate Say b.

And.... if you're not looping, then why the heck does 'i' make a difference anyways... can't you just do the stuff without looping it?
 
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Janeice said (no, not the censored bit!)

you don't need i, just do something like this.



If you get stuck, ping your nitpicker for hints, or ask obliquely here on the forum!
 
Ranch Hand
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
random reply to your quesetion...

I too had a difficulty with Say b so your not the only one.

Garry
 
Rian Nolan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found these threads which managed to cover off all of my concerns about unrolling loops and not using ternary operators:
Nice to know that I'm not completely off the beaten track!
Math, Ternaries, Passing and Returning
Say 4b - completely stumped
...so attempt#2 with ifs everywhere, and nested loops unrolled is on its way...
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rian, I promise it's worth it. I know it feels just awful to hard code it like that... but there are efficiencies and beautiful things on the other side that you just cannot get to while you have that loop in place. Promise.
 
    Bookmark Topic Watch Topic
  • New Topic