关于F#的用处

 

The first application was parsing 110GB of log data spread over 11,000 text files in over 300 directories and importing it into a SQL database. The whole application is 90 lines long (including comments!) and finished the task of parsing the source files and importing the data in under 18 hours; that works out to a staggering 10,000 log lines processed per second! Note that I have not optimized the code at all but written the application in the most obvious way. I was truly astonished as I had planned at least a week of work for both coding and running the application.
The second application was an analysis of millions of feedbacks.We had developed the model equations and I literally just typed them in as an F# program; together with the reading-data-from-SQL-database and writing-results-to-MATLAB-data-file the F# source code is 100 lines long (including comments). Again, I was astonished by the running time; the whole processing of the millions of data items takes 10 minutes on a standard desktop machine. My C# reference application (from some earlier tasks) is almost 1,000 lines long and is no faster. The whole job from developing the model equations to having first real world data results took 2 days.
Ralf Herbrich, Microsoft Research
(http://blogs.msdn.com/dsyme/archive/2006/04/01/566301.aspx)

The first application was parsing 110GB of log data spread over 11,000 text files in over 300 directories and importing it into a SQL database. The whole application is 90 lines long (including comments!) and finished the task of parsing the source files and importing the data in under 18 hours; that works out to a staggering 10,000 log lines processed per second! Note that I have not optimized the code at all but written the application in the most obvious way. I was truly astonished as I had planned at least a week of work for both coding and running the application.


The second application was an analysis of millions of feedbacks.We had developed the model equations and I literally just typed them in as an F# program; together with the reading-data-from-SQL-database and writing-results-to-MATLAB-data-file the F# source code is 100 lines long (including comments). Again, I was astonished by the running time; the whole processing of the millions of data items takes 10 minutes on a standard desktop machine. My C# reference application (from some earlier tasks) is almost 1,000 lines long and is no faster. The whole job from developing the model equations to having first real world data results took 2 days.Ralf Herbrich, Microsoft Research(http://blogs.msdn.com/dsyme/archive/2006/04/01/566301.aspx)

 

看看判断质数的F#代码,好像的确思路不一样...但是哪个更简单就不知道了~

 

1 let isPrime n =
2 let rec isPrimerInternal num m =
3 match m with
4 | 1 -> true
5 | _ -> match num % m with
6 | 0 -> false
7 | _ -> isPrimerInternal n (m - 1)
8 isPrimerInternal n ((int)(sqrt((double)n)))

 

 

 

 

posted on 2010-03-09 00:32  grapeot  阅读(828)  评论(0编辑  收藏  举报

导航