Skip to content

Check your F# skills

December 2, 2011

While working on Project Euler Problem 54 and considering data presentation I came up with the following snippet:

type IntPair =
    | Foo of int*int | Bar of int*int

    member __.LValue =
        match __ with
        | Bar(x,y) | Foo(x,y) -> x

    member __.RValue = function
        | Bar(x,y) | Foo(x,y) -> y

let a = Bar(10,5).LValue
let b = Foo(10,5).RValue

Try finding what would be the values of a and b without help from FSI or VS.

Advertisements

From → F#

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: