我已经看过很多(代码高尔夫)Perl程序,即使我看不懂它们(不知道Perl)我想知道你怎么能设法得到这么少的代码去做20一些其他编程语言中的行.
我想学习如何编写功能强大而又简短的程序,就像你从代码高尔夫挑战中所知道的那样.什么是最好的开始?我不想学习"干净"Perl - 我想编写脚本,即使我在一周后不再理解.
如果还有其他编程语言,我可以写更短的代码,请告诉我.
什么是更快和/或更好?
vector<myType> myVec;
int i;
myType current;
for( i = 0; i < 1000000; i ++ )
{
current = myVec[ i ];
doSomethingWith( current );
doAlotMoreWith( current );
messAroundWith( current );
checkSomeValuesOf( current );
}
Run Code Online (Sandbox Code Playgroud)
要么
vector<myType> myVec;
int i;
for( i = 0; i < 1000000; i ++ )
{
doSomethingWith( myVec[ i ] );
doAlotMoreWith( myVec[ i ] );
messAroundWith( myVec[ i ] );
checkSomeValuesOf( myVec[ i ] );
}
Run Code Online (Sandbox Code Playgroud)
我目前正在使用第一个解决方案.每秒真的有数百万次调用,每一位比较/移动都是性能问题.