Sir E Brum
Veteran
Last edited:
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
if ($algo eq 'L') {
&L();
} elsif ($algo eq 'R') {
&R();
} elsif ($algo eq 'U') {
&U();
} elsif ($algo eq 'D') {
&D();
} elsif ($algo eq 'F') {
&F();
} elsif ($algo eq 'B') {
&B();
}
Code:if ($algo eq 'L') { &L(); } elsif ($algo eq 'R') { &R(); } elsif ($algo eq 'U') { &U(); } elsif ($algo eq 'D') { &D(); } elsif ($algo eq 'F') { &F(); } elsif ($algo eq 'B') { &B(); }
I'm sure you can clean this up. You've even used it twice.
Another suggestion: Never use one variable for two different things.
What did you mean by clean it up? I can't think of any way to do that.
1. That code looks UGLY
3. How did you fix the problem?
1. That code looks UGLY
I didn't want to say it that hard.
Sir E Brum: Please don't delete your first post.
3. How did you fix the problem?
He didn't.
1. Use parameters
2. Use local variables
3. Don't reuse names (foreach $algo (@algo))
Just because a language lets you do something, doesn't mean you should. What are you trying to accomplish anyway? If you tell us, then maybe the programmers on the board can show you better examples.
Ah well that does make sense. I normally just program for my own enjoyment, but you guys are making some good points that I will have to keep in mind.
Come on! Everyone can write code that works. Clean code is the only enjoyable part of programming in my opinion.
That means that you have a teacher that understood you.This reminds me of the time I turned in some Java source code using only varying lengths of underscores as variables. My CompSci teacher just laughed. It compiled and ran with no problems so I got full marks still.