Using F# Code from IronPython

IronPython isn't the only new language going mainstream on the .NET framework. In fact the dynamic languages team (responsible for IronRuby, IronPython and the Dynamic Language Runtime) are part of a larger team called the GO team - Growth Opportunities.

One of these languages is F#, a functional language created by Don Syme and team and based on Ocaml. Because it runs on the .NET framework (or Mono) F# has the great advantage over many interesting functional languages in being of immediate practical use! It also lends itself to polyglot programming - algorithms and problems particularly suited to being solved in a functional language can easily be mixed with code written in C# or IronPython. F# is already beloved by statisticians who where previously working in C#. Like Python it has a powerful interactive shell.

Luis Diego Fallas has a blog entry on using F# code from IronPython:
F# has its own built-in types like lists and tuples. Although Python has similarly named types they have different implementations. Luis shows adding references to F# assemblies and using F# types, functions and operators.
We can call F# functions to process values generated by fibo. For example the following IronPython code prints the first 15 squared Fibonacci numbers.

for n in Seq.map[int,int]( FuncConvert.ToFastFunc[int,int](lambda x: x*x) , Seq.take[int](15,fibo())):

print n

Comments

Popular posts from this blog

Extending Abobe Flash Player and AIR with Python and Ruby

Further Adventures of the Debugger

IronPython Tools for Visual Studio CTP3