• Sharp Things

    Adventures in F#--Lazy Like a Fox

    • 3 Comments
    Jomo Fisher--This is the next part of the open-notebook series documenting my exploration of F#. Today, I'm looking at the lazy keyword. When an F# function is invoked its value is immediately evaluated. F# does not do lazy evaluation by default. However...
  • Sharp Things

    Adventures in F#--Corecursion

    • 6 Comments
    Jomo Fisher--In a prior post I touched on recursion in F#. One of the comments was about mutually recursive functions. The example given was, let f1 a do print a f2 a let f2 a do print a f1 a f1 1 It turns out that this F# doesn't compile because F# scoping...
  • Sharp Things

    Adventures in F#--Tail Recursion in Three Languages

    • 12 Comments
    Jomo Fisher—Here’s the F# I'm looking at today: #light let rec f n = do printf "%d\n" n f (n+1) f 1 This defines a recursive function 'f' that takes a value 'n' as a parameter. This function prints the value of n to the console and then calls itself with...
  • Sharp Things

    Adventures in F#--Discriminated Unions

    • 7 Comments
    Jomo Fisher-- Easily my favorite feature of F# so far is the combination of discriminated union and pattern matching. Together, these allow you to concisely represent a complex language-like data structure and operations over that structure. We used this...
  • Sharp Things

    Adventures in F#--Poking Tuples with a Stick

    • 3 Comments
    Jomo Fisher--In a comment on my bloglet about type inference in F# John Harrop suggested I try: let f (a,b)=(b,a) Which, under Reflector, gives this equivalent in C#: public static Tuple<U, T> f<T, U>(T a, U b) { return new...
  • Sharp Things

    Adventures in F#--Function Type Inference

    • 6 Comments
    Consider this F#: let Reverse a b = b a This means: given a and b (whatever they may be) call b as a function with 'a' as the argument. When I compile this and look at it under reflector I get: public static U ( ,Microsoft.FSharp.Core.FastFunc...
  • Sharp Things

    Adventures in F#--Probing Type Inference

    • 12 Comments
    Jomo Fisher--I was curious about type inference in F# and I wondered what would happen if there was really no way for the compiler to infer a type. Consider this function which takes a value and just returns it: let func n = n Like last time , I compiled...
  • Sharp Things

    Adventures in F#--The Lay of the Land

    • 5 Comments
    Jomo Fisher--I'm taking some time now to better understand F#. Right now, I understand the concept of functional code and have some narrow but deep experience by way of the work we did on LINQ for C# 3.0. My goal is to understand F# as well as I understand...
Page 1 of 1 (8 items)