Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rian Nolan
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.
 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • 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?
 
Katrina Owen
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!
 
Gary Ba
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic