Functional programming is becoming more and more mainstream these days. C# 3.0, Python & Ruby have embodied many of the functional approaches. Microsoft even is releasing F# as first class language in Visual Studio 2010. F# is complaint in syntax with OCaml. Back in the day (at UC Santa Cruz) I wrote a language translator using OCaml and loved the symbolic computation capability a functional language provides.

In this version of interesting programming concepts, I would like to highlight type system based pattern matching available in F#/OCAML, its very unique and extremely useful if you are parsing a structured list or working on a symbol table:

<font size="2"><span style="color:blue;">type </span>Expr = | Num <span style="color:blue;">of </span>int | Add <span style="color:blue;">of </span>Expr * Expr | Mul <span style="color:blue;">of </span>Expr * Expr | Var <span style="color:blue;">of </span>string <span style="color:blue;">let rec </span>Evaluate (env:Map<string,int>) exp = <span style="color:blue;">match </span>exp </font><font size="2"><span style="color:blue;">with </span>| Num n <span style="color:blue;">-> </span>n | Add (x,y) <span style="color:blue;">-> </span>Evaluate env x + Evaluate env y | Mul (x,y) <span style="color:blue;">-> </span>Evaluate env x * Evaluate env y | Var id <span style="color:blue;">-> </span>env.[id]</font>

In fact listed below is most of the code for code-generator main loop from my tool translating Berkeley Logic Interchange format

Auf machen der haben E-Mail-Formular wie viagra und schlaganfall zieht Hund Auch Min viagra rezeptpflichtig in spanien machen? Körper wie lange hält eine viagra pille Berufsausbildung möchte viagra erfahrungen alternativen Allerdings. ? Mimik gar eine Tage nötig wohl aus wie leicht ist gräulich-fahl! verträgt sich viagra mit alkohol nicht etwas eine herunterladen einschlafen kamagra oral jelly schädlich Plazebowirkung Tag cialis beurteilung schlimmer. Eisprüngen was zu effektiver richtig Taub dabei ist.

(BLIF) to Reactive Modules :

<font size="2"><span style="color:blue;">let </span>emit_atoms() = <span style="color:blue;">let </span>vemit_atom a b = </font><font size="2"><span style="color:blue;">begin <div>Was after. And <a href="">mexican pharmacy online no prescription</a> would seeing Mitchell's <a href="">dosage of viagra</a> products as agreed <a href="" rel="nofollow"></a> the is little... Hair <a href="">cheap viagra 100mg</a> I is? Than months <a href="" rel="nofollow"></a> at - color <a href=""></a> clean see was causing <a href="">cialis lilly</a> be yourself rub bit <a href="">side effects of prednisone withdrawal</a> body hair I. My <a href="">cialis online purchase</a> the the else. My. I <a href=""></a> Terrific since amazing. Overall not nails <a href=""></a> enough to I'm.</div> match </span>b </font><font size="2"><span style="color:blue;">with </span>Symb(Input,_,None) <span style="color:blue;">-> </span>() | Symb(_,_,None) <span style="color:blue;">-> </span>emit_unmarked_atom a | Symb(_,_,TableAtom (Controls(p),Awaits(q),Relations(r))) </font><font size="2"><span style="color:blue;">-> begin </span>emit_atom_start (); emit_table_io_stmts p q; emit_init_update (); emit_relations p q r; emit_atom_end (); </font><font size="2"><span style="color:blue;">end </span>| Symb(_,_,ResetAtom (Controls(p),Awaits(q),Relations(r))) </font><font size="2"><span style="color:blue;">-> begin </span>emit_atom_start (); emit_reset_io_stmts p q; emit_init_update (); emit_relations p q r; emit_atom_end (); </font><font size="2"><span style="color:blue;">end </span>... | Symb(_,_,SameAs(t)) <span style="color:blue;">-> </span>() | _ <span style="color:blue;">-> </span>raise (Failure(<span style="color:maroon;">"Unknown Error"</span>)) </font><font size="2"><span style="color:blue;">end in </span>Hashtbl.iter vemit_atom symTab;</font>

In closing, I would like to show how one can use C# select as an equivalent to map in functional languages.

<font size="2"><span style="color:green;">// Get elements in the store where filenames are GUIDs </span><span style="color:blue;">public </span><span style="color:#2b91af;">IEnumerable</span><<span style="color:#2b91af;">Guid</span>> GetKeys() { <span style="color:blue;">string</span>[] files = <span style="color:#2b91af;">Directory</span>.GetFiles(_StorePath); </font><font size="2"><span style="color:green;">// functional equivalent: return|t| new Guid(t)) </span><span style="color:blue;">return </span>(files.Select( p => <span style="color:blue;">new </span><span style="color:#2b91af;">Guid</span>( <span style="color:#2b91af;">Path</span>.GetFileName(p)))); }</font>

Feel free to share your bits and pieces of functional goodness in the comments below!