Hi Kane:

While zakaluka is teaching you to fish, I'll make lunch.

If you just want to use library functions, then the Set module provides the functionality you are looking for:

1
2
3
4
5
6
7
#light
let a = Set.of_list [2;3;4]
let b = Set.of_list [3;4;5]
let union = a + b
let inter = Set.inter a b
printfn "Union = %A" union
printfn "Intersection = %A" inter

If, however, you are interested in writing these yourself, then see the good (free) O'Riley OCaml book at [link:caml.inria.fr] or pick up Robert Pickering's excellent book, which has great chapters on functional, imperative, and OO programming in F#. [link:www.amazon.com]

By on 10/15/2007 12:07 AM ()

I recently discovered that you can actually create a set with only:

1
set [1;2;3]

Very cool! :-)

By on 10/19/2007 1:11 PM ()

Well, if I didn't know better, I'd say this is a classic homework assignment for any elementary Programming Languages class.

As such, I only offer 1 hint: make use of F#'s built-in looping operators over lists (map, fold, etc). They'll reduce the majority of the functions you have to 1-liners.

Regards,

Z.

By on 10/14/2007 10:49 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper