Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What simple, non-trivial, usable code have you created in F#

Tags:

f#

I'm trying to learn F#, but since I have never done any functional programming or taken a class in it, I find it very hard to generalize the trivial fibonacci or factorial examples into how I would do something usable.

So, what simple but nontrivial non-trivial and usable F# code is there on the net?

like image 715
erikkallen Avatar asked Apr 28 '09 21:04

erikkallen


2 Answers

Here is a great session from PDC -- he does a fairly non-trivial example application.

like image 170
JP Alioto Avatar answered Nov 15 '22 08:11

JP Alioto


I like to use it whenever I have the need for parser support (nowadays you might call it DSL) and whenever I implement symbol-processing algorithms.

The latest productive code I've written in F# concerns filters (used to filter incomming messages to a logging service). I've got a couple of basic filters (that processes the subject, etc.) and higher-order logic filters that combine other filters with AND/OR/NOT operators. The implementation simplifies such "expressions" by converting them to CNF, collecting by type and using special rules (like a < 5 && a < 10 => a < 5, etc.) On top of this I createt a simple parser with fsyacc to give the users of this service a simpler way to create filters.

I guess the hole thing has in F# as many lines of code I would have needed with C# to write just the simplification ;)

like image 26
Random Dev Avatar answered Nov 15 '22 09:11

Random Dev