Jomo Fisher--F# is about conciseness. Consider the interview question that asks you to reverse a singly-linked-list. I’ve been asked this question twice in interviews and even the cleanest implementation in the interviewer’s chosen language was long and it was hard to show that I’d covered the corner cases. The F# answer is concise and self-evidently correct now that I’ve learned F# well enough:
// Take two lists, source and target, and append all the items from source
// to target in reverse order.
let rec AppendReverse source target =
match source with
|  -> target
| (head::tail) -> AppendReverse tail (head::target)
// Call AppendReverse with the empty list for target.
let Reverse list =
AppendReverse list 
Once you have F# installed, you’re free to just start coding. These steps take about ten seconds:
- Press Ctrl+N (new file) and select Script\F# Script File
- In the opened .fsx file add:
- One time only, press Ctrl+Alt+F to bring up the F# interactive window.
- Press Ctrl+A (select everything) and then Alt+Enter (execute)
That’s it. We’ve tried to eliminate every piece of friction between you and the code you want to write.
We call these files scripts, but they’re not watered down in any way. They are actual F# which means they are compiled, statically typed and have access to .NET. There’s just not a project or even an explicit build step. In fact, this is one of the reasons F# needed a Visual Studio language service that can actively display errors and warnings as you type.
You can pick up the CTP of F# 184.108.40.206 here: http://msdn.com/fsharp
This posting is provided "AS IS" with no warranties, and confers no rights.
- Don's Announcement [ reddit ][ digg ] - F# Scripts -- Zero to Execute in Ten Seconds [ reddit ][ digg
Don Syme just announced today the F# Community Technical Preview (CTP) Release September 2008 which is
I’m very pleased to announce the availability of the F# September 2008 CTP Release , launched via the
Oh dear, how about:
template< class T >
T reverse( const T& other )
return T( other.rbegin(), other.rend() );
That's the entire point of BCL has missed. On generics and so much more. F# leading nowhere too it seems.
Oh yes, did I say you have the same mechanics for COMPILE-TIME.
All this runtime nonsense is so off the mark, it is incredible it improved only so slightly on Java.. life goes on.
Thank you, I'd forgotten that I wanted to mention that in the real world you should just use the built in function:
My code in the article is O(n) but why reinvent the wheel?
My code in the article is successful if it can show the power and expressiveness of F# language primitives.
First, let me remind you that in my new ongoing quest to read source code to be a better developer ,
How can one add references to assemblies in a script?